def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = "POST" self.helper.add_input(Submit("submit", _("M'enregistrer comme volontaire"))) self.helper.layout = Layout( Row( FullCol( Fieldset( "Vie du mouvement", Row(HalfCol("draw_participation"), HalfCol("gender")), ) ), HalfCol( Fieldset( "Agir près de chez vous", *(tag for tag, title, desc in action_tags["nearby"]) ) ), HalfCol( Fieldset( "Agir sur internet", *(tag for tag, title, desc in action_tags["internet"]) ) ), ) )
def __init__(self, data=None, *args, **kwargs): super().__init__(data=data, *args, **kwargs) if ( not self.is_bound and self.instance.contact_phone and not ( is_french_number(self.instance.contact_phone) and is_mobile_number(self.instance.contact_phone) ) ): self.initial["contact_phone"] = "" self.fields["contact_phone"].help_text = _( "Seul un numéro de téléphone mobile français (outremer inclus) peut être utilisé pour la validation." ) self.fields["contact_phone"].required = True self.fields["contact_phone"].error_messages["required"] = _( "Vous devez indiquer le numéro de mobile qui vous servira à valider votre compte." ) fields = [ Row( HalfCol( FieldWithButtons( "contact_phone", Submit("submit", "Recevoir mon code") ) ) ) ] self.helper = FormHelper() self.helper.form_method = "POST" self.helper.layout = Layout(*fields)
def __init__(self, *args, person, **kwargs): super().__init__(*args, **kwargs) self.person = person phone_input = Field("code") submit_button = Submit("submit", "Valider mon numéro") fields = [Row(HalfCol(phone_input, submit_button))] self.helper = FormHelper() self.helper.form_method = "POST" self.helper.layout = Layout(*fields)
def __init__(self, *args, person, **kwargs): super().__init__(*args, **kwargs) self.person = person fields = [ Row( HalfCol( FieldWithButtons("code", Submit("submit", "Valider mon numéro")))) ] self.helper = FormHelper() self.helper.form_method = "POST" self.helper.layout = Layout(*fields)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = "POST" self.helper.add_input(Submit("submit", "Enregistrer mes informations")) self.fields["location_address1"].label = _("Adresse") self.fields["location_address2"].label = False self.fields["location_country"].required = True description_gender = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text="Pour nous adresser à vous correctement, et pour mesurer la parité.", ) ) description_address = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text="Permet de vous informer d'événements se déroulant près de chez vous.", ) ) description_birth_date = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text="Utilisée à des fins statistiques.", ) ) description = HTML( """<p>Ces informations nous permettront de nous adresser à vous plus correctement et en fonction de votre situation géographique.</p>""" ) self.helper.layout = Layout( Row( FullCol(description), HalfCol( Row(HalfCol("first_name"), HalfCol("last_name")), Row( HalfCol("gender"), HalfCol(Field("date_of_birth", placeholder=_("JJ/MM/AAAA"))), ), Row(HalfCol(description_gender), HalfCol(description_birth_date)), ), HalfCol( Row( FullCol( Field("location_address1", placeholder=_("1ère ligne")) ), FullCol( Field("location_address2", placeholder=_("2ème ligne")) ), HalfCol("location_zip"), HalfCol("location_city"), ), Row(FullCol("location_country")), Row(FullCol(description_address)), ), ) )
def get_fields(self, fields=None): fields = fields or [] block_template = """ <label class="control-label">{label}</label> <div class="controls"> <div>{value}</div> <p class="help-block">{help_text}</p> </div> """ validation_link = format_html( '<a href="{url}" class="btn btn-default btn-block">{label}</a>', url=reverse("send_validation_sms"), label=_("Valider mon numéro de téléphone"), ) unverified = ( self.instance.contact_phone_status == Person.CONTACT_PHONE_UNVERIFIED ) validation_block = HTML( format_html( block_template, label=_("Vérification de votre numéro de téléphone"), value=validation_link if unverified else f"Compte {self.instance.get_contact_phone_status_display().lower()}", help_text=_( "Faites vérifiez votre numéro de téléphone (cette certification " "facultative n'est possible que pour les numéros français)." ) if unverified else "", ) ) btn_no_mails = ( Submit( "no_mail", "Ne plus recevoir d'emails ou de SMS", css_class="btn-danger btn-block marginbottom", ) if self.instance.is_insoumise else Div() ) btn_submit = Submit( "submit", "Sauvegarder", css_class="btn-danger btn-block marginbottom", ) newsletter_fieldset = [] if self.instance.is_insoumise: newsletter_fieldset.append("subscribed_lfi") if self.instance.is_2022: newsletter_fieldset.append( HTML( format_html( '<a href="{url}" class="btn btn-primary">{label}</a>', url=f"https://noussommespour.fr/preferences/?_{urlencode(generate_token_params(self.instance))}", label="Paramétrer les emails de « Nous Sommes Pour ! »", ) ) ) if len(newsletter_fieldset) > 0: fields.append(Fieldset("Lettres d'informations", *newsletter_fieldset)) fields.extend( [ Fieldset( "Notifications", "group_notifications", "event_notifications", ), Fieldset( "Téléphone", Row(ThirdCol("contact_phone"), HalfCol(validation_block)), "subscribed_sms", ), Row( ThirdCol(btn_submit), HalfCol(btn_no_mails, css_class="col-md-offset-2"), css_class="padtop", ), ] ) return fields
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = "POST" self.helper.add_input(Submit("submit", "Enregistrer mes informations")) self.fields["location_address1"].label = _("Adresse") self.fields["location_address2"].label = False self.fields["location_country"].required = True self.fields["display_name"].required = True description_gender = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text= "Pour nous adresser à vous correctement, et pour mesurer la parité.", )) description_address = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text= "Permet de vous informer d'événements se déroulant près de chez vous.", )) description_birth_date = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text="Utilisée à des fins statistiques.", )) description = HTML( """<p class="marginbottommore">Ces informations nous permettront de nous adresser à vous plus correctement et en fonction de votre situation géographique.</p>""") description_display_name = HTML( format_html( """<p class="help-block">{help_text}</p>""", help_text= "Votre nom tel que les autres personnes le verront sur Action Populaire. Vous pouvez indiquer, par exemple, votre prénom ou un pseudonyme.", )) self.helper.layout = Layout( Row( FullCol(description), HalfCol( Row( HalfCol("first_name"), HalfCol("last_name"), ), Row( FullCol( Field("display_name"), description_display_name, css_class="field-with-help", )), Row( FullCol("gender", description_gender, css_class="field-with-help")), Row( FullCol( Field("date_of_birth", placeholder=_("JJ/MM/AAAA")), description_birth_date, css_class="field-with-help", )), Row( FullCol( Field("location_address1", placeholder=_("1ère ligne"))), FullCol( Field("location_address2", placeholder=_("2ème ligne"))), HalfCol("location_zip"), HalfCol("location_city"), FullCol( "location_country", description_address, css_class="field-with-help", ), ), ), HalfCol( Row(FullCol("image")), Row(FullCol("image_accept_license")), ), ))