BadgeAndProfile is replaced with AttendeeProfileBase — consumer apps should subclass AttendeeProfileBase to make the registration process work :)
This commit is contained in:
parent
660e8cb75f
commit
be277c17d2
4 changed files with 49 additions and 75 deletions
|
@ -132,14 +132,6 @@ def ProductsForm(category, products):
|
|||
return ProductsForm
|
||||
|
||||
|
||||
class ProfileForm(forms.ModelForm):
|
||||
''' A form for requesting badge and profile information. '''
|
||||
|
||||
class Meta:
|
||||
model = rego.BadgeAndProfile
|
||||
exclude = ['attendee']
|
||||
|
||||
|
||||
class VoucherForm(forms.Form):
|
||||
voucher = forms.CharField(
|
||||
label="Voucher code",
|
||||
|
|
30
registrasion/migrations/0011_auto_20160401_0943.py
Normal file
30
registrasion/migrations/0011_auto_20160401_0943.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.2 on 2016-04-01 09:43
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('registrasion', '0010_auto_20160330_2342'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='AttendeeProfileBase',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('attendee', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='registrasion.Attendee')),
|
||||
],
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='badgeandprofile',
|
||||
name='attendee',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='BadgeAndProfile',
|
||||
),
|
||||
]
|
|
@ -41,73 +41,14 @@ class Attendee(models.Model):
|
|||
highest_complete_category = models.IntegerField(default=0)
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class BadgeAndProfile(models.Model):
|
||||
''' Information for an attendee's badge and related preferences '''
|
||||
|
||||
def __str__(self):
|
||||
return "Badge for: %s of %s" % (self.name, self.company)
|
||||
|
||||
def save(self):
|
||||
if not self.name_per_invoice:
|
||||
self.name_per_invoice = self.name
|
||||
super(BadgeAndProfile, self).save()
|
||||
class AttendeeProfileBase(models.Model):
|
||||
''' Information for an attendee's badge and related preferences.
|
||||
Subclass this in your Django site to ask for attendee information in your
|
||||
registration progess.
|
||||
'''
|
||||
|
||||
attendee = models.OneToOneField(Attendee, on_delete=models.CASCADE)
|
||||
|
||||
# Things that appear on badge
|
||||
name = models.CharField(
|
||||
verbose_name="Your name (for your conference nametag)",
|
||||
max_length=64,
|
||||
help_text="Your name, as you'd like it to appear on your badge. ",
|
||||
)
|
||||
company = models.CharField(
|
||||
max_length=64,
|
||||
help_text="The name of your company, as you'd like it on your badge",
|
||||
blank=True,
|
||||
)
|
||||
free_text_1 = models.CharField(
|
||||
max_length=64,
|
||||
verbose_name="Free text line 1",
|
||||
help_text="A line of free text that will appear on your badge. Use "
|
||||
"this for your Twitter handle, IRC nick, your preferred "
|
||||
"pronouns or anything else you'd like people to see on "
|
||||
"your badge.",
|
||||
blank=True,
|
||||
)
|
||||
free_text_2 = models.CharField(
|
||||
max_length=64,
|
||||
verbose_name="Free text line 2",
|
||||
blank=True,
|
||||
)
|
||||
|
||||
# Other important Information
|
||||
name_per_invoice = models.CharField(
|
||||
verbose_name="Your legal name (for invoicing purposes)",
|
||||
max_length=64,
|
||||
help_text="If your legal name is different to the name on your badge, "
|
||||
"fill this in, and we'll put it on your invoice. Otherwise, "
|
||||
"leave it blank.",
|
||||
blank=True,
|
||||
)
|
||||
of_legal_age = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name="18+?",
|
||||
blank=True,
|
||||
)
|
||||
dietary_requirements = models.CharField(
|
||||
max_length=256,
|
||||
blank=True,
|
||||
)
|
||||
accessibility_requirements = models.CharField(
|
||||
max_length=256,
|
||||
blank=True,
|
||||
)
|
||||
gender = models.CharField(
|
||||
max_length=64,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
|
||||
# Inventory Models
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import sys
|
||||
|
||||
from registrasion import forms
|
||||
from registrasion import models as rego
|
||||
from registrasion.controllers import discount
|
||||
|
@ -7,6 +9,7 @@ from registrasion.controllers.product import ProductController
|
|||
|
||||
from collections import namedtuple
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.contrib import messages
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
|
@ -30,6 +33,12 @@ GuidedRegistrationSection.__new__.__defaults__ = (
|
|||
(None,) * len(GuidedRegistrationSection._fields)
|
||||
)
|
||||
|
||||
def get_form(name):
|
||||
dot = name.rindex(".")
|
||||
mod_name, form_name = name[:dot], name[dot + 1:]
|
||||
__import__(mod_name)
|
||||
return getattr(sys.modules[mod_name], form_name)
|
||||
|
||||
@login_required
|
||||
def guided_registration(request, page_id=0):
|
||||
''' Goes through the registration process in order,
|
||||
|
@ -56,7 +65,7 @@ def guided_registration(request, page_id=0):
|
|||
|
||||
# Step 1: Fill in a badge and collect a voucher code
|
||||
try:
|
||||
profile = attendee.badgeandprofile
|
||||
profile = attendee.attendeeprofilebase
|
||||
except ObjectDoesNotExist:
|
||||
profile = None
|
||||
|
||||
|
@ -161,13 +170,15 @@ def handle_profile(request, prefix):
|
|||
attendee = rego.Attendee.get_instance(request.user)
|
||||
|
||||
try:
|
||||
profile = attendee.badgeandprofile
|
||||
profile = attendee.attendeeprofilebase
|
||||
except ObjectDoesNotExist:
|
||||
profile = None
|
||||
|
||||
# TODO: pull down the speaker's real name from the Speaker profile
|
||||
|
||||
form = forms.ProfileForm(
|
||||
ProfileForm = get_form(settings.ATTENDEE_PROFILE_FORM)
|
||||
|
||||
form = ProfileForm(
|
||||
request.POST or None,
|
||||
instance=profile,
|
||||
prefix=prefix
|
||||
|
|
Loading…
Reference in a new issue