Fixed signup emails and default group

This commit is contained in:
Zakary Timson 2018-01-06 13:42:37 -05:00
parent 71eaabda58
commit 468112b33a

View File

@ -44,9 +44,9 @@ def login(request):
user = User.objects.create_user(request.POST.get('username'), email=request.POST.get('email'), password=request.POST.get('password')) user = User.objects.create_user(request.POST.get('username'), email=request.POST.get('email'), password=request.POST.get('password'))
user.save() user.save()
default_group = Group.objects.get(name='default') default_group = Group.objects.filter(name='default')
if default_group: if default_group:
default_group.user_set.add(user) default_group[0].user_set.add(user)
if settings.EMAIL_HOST: if settings.EMAIL_HOST:
mail.send_mail('OACPL Registration', 'You have successfully registered to the Ontario Association of Child Protection Lawyers!', settings.EMAIL_HOST_USER, [request.POST.get('email')], html_message=render_to_string('email.html', {'content': 'You have successfully registered to the Ontario Association of Child Protection Lawyers!', 'name': user.username, 'base_url': settings.BASE_URL})) mail.send_mail('OACPL Registration', 'You have successfully registered to the Ontario Association of Child Protection Lawyers!', settings.EMAIL_HOST_USER, [request.POST.get('email')], html_message=render_to_string('email.html', {'content': 'You have successfully registered to the Ontario Association of Child Protection Lawyers!', 'name': user.username, 'base_url': settings.BASE_URL}))
@ -56,7 +56,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)
email = user.email email = user.email
mail.send_mail('OACPL Case Law Request', '%(email)s has requested case law access.', settings.EMAIL_HOST_USER, admins, html_message=render_to_string('email.html', {'content': '<a href="#">%(email)s</a> has requested case law access.', 'base_url': settings.BASE_URL})) mail.send_mail('OACPL Case Law Request', '%(email)s has requested case law access.' % locals(), settings.EMAIL_HOST_USER, admins, html_message=render_to_string('email.html', {'content': '<a href="#">%(email)s</a> has requested case law access.', 'base_url': settings.BASE_URL}))
auth.login(request, user) auth.login(request, user)
return redirect('/') return redirect('/')
else: else: