@@ -44,7 +44,6 @@ class HackerApplicationForm(_BaseApplicationForm):
44
44
45
45
online = common_online ()
46
46
47
-
48
47
def clean_resume (self ):
49
48
resume = self .cleaned_data ["resume" ]
50
49
size = getattr (resume , "_size" , 0 )
@@ -92,7 +91,6 @@ def clean_projects(self):
92
91
),
93
92
)
94
93
95
-
96
94
cvs_edition = forms .BooleanField (
97
95
required = False ,
98
96
label = 'I authorize "Hackers at UPC" to share my CV with HackUPC 2024 Sponsors.' ,
@@ -193,7 +191,6 @@ def get_bootstrap_field_info(self):
193
191
deadline = getattr (settings , "REIMBURSEMENT_DEADLINE" , False )
194
192
r_enabled = getattr (settings , "REIMBURSEMENT_ENABLED" , False )
195
193
personal_info_fields .append ({"name" : "origin" , "space" : 12 })
196
-
197
194
198
195
# Fields that we only need the first time the hacker fills the application
199
196
# https://stackoverflow.com/questions/9704067/test-if-django-modelform-has-instance
@@ -233,7 +230,24 @@ class Meta(_BaseApplicationForm.Meta):
233
230
"Plase type following this schema: <strong>city, province, country</strong>" ,
234
231
}
235
232
233
+ class CustomSelect (forms .Select ):
234
+ def create_option (
235
+ self , name , value , label , selected , index , subindex = None , attrs = None
236
+ ):
237
+ if index == 0 :
238
+ attrs = {"disabled" : "disabled" }
239
+ return super ().create_option (
240
+ name , value , label , selected , index , subindex = subindex , attrs = attrs
241
+ )
242
+
243
+ def clean_discover (self ):
244
+ discover = self .cleaned_data .get ("discover" )
245
+ if discover == "" :
246
+ raise forms .ValidationError ("Please select an option." )
247
+ return discover
248
+
236
249
discover_choices = (
250
+ ("" , "- Select an option -" ),
237
251
(1 , "HackUPC's social media" ),
238
252
(2 , "Through your university (social media, emails...)" ),
239
253
(3 , "Friends" ),
@@ -248,7 +262,7 @@ class Meta(_BaseApplicationForm.Meta):
248
262
"origin" : forms .TextInput (attrs = {"autocomplete" : "off" }),
249
263
"description" : forms .Textarea (attrs = {"rows" : 3 , "cols" : 40 }),
250
264
"projects" : forms .Textarea (attrs = {"rows" : 3 , "cols" : 40 }),
251
- "discover" : forms . Select (choices = discover_choices ),
265
+ "discover" : CustomSelect (choices = discover_choices ),
252
266
"graduation_year" : forms .RadioSelect (),
253
267
}
254
268
@@ -263,5 +277,5 @@ class Meta(_BaseApplicationForm.Meta):
263
277
"origin" : "Where are you joining us from?" ,
264
278
"description" : "Why are you excited about %s?" % settings .HACKATHON_NAME ,
265
279
"projects" : "What projects have you worked on?" ,
266
- "resume" : "Upload your resume"
280
+ "resume" : "Upload your resume" ,
267
281
}
0 commit comments