Lowered target python version to 3.4

This commit is contained in:
Zakary Timson 2017-09-29 16:21:21 -04:00
parent 98acaee04f
commit 12119cb514
2 changed files with 6 additions and 6 deletions

View File

@ -23,8 +23,8 @@ def contact(request):
result = False result = False
if name is not None and email is not None and subject is not None and body is not None: if name is not None and email is not None and subject is not None and body is not None:
result = mail.send_mail(f'OACPL CONTACT: {subject}', body, settings.EMAIL_HOST_USER, [settings.EMAIL_CONTACT], result = mail.send_mail('OACPL CONTACT: %(subject)s' % locals(), body, settings.EMAIL_HOST_USER, [settings.EMAIL_CONTACT],
html_message=f'<strong>From:</strong> {name} ({email})<br><br>{body}') html_message='<strong>From:</strong> %(name)s (%(email)s)<br><br>{body}' % locals())
return JsonResponse({'success': True if result else False}) return JsonResponse({'success': True if result else False})
@ -51,7 +51,7 @@ def login(request):
perm = Permission.objects.get(codename='change_user') perm = Permission.objects.get(codename='change_user')
admins = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) | Q(is_superuser=True)).distinct().values_list('email', flat=True) admins = User.objects.filter(Q(groups__permissions=perm) | Q(user_permissions=perm) | Q(is_superuser=True)).distinct().values_list('email', flat=True)
print(admins) print(admins)
mail.send_mail('OACPL Case Law Request', f'{user.email} has requested case law access.', settings.EMAIL_HOST_USER, admins, html_message=f'<a href="#">{user.email}</a> has requested case law access.') mail.send_mail('OACPL Case Law Request', '%(user.email)s has requested case law access.', settings.EMAIL_HOST_USER, admins, html_message='<a href="#">%(user.email)s</a> has requested case law access.')
auth.login(request, user) auth.login(request, user)
return redirect('/') return redirect('/')
else: else:

View File

@ -14,10 +14,10 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
newsletters = Newsletter.objects.filter(Q(sent=False) & Q(publish__lte=timezone.now())) newsletters = Newsletter.objects.filter(Q(sent=False) & Q(publish__lte=timezone.now()))
subscribers = Subscriber.objects.all().values_list('email', flat=True) subscribers = Subscriber.objects.all().values_list('email', flat=True)
print(f'Found {len(newsletters)} unsent newsletters') print('Found %s unsent newsletters' % len(newsletters))
print(f'Found {len(subscribers)} subscribers') print('Found %s subscribers' % len(subscribers))
for newsletter in newsletters: for newsletter in newsletters:
print(f'Sending newsletter: "{newsletter.subject}"') print('Sending newsletter: "$s"' % newsletter.subject)
mail.send_mail(newsletter.subject, strip_tags(newsletter.body), settings.EMAIL_HOST_USER, subscribers, html_message=newsletter.body) mail.send_mail(newsletter.subject, strip_tags(newsletter.body), settings.EMAIL_HOST_USER, subscribers, html_message=newsletter.body)
newsletter.sent = True newsletter.sent = True
newsletter.save() newsletter.save()