remove workaround, fix message ids

v1-0-stable
Christian Merten 7 years ago
parent 83b4bd09a4
commit 83ec07fd18

@ -6,24 +6,25 @@ import subprocess
class Command(BaseCommand): class Command(BaseCommand):
help = 'Shows reply-to addresses' help = 'Shows reply-to addresses'
requires_system_checks = False
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('message_id', type=int) parser.add_argument('message_id', nargs='?', default="-1")
def handle(self, *args, **options): def handle(self, *args, **options):
replies = [] replies = []
try: try:
message = Message.objects.get(pk=options['message_id']) message_id = int(options['message_id'])
message = Message.objects.get(pk=message_id)
if message.reply_to: if message.reply_to:
replies = message.reply_to.all() replies = message.reply_to.all()
except Message.DoesNotExist: except (Message.DoesNotExist, ValueError):
pass pass
if not replies: if not replies:
# send mail to all jugendleiters # send mail to all jugendleiters
replies = Member.objects.filter(group__name='Jugendleiter0', replies = Member.objects.filter(group__name='Jugendleiter',
gets_newsletter=True) gets_newsletter=True)
forwards = [l.email for l in replies] forwards = [l.email for l in replies]
subprocess.call(["forward"] + forwards)
self.stdout.write("forwarded email to {}".format(forwards)) self.stdout.write(" ".join(forwards))

@ -72,16 +72,12 @@ class Message(models.Model):
# remove any underscores from subject to prevent Arne from using # remove any underscores from subject to prevent Arne from using
# terrible looking underscores in subjects # terrible looking underscores in subjects
self.subject = self.subject.replace('_', ' ') self.subject = self.subject.replace('_', ' ')
if len(self.reply_to.all()) > 0: message_id = "<{}@jdav-ludwigsburg.de>".format(self.pk)
temporary_reply_to = [r.email for r in self.reply_to.all()]
else:
temporary_reply_to = None
try: try:
success = send(self.subject, get_content(self.content), success = send(self.subject, get_content(self.content),
SENDING_ADDRESS, SENDING_ADDRESS,
emails, emails,
reply_to=temporary_reply_to, message_id=message_id,
message_id=self.pk,
attachments=attach) attachments=attach)
if success == SENT or success == PARTLY_SENT: if success == SENT or success == PARTLY_SENT:
self.sent = True self.sent = True

Loading…
Cancel
Save