Pre-fills the attendee name from a speaker profile, if there is one.

Resolves #8.
This commit is contained in:
Christopher Neugebauer 2016-04-01 21:39:54 +11:00
parent be277c17d2
commit 89cba55807
2 changed files with 22 additions and 2 deletions

View file

@ -47,6 +47,12 @@ class AttendeeProfileBase(models.Model):
registration progess.
'''
@classmethod
def name_field(cls):
''' This is used to pre-fill the attendee's name from the
speaker profile. If it's None, that functionality is disabled. '''
return None
attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE)

View file

@ -1,3 +1,4 @@
import symposion.speakers
import sys
from registrasion import forms
@ -174,12 +175,25 @@ def handle_profile(request, prefix):
except ObjectDoesNotExist:
profile = None
# TODO: pull down the speaker's real name from the Speaker profile
ProfileForm = get_form(settings.ATTENDEE_PROFILE_FORM)
# Load a pre-entered name from the speaker's profile,
# if they have one.
try:
speaker_profile = request.user.speaker_profile
speaker_name = speaker_profile.name
except ObjectDoesNotExist:
speaker_name = None
name_field = ProfileForm.Meta.model.name_field()
initial = {}
if name_field is not None:
initial[name_field] = speaker_name
form = ProfileForm(
request.POST or None,
initial=initial,
instance=profile,
prefix=prefix
)