92 except ObjectDoesNotExist: |
92 except ObjectDoesNotExist: |
93 acco = Accommodation(user=user, scope=scope) |
93 acco = Accommodation(user=user, scope=scope) |
94 |
94 |
95 sex = self.cleaned_data['sex'] |
95 sex = self.cleaned_data['sex'] |
96 accommodation_required = self.cleaned_data['accommodation_required'] |
96 accommodation_required = self.cleaned_data['accommodation_required'] |
97 accommodation_days = sum(filter([a1, a2, a3, a4, a5, a6])) |
|
98 |
97 |
99 a1 = self.cleaned_data['accommodation_on_1st'] |
98 a1 = self.cleaned_data['accommodation_on_1st'] |
100 a2 = self.cleaned_data['accommodation_on_2nd'] |
99 a2 = self.cleaned_data['accommodation_on_2nd'] |
101 a3 = self.cleaned_data['accommodation_on_3rd'] |
100 a3 = self.cleaned_data['accommodation_on_3rd'] |
102 a4 = self.cleaned_data['accommodation_on_4th'] |
101 a4 = self.cleaned_data['accommodation_on_4th'] |
103 a5 = self.cleaned_data['accommodation_on_5th'] |
102 a5 = self.cleaned_data['accommodation_on_5th'] |
104 a6 = self.cleaned_data['accommodation_on_6th'] |
103 a6 = self.cleaned_data['accommodation_on_6th'] |
105 |
104 |
|
105 accommodation_days = [a1, a2, a3, a4, a5, a6].count(True) |
|
106 |
106 acco.sex = sex |
107 acco.sex = sex |
107 acco.accommodation_required = accommodation_required |
108 acco.accommodation_required = accommodation_required |
108 acco.accommodation_days = _days |
109 acco.accommodation_days = accommodation_days |
109 |
110 |
110 acco._on_1st = a1 |
111 acco.accommodation_on_1st = a1 |
111 acco._on_2nd = a2 |
112 acco.accommodation_on_2nd = a2 |
112 acco._on_3rd = a3 |
113 acco.accommodation_on_3rd = a3 |
113 acco._on_4th = a4 |
114 acco.accommodation_on_4th = a4 |
114 acco._on_5th = a5 |
115 acco.accommodation_on_5th = a5 |
115 acco._on_6th = a6 |
116 acco.accommodation_on_6th = a6 |
116 |
117 |
117 |
118 |
118 acco.save() |
119 acco.save() |
119 |
120 |
120 return acco |
121 return acco |
127 cleaned = self.cleaned_data |
128 cleaned = self.cleaned_data |
128 |
129 |
129 sex = self.cleaned_data['sex'] |
130 sex = self.cleaned_data['sex'] |
130 accommodation_required = self.cleaned_data['accommodation_required'] |
131 accommodation_required = self.cleaned_data['accommodation_required'] |
131 |
132 |
132 a1 = self.cleaned_data['_on_1st'] |
133 a1 = self.cleaned_data['accommodation_on_1st'] |
133 a2 = self.cleaned_data['_on_2nd'] |
134 a2 = self.cleaned_data['accommodation_on_2nd'] |
134 a3 = self.cleaned_data['_on_3rd'] |
135 a3 = self.cleaned_data['accommodation_on_3rd'] |
135 a4 = self.cleaned_data['_on_4th'] |
136 a4 = self.cleaned_data['accommodation_on_4th'] |
136 a5 = self.cleaned_data['_on_5th'] |
137 a5 = self.cleaned_data['accommodation_on_5th'] |
137 a6 = self.cleaned_data['_on_6th'] |
138 a6 = self.cleaned_data['accommodation_on_6th'] |
138 |
139 |
139 selected_a_date = any([a1, a2, a3, a4, a5, a6]) |
140 selected_a_date = any([a1, a2, a3, a4, a5, a6]) |
140 |
141 |
141 if accommodation_required and (not sex or not selected_a_date): |
142 if accommodation_required and (not sex or not selected_a_date): |
142 #or accommodation_days == 0): |
143 #or accommodation_days == 0): |
148 |
149 |
149 class Meta: |
150 class Meta: |
150 model = Accommodation |
151 model = Accommodation |
151 fields = ('accommodation_required', |
152 fields = ('accommodation_required', |
152 'sex', |
153 'sex', |
153 '_on_1st', |
154 'accommodation_on_1st', |
154 '_on_2nd', |
155 'accommodation_on_2nd', |
155 '_on_3rd', |
156 'accommodation_on_3rd', |
156 '_on_4th', |
157 'accommodation_on_4th', |
157 '_on_5th', |
158 'accommodation_on_5th', |
158 '_on_6th', |
159 'accommodation_on_6th', |
159 ) |
160 ) |
160 |
161 |
161 |
162 |
162 class PaymentForm(forms.ModelForm): |
163 class PaymentForm(forms.ModelForm): |
163 """SciPyCon Payment form |
164 """SciPyCon Payment form |