@@ -145,13 +145,16 @@ class ConfirmationInvitationForm(BootstrapFormMixin, forms.ModelForm):
145
145
'fields' : [{'name' : 'tshirt_size' , 'space' : 4 }, {'name' : 'diet' , 'space' : 4 },
146
146
{'name' : 'other_diet' , 'space' : 4 },
147
147
{'name' : 'reimb' , 'space' : 12 }, {'name' : 'reimb_amount' , 'space' : 12 },
148
- {'name' : 'terms_and_conditions' , 'space' : 12 }, {'name' : 'mlh_required_terms' , 'space' : 12 },
149
- {'name' : 'mlh_required_privacy' , 'space' : 12 }, {'name' : 'mlh_subscribe' , 'space' : 12 }
148
+ {'name' : 'terms_and_conditions' , 'space' : 12 },
149
+ {'name' : 'mlh_required_terms' , 'space' : 12 },
150
+ {'name' : 'mlh_required_privacy' , 'space' : 12 }, {'name' : 'mlh_subscribe' , 'space' : 12 },
151
+ {'name' : 'diet_notice' , 'space' : 12 }
150
152
],
151
153
},
152
154
}
153
155
154
156
diet = forms .ChoiceField (label = 'Dietary requirements' , choices = models .DIETS , required = True )
157
+
155
158
reimb = forms .TypedChoiceField (
156
159
required = False ,
157
160
label = 'Do you need a travel reimbursement to attend?' ,
@@ -174,6 +177,12 @@ class ConfirmationInvitationForm(BootstrapFormMixin, forms.ModelForm):
174
177
"Organizer Newsletters and other communications from MLH."
175
178
)
176
179
180
+ diet_notice = forms .BooleanField (
181
+ required = False ,
182
+ label = 'I authorize "Hackers at UPC" to use my food allergies and intolerances information to '
183
+ 'manage the catering service only.<span style="color: red; font-weight: bold;"> *</span>'
184
+ )
185
+
177
186
mlh_required_privacy = forms .BooleanField (
178
187
label = "I authorize you to share my application/registration information with Major League Hacking for "
179
188
"event administration, ranking, and MLH administration in-line with the MLH "
@@ -224,6 +233,19 @@ def clean_mlh_optional_communications(self):
224
233
)
225
234
return cc
226
235
236
+
237
+ def clean_diet_notice (self ):
238
+ diet = self .cleaned_data .get ('diet' , 'None' )
239
+ diet_notice = self .cleaned_data .get ('diet_notice' , False )
240
+ # Check that if it's the first submission hackers checks terms and conditions checkbox
241
+ # self.instance.pk is None if there's no Application existing before
242
+ # https://stackoverflow.com/questions/9704067/test-if-django-modelform-has-instance
243
+ if diet != 'None' and not diet_notice and not self .instance .pk :
244
+ raise forms .ValidationError (
245
+ "In order to apply and attend you have to accept us to use your personal data related to your food "
246
+ "allergies and intolerances only in order to manage the catering service."
247
+ )
248
+ return diet_notice
227
249
def clean_other_diet (self ):
228
250
data = self .cleaned_data .get ('other_diet' , '' )
229
251
diet = self .cleaned_data .get ('diet' , 'None' )
0 commit comments