From 98acaee04f23d7d2cea3eeb7e59b384c3b2630b8 Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Mon, 18 Sep 2017 00:05:16 -0400 Subject: [PATCH] Added caselaw access request --- main/views.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/main/views.py b/main/views.py index ec704af..1ec480d 100644 --- a/main/views.py +++ b/main/views.py @@ -1,7 +1,8 @@ from django.http import JsonResponse from django.contrib import auth -from django.contrib.auth.models import User +from django.contrib.auth.models import User, Permission from django.core import mail +from django.db.models import Q from django.shortcuts import render, redirect from charter_members.models import Attorney @@ -46,13 +47,13 @@ def login(request): mail.send_mail('OACPL Registration', 'You have successfully registered to the Ontario Asscocaition of Child Protection Lawyers!', settings.EMAIL_HOST_USER, [request.POST.get('email')]) if request.POST.get('newsletter'): Subscriber.objects.create(email=request.POST.get('email')) - # TODO: If Case law access was requested, send an email out to staff + if request.POST.get('caselaw'): + 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) + 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'{user.email} has requested case law access.') auth.login(request, user) return redirect('/') - - elif request.POST.get('request') == 'reset': - # TODO: Reset password and send email - pass else: return render(request, 'login.html', {'navbar': False, 'footer': False})