@@ -214,15 +214,47 @@ def __init__(self, *args, **kwargs):
214214 self .fields .pop (field , None )
215215
216216
217+ class ContribAccessibilitePollingStationForm (ContribAccessibiliteForm ):
218+ fields_to_remove = (
219+ "entree_dispositif_appel" ,
220+ "entree_balise_sonore" ,
221+ "entree_aide_humaine" ,
222+ "accueil_cheminement_plain_pied" ,
223+ "accueil_retrecissement" ,
224+ "accueil_personnels" ,
225+ "accueil_audiodescription_presence" ,
226+ "accueil_equipements_malentendants_presence" ,
227+ "labels" ,
228+ "labels_familles_handicap" ,
229+ "labels_autre" ,
230+ )
231+ conditionals_to_add = get_conditional_fields_in ("polling_station" )
232+ conditionals_to_remove = get_conditional_fields_not_in ("polling_station" )
233+
234+ class Meta :
235+ model = Accessibilite
236+ exclude = ("pk" ,)
237+ widgets = get_widgets_for_accessibilite ()
238+ labels = schema .get_labels (include_conditional = ["polling_station" ])
239+ help_texts = schema .get_help_texts (include_conditional = ["polling_station" ])
240+ required = schema .get_required_fields ()
241+
242+ def __init__ (self , * args , ** kwargs ):
243+ super ().__init__ (* args , ** kwargs )
244+ for field in copy (self .fields ):
245+ if field not in schema .get_help_texts (include_conditional = "polling_station" ).keys ():
246+ self .fields .pop (field , None )
247+
248+
217249class AdminAccessibiliteForm (ContribAccessibiliteForm ):
218250 # Note: defining `labels` and `help_texts` in `Meta` doesn't work with custom
219251 # fields, hence why we set them up manually for each fields.
220252 class Meta :
221253 model = Accessibilite
222254 exclude = ["pk" ]
223255 widgets = get_widgets_for_accessibilite ()
224- labels = schema .get_labels (include_conditional = ["hosting" , "school" , "floor" ])
225- help_texts = schema .get_help_texts (include_conditional = ["hosting" , "school" , "floor" ])
256+ labels = schema .get_labels (include_conditional = ["hosting" , "school" , "floor" , "polling_station" ])
257+ help_texts = schema .get_help_texts (include_conditional = ["hosting" , "school" , "floor" , "polling_station" ])
226258 required = schema .get_required_fields ()
227259
228260 sanitaires_adaptes = forms .ChoiceField (
@@ -775,6 +807,7 @@ def get_contrib_forms_for_activity(activity: Activite):
775807 ACTIVITY_GROUPS ["HOSTING" ]: ContribAccessibiliteHotelsForm ,
776808 ACTIVITY_GROUPS ["SCHOOL" ]: ContribAccessibiliteSchoolsForm ,
777809 ACTIVITY_GROUPS ["FLOOR" ]: ContribAccessibiliteFloorsForm ,
810+ ACTIVITY_GROUPS ["POLLING_STATION" ]: ContribAccessibilitePollingStationForm ,
778811 }
779812
780813 groups = activity .groups .all ()
0 commit comments