9 from django.contrib.auth.models import User |
9 from django.contrib.auth.models import User |
10 |
10 |
11 from .models import SIZE_CHOICES |
11 from .models import SIZE_CHOICES |
12 from .models import Registration |
12 from .models import Registration |
13 from .models import Wifi |
13 from .models import Wifi |
14 from project.kiwipycon.sponsor.models import Sponsor |
14 |
15 |
15 |
16 class RegistrationSubmitForm(forms.Form): |
16 class RegistrationSubmitForm(forms.Form): |
17 """PyCon registration form |
17 """PyCon registration form |
18 """ |
18 """ |
19 tshirt = forms.ChoiceField(choices=SIZE_CHOICES, required=True, |
19 tshirt = forms.ChoiceField(choices=SIZE_CHOICES, required=True, |
20 label=u'T-shirt size', help_text=u'Yes, we all get a t-shirt!') |
20 label=u'T-shirt size', help_text=u'Yes, we all get a t-shirt!') |
21 # beverage = forms.CharField(required=True, label=u'Beverage', |
|
22 # help_text=u'Your beverage of choice - coffee, tea etc', |
|
23 # max_length=255, |
|
24 # widget=forms.TextInput(attrs={'size':'50'})) |
|
25 # diet = forms.CharField(required=False, label=u'Dietary', |
|
26 # help_text=u'Special dietary requirements - vegetarian etc', |
|
27 # max_length=255, |
|
28 # widget=forms.TextInput(attrs={'size':'50'})) |
|
29 organisation = forms.CharField(required=True, label=u'Organisation', |
21 organisation = forms.CharField(required=True, label=u'Organisation', |
30 help_text=u'The primary organisation that you are a member of.', |
22 help_text=u'The primary organisation that you are a member of.', |
31 max_length=255, |
23 max_length=255, |
32 widget=forms.TextInput(attrs={'size':'50'})) |
24 widget=forms.TextInput(attrs={'size':'50'})) |
33 occupation = forms.CharField(required=True, label=u'Occupation', |
25 occupation = forms.CharField(required=True, label=u'Occupation', |
50 pay on the spot.""") |
42 pay on the spot.""") |
51 tutorial = forms.BooleanField(required=False, label=u'Tutorial', |
43 tutorial = forms.BooleanField(required=False, label=u'Tutorial', |
52 help_text=u'Do you intend to attend the tutorials?') |
44 help_text=u'Do you intend to attend the tutorials?') |
53 sprint = forms.BooleanField(required=False, label=u'Sprint', |
45 sprint = forms.BooleanField(required=False, label=u'Sprint', |
54 help_text=u'Do you intend to attend the sprints?') |
46 help_text=u'Do you intend to attend the sprints?') |
55 # party = forms.BooleanField(required=False, label=u'Pre-con party', |
|
56 # help_text=u'Do you intend to attend the pre-conference party on Friday?') |
|
57 # discount = forms.BooleanField(required=False, label=u'Student/Unwaged?', |
|
58 # help_text=u'You will be required to present your Community Services '\ |
|
59 # 'Card or Student ID on arrival.') |
|
60 # sponsor = forms.CharField(required=False, label=u'Sponsor code', |
|
61 # help_text=u'If attending as a sponsor please enter your sponsor code.', |
|
62 # max_length=50, |
|
63 # widget=forms.TextInput(attrs={'size':'20'})) |
|
64 |
47 |
65 def demographic_fields(self): |
48 def demographic_fields(self): |
66 return (self['organisation'], |
49 return (self['organisation'], |
67 self['occupation'], |
50 self['occupation'], |
68 self['city'], |
51 self['city'], |
72 return (self['tshirt'], |
55 return (self['tshirt'], |
73 self['conference'], |
56 self['conference'], |
74 self['tutorial'], |
57 self['tutorial'], |
75 self['sprint'], |
58 self['sprint'], |
76 self['allow_contact']) |
59 self['allow_contact']) |
77 |
|
78 # def other_fields(self): |
|
79 # return (self['sponsor'],) |
|
80 # |
|
81 # def clean_sponsor(self): |
|
82 # """Validates that the entered sponsor code is valid and within limits |
|
83 # of allowed guests |
|
84 # """ |
|
85 # sponsorcode = self.cleaned_data.get("sponsor") |
|
86 # if sponsorcode: |
|
87 # try: |
|
88 # sponsor = Sponsor.objects.get(slug=sponsorcode) |
|
89 # except ObjectDoesNotExist: |
|
90 # raise forms.ValidationError( |
|
91 # u"The sponsor code you entered is not valid.") |
|
92 # if sponsor: |
|
93 # guests = sponsor.guests |
|
94 # if guests == 0: |
|
95 # raise forms.ValidationError( |
|
96 # u"The sponsor code you entered is not valid.") |
|
97 # count = Registration.objects.filter( |
|
98 # sponsor=sponsorcode).count() |
|
99 # if count >= guests: |
|
100 # raise forms.ValidationError( |
|
101 # u"That sponsor has reached limit of guests.") |
|
102 # |
|
103 # |
|
104 # return sponsorcode |
|
105 |
60 |
106 |
61 |
107 class RegistrationEditForm(RegistrationSubmitForm): |
62 class RegistrationEditForm(RegistrationSubmitForm): |
108 id = forms.CharField(widget=forms.HiddenInput) |
63 id = forms.CharField(widget=forms.HiddenInput) |
109 sponsor = forms.CharField(required=False, widget=forms.HiddenInput) |
64 sponsor = forms.CharField(required=False, widget=forms.HiddenInput) |