def __init__(self, *args, **kwargs): super(AddDeliveryService, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-4' self.helper.field_class = 'col-lg-7' self.helper.form_action = "" self.helper.form_method = "POST" self.helper.layout = layout.Layout( layout.Div( layout.HTML( u"""<div class="panel-heading"><h3 class="panel-title">Delivery Form for Service </h3></div>""" ), layout.Div( layout.Div( layout.Field('deliveryNotes'), css_class="col-md-10", ), layout.Div( bootstrap.FormActions( layout.Reset(('Reset'), _('Reset')), layout.Submit(('submit'), _('Save'), style='margin-left: 80px')), #layout.Submit(('submit'),_('Save'), css_class= "col-md-2 offset-md-3")), css_class="col-md-10"), css_class="row panel-body", ), css_class="panel panel-default"), )
def __init__(self, *args, **kwargs): super(TimeDelivery, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-4' self.helper.field_class = 'col-lg-7' self.helper.form_action = "" self.helper.form_method = "POST" self.helper.layout = layout.Layout( layout.Div(layout.HTML( u"""<div class="panel-heading"><h3 class="panel-title">Form for getting the delivery time for the requested services</h3></div>""" ), layout.Div( layout.Div( layout.Field('start_date'), css_class="col-md-10", ), layout.Div( layout.Field('end_date'), css_class="col-md-10", ), layout.Div(bootstrap.FormActions( layout.Reset(('Reset'), _('Reset')), layout.Submit(('submit'), _('Submit'), style='margin-left: 80px')), css_class="col-md-10"), css_class="row panel-body", ), css_class="panel panel-default"), )
def __init__(self, user_name: str = None, post: artisan_models.Post = None, *args, **kwargs) -> None: super().__init__(user_name=user_name, post=post, *args, **kwargs) checked_string = '' if post and user_name and post.subscribed_users.filter( username=user_name).count(): checked_string = 'checked' checkbox_string = '<input type="checkbox" id="subscribe_cb" name="subscribe" value="Subscribe" ' + \ checked_string + '> \ <label for="subscribe_cb" class="tinfo">Subscribe to this post...</label><br>' self.helper.layout = layout.Layout( layout.Fieldset( 'Create your post...', bootstrap5.FloatingField('title'), layout.Field('text', css_class="mb-3 post-create-form-text"), layout.HTML( "<div class='font-italic mb-3 tinfo'>Maximum of 2000 characters. Click on word count to see how many characters you have used...</div>" ), layout.Div(layout.Field('category', css_class="col-auto") if conf.settings.SHOW_CATEGORY else layout.Div(), layout.Field('location', css_class="col-auto") if conf.settings.SHOW_LOCATION else layout.Div(), css_class="col-8 col-sm-4 col-md-4 col-lg-3 tinfo"), layout.HTML(checkbox_string), layout.Submit('save', 'Publish Post', css_class="col-auto mt-3 mb-3"), )) self.helper.form_action = 'django_artisan:post_create_view'
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.form_method = 'get' self.form_id = 'frmComunicacion' # self.form_action = "{% url 'prueba:filter_modal' %}" # self.form_action = "/prueba/filter_modal" self.layout = layout.Layout( layout.Div( layout.Fieldset( None, layout.Div( bootstrap.InlineField("tipo", wrapper_class="col-4"), bootstrap.InlineField("texto", wrapper_class="col-5"), bootstrap.InlineField("active", wrapper_class="col-3"), css_class="row", ), css_class="col-10", ), bootstrap.FormActions( # layout.Submit("submit", "Buscar", css_id="btnBuscar"), layout.Button('btnFilter', 'Buscar', css_id='btnFilter', css_class='btn btn-sm btn-primary', onclick='submit_modal(frmComunicacion);'), css_class="col-2 text-right align-self-center", ), css_class="row", ))
class ComunicacionFilterFormHelper(helper.FormHelper): form_class = "form form-inline" form_id = "comunicacion-search-form" form_method = "GET" form_tag = True html5_required = True layout = layout.Layout( layout.Div( layout.Fieldset( "<span class='fa fa-search'></span> Búsqueda de Comunicaciones", layout.Div( bootstrap.InlineField("id", wrapper_class="col-4"), bootstrap.InlineField("tipo", wrapper_class="col-4"), bootstrap.InlineField("texto", wrapper_class="col-4"), bootstrap.InlineField("active", wrapper_class="col-4"), css_class="row", ), css_class="col-11 border p-3", ), bootstrap.FormActions( layout.Submit("submit", "Filtrar"), css_class="col-1 text-right align-self-center", ), css_class="row", ))
def special_crispy_fields(self): """ DRY mapping that can be used in generating self.get_ordered_crispy_form_fields """ return { "test_link": crispy.Div(crispy.Div( twbscrispy.StrictButton( _('Test Link'), type='button', css_id='test-forward-link', css_class='btn btn-default disabled', ), crispy.Div( css_id='test-forward-result', css_class='text-success hide', ), css_class='{} {}'.format(self.helper.field_class, self.helper.offset_class), ), css_class='form-group'), "auth_type": twbscrispy.PrependedText('auth_type', ''), "skip_cert_verify": twbscrispy.PrependedText('skip_cert_verify', ''), }
def layout_fields(self): return [ crispy.Div( crispy.Field('emwf_case_filter', ), data_bind="visible: showEmwfCaseFilter", ), crispy.Div( crispy.Field('emwf_form_filter', ), data_bind="visible: showEmwfFormFilter", ), crispy.Field( 'date_range', data_bind='value: dateRange', ), crispy.Div( crispy.Field("days", data_bind="value: days"), data_bind="visible: showDays", ), crispy.Div( crispy.Field( "start_date", data_bind="value: startDate", ), data_bind= "visible: showStartDate, css: {'has-error': startDateHasError}", ), crispy.Div( crispy.Field( "end_date", data_bind="value: endDate", ), data_bind= "visible: showEndDate, css: {'has-error': endDateHasError}", ) ]
def __init__(self, *args, **kwargs): super(AdvancedPrimeRestoreCacheForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-2' self.helper.field_class = 'col-lg-4' self.helper.form_method = 'post' self.helper.form_action = '.' self.helper.layout = crispy.Layout( crispy.Field('check_cache_only', data_ng_model='check_cache_only'), crispy.Div( 'version', 'cache_timeout', 'overwrite_cache', data_ng_hide='check_cache_only' ), crispy.Field('all_users', data_ng_model='all_users'), 'domain', crispy.Div('users', data_ng_hide='all_users'), hqcrispy.FormActions( StrictButton( "Submit", css_class="btn-primary", type="submit", ), ), )
def __init__(self, *args, **kwargs): super(ProfileCreationForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = "" self.helper.form_method = "POST" self.helper.form_tag = False self.helper.csrf = False self.fields['profilePosition'].required = True self.fields['profileCenter'].required = True self.fields['profileArea'].required = True self.helper.layout = layout.Layout( layout.Div( layout.HTML( u"""<div class="panel-heading"><h3 class="panel-title">User data</h3></div>""" ), layout.Div( layout.Div( layout.Field("profilePosition"), layout.Field("profileCenter"), css_class="col-md-6", ), layout.Div( layout.Field("profileArea"), layout.Field("profileExtension"), css_class="col-md-6", ), css_class='row panel-body', ), css_class='panel panel-default', ), )
def __init__(self, *args, **kwargs): super(UpdateNameForm, self).__init__(*args, **kwargs) self.helper = helper.FormHelper(self) self.helper.form_show_labels = False self.helper.form_tag = False self.helper.layout = layout.Layout( layout.Div( layout.Div( layout.Div( layout.HTML( fieldtostring(True, "required", "autofocus", type="text", name="first_name", value="", css_class="form-control")), layout.HTML(valuetolabel("first_name", "First Name")), css_class="md-form", ), ), layout.Div( layout.Div( layout.HTML( fieldtostring(True, "required", type="text", name="last_name", value="", css_class="form-control")), layout.HTML(valuetolabel("last_name", "Last Name")), css_class="md-form", ), ), ))
class DomicilioFilterFormHelper_OLD(helper.FormHelper): form_class = "form form-inline" form_id = "domicilio-search-form" form_method = "GET" form_tag = True html5_required = True layout = layout.Layout( layout.Div( layout.Fieldset( "<span class='fa fa-search'></span> Búsqueda de Domicilios", layout.Div( bootstrap.InlineField("id", wrapper_class="col-2"), bootstrap.InlineField("nombre", wrapper_class="col-8"), bootstrap.InlineField("active", wrapper_class="col-2"), css_class="row", ), css_class="col-11 border p-3", ), bootstrap.FormActions( layout.Submit("submit", "Filtrar"), css_class="col-1 text-right align-self-center", ), css_class="row", ) )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.form_method = 'get' self.form_id = 'frmDomicilio' self.layout = layout.Layout( layout.Div( layout.Fieldset( None, layout.Div( bootstrap.InlineField("nombre", wrapper_class="col-5"), bootstrap.InlineField("numero", wrapper_class="col-4"), bootstrap.InlineField("active", wrapper_class="col-3"), css_class="row", ), css_class="col-10", ), bootstrap.FormActions( # layout.Submit("submit", "Buscar", css_id="btnBuscar"), layout.Button('btnFilter', 'Buscar', css_id='btnFilter', css_class='btn btn-sm btn-primary', onclick='submit_modal(frmDomicilio);'), css_class="col-2 text-right align-self-center", ), css_class="row", ) )
def get_field_layout(self): return [ layout.Div('title', css_class="trix-focusfield"), # layout.Fieldset(_('Organize'), 'tags'), layout.Div('tags', css_class="trix-focusfield"), layout.Div('description', css_class="trix-focusfield"), ]
def section_internal(self): return crispy.Fieldset( _("Internal Settings (Dimagi Only)"), hqcrispy.B3MultiField( _("Override Daily Outbound SMS Limit"), crispy.Div(InlineField( 'override_daily_outbound_sms_limit', data_bind='value: override_daily_outbound_sms_limit', ), css_class='col-sm-4'), crispy.Div( InlineField('custom_daily_outbound_sms_limit'), data_bind= "visible: override_daily_outbound_sms_limit() === '%s'" % ENABLED, css_class='col-sm-8'), ), hqcrispy.B3MultiField( _("Chat Template"), crispy.Div(InlineField( "use_custom_chat_template", data_bind="value: use_custom_chat_template", ), css_class='col-sm-4'), crispy.Div(InlineField( "custom_chat_template", data_bind="visible: showCustomChatTemplate", ), css_class='col-sm-8'), help_bubble_text=_("To use a custom template to render the " "chat window, enter it here."), css_id="custom-chat-template-group", ), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.form_method = 'get' self.form_id = 'frmPersona' self.layout = layout.Layout( layout.Div( layout.Fieldset( None, layout.Div( bootstrap.InlineField("nombre", wrapper_class="col-3"), bootstrap.InlineField("apellido", wrapper_class="col-3"), bootstrap.InlineField("documento", wrapper_class="col-3"), bootstrap.InlineField("active", wrapper_class="col-3"), css_class="row", ), css_class="col-10", ), bootstrap.FormActions( layout.Button('btnFilter', 'Buscar', css_id='btnFilter', css_class='btn btn-sm btn-primary', onclick='submit_modal(frmPersona);'), css_class="col-2 text-right align-self-center", ), css_class="row", ))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.form_method = 'get' bFilter = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-filter"></i></span><span class="text">Filtrar</span></button>' bLimpiar = '<a class="btn btn-sm btn-secondary btn-icon-split" href="' + reverse('domicilio:list') + '"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text">Limpiar</span></a>' self.layout = layout.Layout( layout.Div( layout.Row( layout.Div( layout.Row( layout.Column('nombre', css_class='col-lg-10 col-md-10 col-sm-9 mb-0'), layout.Column('active', css_class='col-lg-2 col-md-2 col-sm-3 mb-0'), ), css_class="col-lg-12 col-md-12 col-sm-12", ), layout.Div( layout.HTML(bFilter), layout.HTML(bLimpiar), css_class="col-12 text-right", ), ) ) )
def __init__(self, *args, **kwargs): self.user = kwargs['existing_user'] api_key = kwargs.pop('api_key') if 'api_key' in kwargs else None super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs) self.username = self.user.username username_controls = [] if self.username: username_controls.append( hqcrispy.StaticField(ugettext_lazy('Username'), self.username)) api_key_controls = [ hqcrispy.StaticField(ugettext_lazy('API Key'), api_key), hqcrispy.FormActions(twbscrispy.StrictButton( ugettext_lazy('Generate API Key'), type="button", id='generate-api-key', css_class='btn-default', ), css_class="form-group"), ] self.fields['language'].label = ugettext_lazy("My Language") self.new_helper = cb3_helper.FormHelper() self.new_helper.form_method = 'POST' self.new_helper.form_class = 'form-horizontal' self.new_helper.attrs = { 'name': 'user_information', } self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2' self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6' basic_fields = [ cb3_layout.Div(*username_controls), hqcrispy.Field('first_name'), hqcrispy.Field('last_name'), hqcrispy.Field('email'), ] if self.set_analytics_enabled: basic_fields.append( twbscrispy.PrependedText('analytics_enabled', ''), ) if self.set_email_opt_out: basic_fields.append(twbscrispy.PrependedText('email_opt_out', '')) self.new_helper.layout = cb3_layout.Layout( cb3_layout.Fieldset(ugettext_lazy("Basic"), *basic_fields), (hqcrispy.FieldsetAccordionGroup if self.collapse_other_options else cb3_layout.Fieldset)( ugettext_lazy("Other Options"), hqcrispy.Field('language'), cb3_layout.Div(*api_key_controls), ), hqcrispy.FormActions( twbscrispy.StrictButton( ugettext_lazy("Update My Information"), type='submit', css_class='btn-primary', )))
def __init__(self, *args, event, submission, is_guest, **kwargs): super().__init__(*args, **kwargs) self.fields["submission"].initial = submission self.fields["event"].initial = event self.fields["is_guest"].initial = is_guest if event.payment_parameters.get("payment_modes"): self.fields[ "payment_mode"].payment_modes = event.payment_parameters[ "payment_modes"] # si l'événement est dans moins d'une semaine, on refuse le paiement par chèque if event.start_time - timezone.now() < timezone.timedelta(days=7): self.fields["payment_mode"].payment_modes = [ p for p in self.fields["payment_mode"].payment_modes if p.category != "check" ] for f in [ "first_name", "last_name", "location_address1", "location_zip", "location_city", "location_country", "contact_phone", ]: self.fields[f].required = True self.fields["location_address1"].label = "Adresse" self.fields["location_address2"].label = False fields = ["submission", "event", "is_guest"] fields.extend(["first_name", "last_name"]) fields.extend([ layout.Field("location_address1", placeholder="Ligne 1"), layout.Field("location_address2", placeholder="Ligne 2"), ]) fields.append( Row( layout.Div("location_zip", css_class="col-md-4"), layout.Div("location_city", css_class="col-md-8"), )) fields.append("location_country") fields.append("contact_phone") fields.append("payment_mode") self.helper = FormHelper() self.helper.add_input( layout.Submit( "valider", f"Je paie {floatformat(event.get_price(submission and submission.data)/100, 2)} €", )) self.helper.layout = layout.Layout(*fields)
def section_general(self): fields = [ hqcrispy.B3MultiField( _("Default SMS Response"), crispy.Div(InlineField( "use_default_sms_response", data_bind="value: use_default_sms_response", ), css_class='col-sm-4'), crispy.Div(InlineField( "default_sms_response", css_class="input-xxlarge", placeholder=_("Enter Default Response"), data_bind="visible: showDefaultSMSResponse", ), css_class='col-sm-8'), help_bubble_text=_( "Enable this option to provide a " "default response when a user's incoming SMS does not " "answer an open survey or match a known keyword."), css_id="default-sms-response-group", field_class='col-sm-6 col-md-9 col-lg-9'), hqcrispy.FieldWithHelpBubble( "use_restricted_sms_times", data_bind="value: use_restricted_sms_times", help_bubble_text=_( "Use this option to limit the times " "that SMS messages can be sent to users. Messages that " "are sent outside these windows will remained queued " "and will go out as soon as another window opens up."), ), hqcrispy.B3MultiField( "", hqcrispy.HiddenFieldWithErrors( "restricted_sms_times_json", data_bind="value: restricted_sms_times_json"), crispy.Div(data_bind="template: {" " name: 'ko-template-restricted-sms-times', " " data: $data" "}", ), data_bind="visible: showRestrictedSMSTimes", field_class='col-md-10 col-lg-10'), hqcrispy.FieldWithHelpBubble( "send_to_duplicated_case_numbers", help_bubble_text=_( "Enabling this option will send " "outgoing-only messages to phone numbers registered " "with more than one mobile worker or case. SMS surveys " "and keywords will still only work for unique phone " "numbers in your project."), ), hqcrispy.FieldWithHelpBubble( 'sms_survey_date_format', help_bubble_text=_("Choose the format in which date questions " "should be answered in SMS surveys."), ), ] return crispy.Fieldset(_("General Settings"), *fields)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["gender"].required = True self.fields["date_of_birth"].required = True self.fields["declaration"].label = _( "Je certifie sur l'honneur être une personne physique et que le réglement de mon prêt ne provient pas d'une" " personne morale mais de mon compte en banque personnel.") # retirer le help_text qui indique qu'un reçu fiscal sera émis (ce qui n'est pas le cas pour un prêt) self.fields["declaration"].help_text = None del self.fields["fiscal_resident"] if (Payment.objects.filter( Q(type=EuropeennesConfig.LOAN_PAYMENT_TYPE) & (Q(status=Payment.STATUS_COMPLETED) | Q(status=Payment.STATUS_WAITING, mode="check_afce")) ).aggregate(amount=Coalesce(Sum("price"), 0))["amount"] > settings.LOAN_MAXIMUM_TOTAL): self.fields["payment_mode"].payment_modes = [ PAYMENT_MODES["system_pay_afce_pret"] ] self.fields["payment_mode"].initial = PAYMENT_MODES[ "system_pay_afce_pret"].id self.fields["payment_mode"].widget = HiddenInput() fields = ["amount"] if "email" in self.fields: fields.append("email") fields.extend([ "first_name", "last_name", "gender", "nationality", layout.Field("location_address1", placeholder="Ligne 1"), layout.Field("location_address2", placeholder="Ligne 2"), layout.Row( layout.Div("location_zip", css_class="col-md-4"), layout.Div("location_city", css_class="col-md-8"), ), "location_country", "contact_phone", layout.Field("date_of_birth", placeholder="JJ/MM/AAAA"), "country_of_birth", "city_of_birth", "departement_of_birth", "iban", "payment_mode", "declaration", ]) if "subscribed" in self.fields: fields.append("subscribed") self.helper.layout = layout.Layout(*fields)
def __init__(self, *args, **kwargs): from corehq.apps.settings.views import ApiKeyView self.user = kwargs['existing_user'] super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs) self.username = self.user.username username_controls = [] if self.username: username_controls.append(hqcrispy.StaticField( ugettext_lazy('Username'), self.username) ) self.fields['language'].label = ugettext_lazy("My Language") self.new_helper = FormHelper() self.new_helper.form_method = 'POST' self.new_helper.form_class = 'form-horizontal' self.new_helper.attrs = { 'name': 'user_information', } self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2' self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6' basic_fields = [ crispy.Div(*username_controls), hqcrispy.Field('first_name'), hqcrispy.Field('last_name'), hqcrispy.Field('email'), ] if self.set_analytics_enabled: basic_fields.append(twbscrispy.PrependedText('analytics_enabled', ''),) self.new_helper.layout = crispy.Layout( crispy.Fieldset( ugettext_lazy("Basic"), *basic_fields ), (hqcrispy.FieldsetAccordionGroup if self.collapse_other_options else crispy.Fieldset)( ugettext_lazy("Other Options"), hqcrispy.Field('language'), crispy.Div(hqcrispy.StaticField( ugettext_lazy('API Key'), mark_safe( ugettext_lazy('API key management has moved <a href="{}">here</a>.') .format(reverse(ApiKeyView.urlname)) ), )), ), hqcrispy.FormActions( twbscrispy.StrictButton( ugettext_lazy("Update My Information"), type='submit', css_class='btn-primary', ) ) )
def __init__(self, domain, *args, **kwargs): super(CreateFormExportForm, self).__init__(*args, **kwargs) apps = get_apps_in_domain(domain) self.fields['application'].choices = ([ ('', _('Select Application...')), ] if len(apps) > 1 else []) + [(app._id, app.name) for app in apps] self.fields['module'].choices = [(module.unique_id, module.name) for app in apps if hasattr(app, 'modules') for module in app.modules] self.fields['form'].choices = [(form.get_unique_id(), form.name) for app in apps for form in app.get_forms()] self.helper = FormHelper() self.helper.form_id = "create-export-form" self.helper.form_class = "form-horizontal" self.helper.layout = crispy.Layout( crispy.Fieldset( _('Select Form'), crispy.Field( 'application', data_bind='value: appId', ), crispy.Div( crispy.Field( 'module', data_bind=("options: moduleOptions, " "optionsText: 'text', " "optionsValue: 'value', " "value: moduleId"), ), data_bind="visible: appId", ), crispy.Div( crispy.Field( 'form', data_bind=("options: formOptions, " "optionsText: 'text', " "optionsValue: 'value', " "value: formId"), ), data_bind="visible: moduleId", ), ), crispy.Div( FormActions( crispy.ButtonHolder( crispy.Submit( 'create_export', _('Next'), ), ), ), data_bind="visible: formId", ), )
def get_field_layout(self): """ Sets the layout using crispy forms """ return [ layout.Div('title', css_class="trix-focusfield"), layout.Div('tags', css_class="trix-focusfield"), layout.Div('hidden', css_class="trix-focusfield"), layout.Div('text', css_class="trix-focusfield"), layout.Div('solution', css_class="trix-focusfield"), ]
def __init__(self, *args, **kwargs): if 'domain' not in kwargs: raise Exception('Expected kwargs: domain') self.domain = kwargs.pop('domain') super(SendRegistrationInvitationsForm, self).__init__(*args, **kwargs) self.set_app_id_choices() self.helper = FormHelper() self.helper.form_class = "form-horizontal" self.helper.label_class = 'col-sm-4' self.helper.field_class = 'col-sm-8' self.helper.layout = crispy.Layout( crispy.Div( 'app_id', crispy.Field( 'phone_numbers', placeholder=_("Enter phone number(s) in international " "format. Example: +27..., +91...,"), ), 'phone_type', InlineField('action'), css_class='modal-body', ), hqcrispy.FieldsetAccordionGroup( _("Advanced"), crispy.Field( 'registration_message_type', data_bind='value: registration_message_type', ), crispy.Div( crispy.Field( 'custom_registration_message', placeholder=_("Enter registration SMS"), ), data_bind='visible: showCustomRegistrationMessage', ), 'make_email_required', active=False ), crispy.Div( twbscrispy.StrictButton( _("Cancel"), data_dismiss='modal', css_class="btn btn-default", ), twbscrispy.StrictButton( _("Send Invitation"), type="submit", css_class="btn btn-primary", ), css_class='modal-footer', ), )
def test_connection_button(self): return crispy.Div(crispy.Div( twbscrispy.StrictButton( _('Test Connection'), type='button', css_id='test-connection-button', css_class='btn btn-default disabled', ), css_class=hqcrispy.CSS_ACTION_CLASS, ), css_class='form-group')
def __init__(self, *args, **kwargs): domain = kwargs.pop('domain') app_id = kwargs.pop('app_id') request_user = kwargs.pop('request_user') super(PromptUpdateSettingsForm, self).__init__(*args, **kwargs) self.fields['apk_version'].choices = [(LATEST_APK_VALUE, 'Latest Released Build')] + [ (build.to_string(), 'CommCare {}'.format(build.get_label())) for build in get_commcare_builds(request_user) ] self.fields['app_version'].choices = [(LATEST_APP_VALUE, 'Latest Released Version')] + [ (app.version, 'Version {}'.format(app.version)) for app in get_all_built_app_ids_and_versions(domain, app_id)[-10:] ] self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.form_id = 'update-manager' self.helper.form_action = reverse( 'update_prompt_settings', args=[domain, app_id]) self.helper.label_class = 'col-sm-3 col-md-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.form_text_inline = True show_apk_version_select = kwargs.get('initial', {}).get('apk_prompt', 'off') != 'off' show_app_version_select = kwargs.get('initial', {}).get('app_prompt', 'off') != 'off' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Manage Update Settings"), crispy.Field( 'apk_prompt', # hide 'apk_version' depending on whether app_prompt is off or not onchange='$("#apk_version_id")[$("#id_apk_prompt").val() == "off"? "hide": "show"]()', ), crispy.Div( 'apk_version', # initial show/hide value style=('' if show_apk_version_select else "display: none;"), css_id="apk_version_id"), crispy.Field( 'app_prompt', # hide 'app_version' depending on whether app_prompt is off or not onchange='$("#app_version_id")[$("#id_app_prompt").val() == "off"? "hide": "show"]()', ), crispy.Div( 'app_version', # initial show/hide value style=('' if show_app_version_select else "display: none;"), css_id="app_version_id"), ) )
def __init__(self, *args, payment_modes=None, **kwargs): super().__init__(*args, **kwargs) if payment_modes is not None: self.payment_modes = payment_modes self.fields["payment_mode"].payment_modes = self.payment_modes self.fields["gender"].required = True self.fields["date_of_birth"].required = True self.fields["declaration"].label = _( "Je certifie sur l'honneur être une personne physique et que le réglement de mon prêt ne provient pas d'une" " personne morale mais de mon compte en banque personnel.") # retirer le help_text qui indique qu'un reçu fiscal sera émis (ce qui n'est pas le cas pour un prêt) self.fields["declaration"].help_text = None del self.fields["fiscal_resident"] fields = ["amount"] if "email" in self.fields: fields.append("email") fields.extend([ "first_name", "last_name", "gender", "nationality", layout.Field("location_address1", placeholder="Ligne 1"), layout.Field("location_address2", placeholder="Ligne 2"), layout.Row( layout.Div("location_zip", css_class="col-md-4"), layout.Div("location_city", css_class="col-md-8"), ), "location_country", "contact_phone", layout.Field("date_of_birth", placeholder="JJ/MM/AAAA"), "country_of_birth", "city_of_birth", "departement_of_birth", "iban", "payment_mode", "declaration", ]) if "subscribed_lfi" in self.fields: fields.append("subscribed_lfi") if len(self.fields["payment_mode"].payment_modes) <= 1: del self.fields["payment_mode"] fields.remove("payment_mode") self.helper.layout = layout.Layout(*fields)
def __init__(self, *args, **kwargs): self.username = kwargs.pop( 'username') if 'username' in kwargs else None self.user = kwargs.pop('user') if 'user' in kwargs else None api_key = kwargs.pop('api_key') if 'api_key' in kwargs else None super(UpdateMyAccountInfoForm, self).__init__(*args, **kwargs) username_controls = [] if self.username: username_controls.append( hqcrispy.StaticField(_('Username'), self.username)) api_key_controls = [ hqcrispy.StaticField(_('API Key'), api_key), hqcrispy.FormActions(twbscrispy.StrictButton( _('Generate API Key'), type="button", id='generate-api-key', ), css_class="form-group"), ] self.fields['language'].label = _("My Language") self.new_helper = cb3_helper.FormHelper() self.new_helper.form_method = 'POST' self.new_helper.form_class = 'form-horizontal' self.new_helper.attrs = { 'name': 'user_information', } self.new_helper.label_class = 'col-sm-3 col-md-2 col-lg-2' self.new_helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.new_helper.layout = cb3_layout.Layout( cb3_layout.Fieldset( _("Basic"), cb3_layout.Div(*username_controls), hqcrispy.Field('first_name'), hqcrispy.Field('last_name'), hqcrispy.Field('email'), hqcrispy.Field('email_opt_out'), ), cb3_layout.Fieldset( _("Other Options"), hqcrispy.Field('language'), cb3_layout.Div(*api_key_controls), ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Update My Information"), type='submit', css_class='btn-primary', )))
def get_field_layout(self): return [ layout.Div( layout.Field('comment_text', placeholder=ugettext_lazy('test placeholder')), layout.Div(layout.Div('new_deadline', 'selected_items', css_class='col-sm-6'), layout.HTML(self.__render_suggested_deadlines()), css_class='row'), css_class='cradmin-globalfields') ]
def __init__(self, *args, **kwargs): self.domain = kwargs.pop('domain') initial = kwargs.get('initial') readonly = False if initial: readonly = (initial.get('send_frequency') == 'immediately') message = initial.get('message', {}) kwargs['initial']['translate'] = '*' not in message kwargs['initial']['non_translated_message'] = message.get('*', '') for lang in self.project_languages: kwargs['initial']['message_%s' % lang] = message.get(lang, '') super(MessageForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' self.helper.label_class = 'col-sm-2 col-md-2 col-lg-2' self.helper.field_class = 'col-sm-10 col-md-3 col-lg-3' self.add_content_fields() if readonly: for field_name, field in self.fields.items(): field.disabled = True layout_fields = [ crispy.Field('schedule_name'), crispy.Field('send_frequency'), crispy.Field('recipients', data_bind='value: message_recipients.value', placeholder=_("Select some recipients")), crispy.Field('content'), crispy.Field('translate', data_bind='checked: translate'), crispy.Div( crispy.Field('non_translated_message'), data_bind='visible: !translate()', ), ] translated_fields = [ crispy.Field('message_%s' % lang) for lang in self.project_languages ] layout_fields.append( crispy.Div(*translated_fields, data_bind='visible: translate()')) if not readonly: layout_fields += [ hqcrispy.FormActions( twbscrispy.StrictButton( _("Save"), css_class='btn-primary', type='submit', ), ), ] self.helper.layout = crispy.Layout(*layout_fields)