Changeset - 89cba55807c1
[Not reviewed]
0 2 0
Christopher Neugebauer - 8 years ago 2016-04-01 10:39:54
chrisjrn@gmail.com
Pre-fills the attendee name from a speaker profile, if there is one.

Resolves #8.
2 files changed with 22 insertions and 2 deletions:
0 comments (0 inline, 0 general)
registrasion/models.py
Show inline comments
...
 
@@ -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)
 

	
 

	
registrasion/views.py
Show inline comments
 
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
 
    )
0 comments (0 inline, 0 general)