Pre-fills the attendee name from a speaker profile, if there is one.
Resolves #8.
This commit is contained in:
parent
be277c17d2
commit
89cba55807
2 changed files with 22 additions and 2 deletions
|
@ -47,6 +47,12 @@ class AttendeeProfileBase(models.Model):
|
||||||
registration progess.
|
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)
|
attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import symposion.speakers
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from registrasion import forms
|
from registrasion import forms
|
||||||
|
@ -174,12 +175,25 @@ def handle_profile(request, prefix):
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
profile = None
|
profile = None
|
||||||
|
|
||||||
# TODO: pull down the speaker's real name from the Speaker profile
|
|
||||||
|
|
||||||
ProfileForm = get_form(settings.ATTENDEE_PROFILE_FORM)
|
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(
|
form = ProfileForm(
|
||||||
request.POST or None,
|
request.POST or None,
|
||||||
|
initial=initial,
|
||||||
instance=profile,
|
instance=profile,
|
||||||
prefix=prefix
|
prefix=prefix
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue