@@ -101,7 +101,7 @@ def clean_projects(self):
101
101
102
102
cvs_edition = forms .BooleanField (
103
103
required = False ,
104
- label = 'I authorize "Hackers at UPC" to share my CV with HackUPC 2023 Sponsors.' ,
104
+ label = 'I authorize "Hackers at UPC" to share my CV with HackUPC 2024 Sponsors.' ,
105
105
)
106
106
107
107
def __init__ (
@@ -224,7 +224,24 @@ class Meta(_BaseApplicationForm.Meta):
224
224
"Please type following this schema: <strong>city, province, country</strong>" ,
225
225
}
226
226
227
+ class CustomSelect (forms .Select ):
228
+ def create_option (
229
+ self , name , value , label , selected , index , subindex = None , attrs = None
230
+ ):
231
+ if index == 0 :
232
+ attrs = {"disabled" : "disabled" }
233
+ return super ().create_option (
234
+ name , value , label , selected , index , subindex = subindex , attrs = attrs
235
+ )
236
+
237
+ def clean_discover (self ):
238
+ discover = self .cleaned_data .get ("discover" )
239
+ if discover == "" :
240
+ raise forms .ValidationError ("Please select an option." )
241
+ return discover
242
+
227
243
discover_choices = (
244
+ ("" , "- Select an option -" ),
228
245
(1 , "HackUPC's social media" ),
229
246
(2 , "Through your university (social media, emails...)" ),
230
247
(3 , "Friends" ),
@@ -239,7 +256,7 @@ class Meta(_BaseApplicationForm.Meta):
239
256
"origin" : forms .TextInput (attrs = {"autocomplete" : "off" }),
240
257
"description" : forms .Textarea (attrs = {"rows" : 3 , "cols" : 40 }),
241
258
"projects" : forms .Textarea (attrs = {"rows" : 3 , "cols" : 40 }),
242
- "discover" : forms . Select (choices = discover_choices ),
259
+ "discover" : CustomSelect (choices = discover_choices ),
243
260
"graduation_year" : forms .RadioSelect (),
244
261
}
245
262
0 commit comments