Use django to do lookups. Removes dj-user-accounts

This commit is contained in:
Sachi King 2017-03-26 12:29:36 +11:00
parent d5986de870
commit 8621bdb8fe
2 changed files with 10 additions and 7 deletions

View file

@ -5,7 +5,6 @@ django-reversion==1.10.1
django-sitetree>=1.7.0
django-taggit==0.18.0
django-timezone-field==1.3
django-user-accounts==1.3.1
easy-thumbnails==2.3
html5lib==0.9999999
markdown==2.6.5

View file

@ -5,7 +5,7 @@ import sys
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.urlresolvers import reverse
from django.db.models import Q
from django.http import Http404, HttpResponse, HttpResponseForbidden
@ -17,8 +17,6 @@ from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from account.models import EmailAddress
from symposion.proposals.models import (
ProposalBase, ProposalSection, ProposalKind
)
@ -137,10 +135,16 @@ def proposal_speaker_manage(request, pk):
return pending, token
email_address = add_speaker_form.cleaned_data["email"]
# check if email is on the site now
users = EmailAddress.objects.get_users_for(email_address)
if users:
try:
user = User.objects.get(email=email_address)
except MultipleObjectsReturned:
# FIXME: This is not handled in the previous code, so I'm not
# going to frett on this now, but should be handled as it is
# an occourance that really, really shouldn't occour.
# Previously, code took [0] from the list and continued.
raise NotImplementedError("Non unique email should not occour")
if user:
# should only be one since we enforce unique email
user = users[0]
message_ctx["user"] = user
# look for speaker profile
try: