def get_form_helper(self): """ Defines and returns the ``django_crispy_forms`` layout. Override this if you want to alter the form-layout. """ formhelper = FormHelper() formhelper.form_action = self.request.get_full_path() formhelper.form_id = 'cradmin_authenticate_login_form' formhelper.label_class = 'sr-only' layoutargs = self.get_field_layout() + [ PrimarySubmitLg('login', gettext_lazy('Sign in')) ] formhelper.layout = layout.Layout(*layoutargs) return formhelper
def __init__(self, domain_object, *args, **kwargs): self.domain_object = domain_object super(DashboardFeedFilterForm, self).__init__(*args, **kwargs) self.fields['emwf_case_filter'].widget.set_url( reverse(CaseListFilter.options_url, args=(self.domain_object.name, ))) self.fields['emwf_form_filter'].widget.set_url( reverse(ExpandedMobileWorkerFilter.options_url, args=(self.domain_object.name, ))) self.helper = HQModalFormHelper() self.helper.form_tag = False self.helper.layout = crispy.Layout(*self.layout_fields)
def __init__(self, *args, **kwargs): super(DomainRegistrationForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = "form-horizontal" self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-6 col-md-5 col-lg-3' self.helper.layout = crispy.Layout( 'hr_name', 'org', hqcrispy.FormActions( twbscrispy.StrictButton( _("Create Project"), type="submit", css_class="btn btn-primary btn-lg disable-on-submit", )))
def __init__(self, *args, **kwargs): super(DomainRequestForm, self).__init__(*args, **kwargs) self.helper = cb3_helper.FormHelper() self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-6 col-md-5 col-lg-3' self.helper.show_form_errors = True self.helper.layout = cb3_layout.Layout( hqcrispy.Field('full_name'), hqcrispy.Field('email'), hqcrispy.Field('domain'), self.form_actions, )
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 = HQFormHelper() 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 __init__(self, *args, **kwargs): super(MarketLoginForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = layout.Layout( layout.Fieldset( '', 'login', 'password' ), bootstrap.FormActions( layout.Submit('submit', 'Log in', css_class='btn btn-success'), ), )
def __init__(self, *args, **kwargs): super(TobuyForm2, self).__init__(*args, **kwargs) self.helper = FormHelper() self.fields['tobuy_date'].widget = DateInput() self.helper.layout = layout.Layout( _('待買表單'), layout.Field('itemname'), layout.Field('budget'), layout.Field('tobuy_date'), bootstrap.InlineRadios('tobuy_type'), # layout.Fieldset( # ), layout.ButtonHolder( Submit('submit', '送出', css_class='button white')))
def __init__(self, domain, *args, **kwargs): super(SMSRateCalculatorForm, self).__init__(*args, **kwargs) backends = SMSBackend.view( "sms/backend_by_domain", startkey=[domain], endkey=[domain, {}], reduce=False, include_docs=True, ).all() backends.extend( SMSBackend.view( 'sms/global_backends', reduce=False, include_docs=True, ).all()) def _get_backend_info(backend): try: api_id = " (%s)" % get_backend_by_class_name( backend.doc_type).get_api_id() except AttributeError: api_id = "" return backend._id, "%s%s" % (backend.name, api_id) backends = [_get_backend_info(g) for g in backends] self.fields['gateway'].choices = backends self.helper = FormHelper() self.helper.form_class = "form-horizontal" self.helper.layout = crispy.Layout( crispy.Field( 'gateway', data_bind="value: gateway, events: {change: clearSelect2}", css_class="input-xxlarge", ), crispy.Field( 'direction', data_bind="value: direction, " "event: {change: clearSelect2}", ), crispy.Field( 'country_code', css_class="input-xxlarge", data_bind="value: select2CountryCode.value, " "event: {change: updateRate}", placeholder=_("Please Select a Country Code"), ), )
def __int__(self, *args, **kwargs): super(ProductForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = "" self.helper.form_method = "POST" self.helper.layout = layout.Layout( layout.Field('category_name'), layout.Field( "categories", template='utils/checkbox_select_multiple_tree.html' ), bootstrap.FormActions( layout.Submit('submit', _('Save')) ) )
def helper(self): helper = FormHelper() helper.layout = layout.Layout( layout.HTML(f'<h2>{self.header}</h2>'), layout.HTML(f'<div>{self.message}</div>'), ) for field in self.Meta().fields: helper.layout.append(layout.Field(field, wrapper_class='row')) helper.layout.append( layout.Submit('submit', 'Submit your session', css_class='btn-success col-12')) helper.label_class = 'col-3' helper.field_class = 'col-9' return helper
def __init__(self, *args, **kwargs): self.has_author = kwargs.pop('has_author') self.contribution = kwargs.pop('contribution') super().__init__(*args, **kwargs) self.helper = helper.FormHelper() self.helper.layout = layout.Layout( 'subject', layout.Field('text', rows=5, **{ 'data-component': 'keysubmit autosize' }), layout.Submit('create', 'Nachricht senden')) if self.has_author: del self.fields['author'] else: self.helper.layout.insert(0, 'author')
def __init__(self, *args, **kwargs): super(EmpresaActividadInfoForm, self).__init__(*args, **kwargs) # creamos helper self.helper = helper.FormHelper() self.helper.form_id = "myform" # creamos layouts personalizado self.helper.layout = layout.Layout( 'empresa_actividad', 'active', ) if kwargs['initial']['actividad_padre'] == 2: self.helper.layout = layout.Layout( 'empresa_actividad', 'tamano', 'tipo', 'comentario' 'active', ) elif kwargs['initial']['actividad_padre'] == 3: self.helper.layout = layout.Layout( 'empresa_actividad', 'nombre', 'referencia_gps', 'superficie', 'comentario' 'active', ) # agregamos los botones de acción bSave = '<button type="submit" class="btn btn-sm btn-primary btn-icon-split mr-1"><span class="icon text-white-50"><i class="fas fa-save"></i></span><span class="text">Grabar</span></button>' bCancel = '<a class="btn btn-sm btn-warning btn-icon-split" href="{{request.META.HTTP_REFERER}}"><span class="icon text-white-50"><i class="fas fa-undo"></i></span><span class="text text-dark">Cancela</span></a>' self.helper.layout.append(layout.HTML("<hr>")) self.helper.layout.append(layout.HTML(bSave)) self.helper.layout.append(layout.HTML(bCancel))
def __init__(self, data, *args, **kwargs): self.domain = kwargs.pop('domain') kwargs['initial'] = self.initial_data super(GaenOtpServerSettingsForm, self).__init__(data, *args, **kwargs) self.helper = hqcrispy.HQFormHelper() self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( hqcrispy.B3MultiField( _("OTP Callouts"), hqcrispy.InlineField('is_enabled'), ), crispy.Div(crispy.Field('server_url'), ), crispy.Div(crispy.Field('auth_token'), ), hqcrispy.FormActions( crispy.ButtonHolder(Submit('submit', _("Update")))))
def __init__(self, can_toggle_is_staff, *args, **kwargs): super(SuperuserManagementForm, self).__init__(*args, **kwargs) if can_toggle_is_staff: self.fields['privileges'].choices.append( ('is_staff', 'Mark as developer')) self.helper = FormHelper() self.helper.form_class = "form-horizontal" 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.layout = crispy.Layout( 'csv_email_list', 'privileges', FormActions( crispy.Submit('superuser_management', 'Update privileges')))
def __init__(self, **kwargs): super(forms.Form, self).__init__(**kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' self.helper.label_class = 'col-sm-3 col-md-4 col-lg-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' self.helper.layout = crispy.Layout( hqcrispy.FormActions( twbscrispy.StrictButton( _('Next'), css_class='btn-primary', type='submit', ) ) )
def __init__(self, *args, **kwargs): super(BulletinFilterForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = "" self.helper.form_method = "GET" self.helper.layout = layout.Layout( layout.Fieldset( _("Filter bulletins"), layout.Field("bulletin_type"), layout.Field("category"), ), bootstrap.FormActions(layout.Submit("submit", _("Filter")), ), )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = layout.Layout( layout.Fieldset( '', layout.Field('title', placeholder='A snappy title'), 'body', 'tags', bootstrap.PrependedAppendedText('price', '$', 'USD'), 'unit', 'location'), bootstrap.FormActions( layout.Submit('submit', 'Create post', css_class='btn btn-success'), )) self.helper.form_tag = False
def __init__(self, request, domain, *args, **kwargs): self.domain = domain super(DataManagementForm, self).__init__(*args, **kwargs) self.helper = HQFormHelper() self.helper.layout = crispy.Layout( crispy.Field('slug'), crispy.Field('db_alias'), crispy.Field('start_date', css_class="date-picker"), crispy.Field('end_date', css_class="date-picker"), hqcrispy.FormActions( crispy.ButtonHolder( Submit('submit', ugettext_lazy("Submit")) ) ) )
def __init__(self, *args, **kwargs): super(ConvertTranslationsForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.layout = crispy.Layout( crispy.Field( 'upload_file', data_bind="value: file", ), StrictButton( ugettext_lazy('Convert'), css_class='btn-primary', type='submit', ), )
def crispy_init(self): # pragma: no cover """Initialize crispy-forms helper.""" self.helper = FormHelper() self.helper.form_id = 'id-RegistrationForm' self.helper.form_class = 'form-group' self.helper.form_method = 'post' self.helper.form_action = reverse('blog_admin:register') self.helper.layout = layout.Layout( layout.Field('username'), layout.Field('email'), layout.Field('password1'), layout.Field('password2'), layout.Div(layout.Submit('submit', 'Register', css_class='btn-success my-2 px-4'), css_class='text-center'))
def __init__(self, *args, **kwargs): domain = kwargs.pop('domain') super(ComposeMessageForm, self).__init__(*args, **kwargs) self.helper = HQFormHelper() self.helper.form_action = reverse('send_to_recipients', args=[domain]) self.helper.layout = crispy.Layout( crispy.Field('recipients', rows=2, css_class='sms-typeahead'), crispy.Field('message', rows=2), hqcrispy.FormActions( twbscrispy.StrictButton( _("Send Message"), type="submit", css_class="btn-primary", ), ), )
def __init__(self, *args, **kwargs): # pragma: no cover """Initialize crispy forms.""" super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-LoginForm' self.helper.form_class = 'form-group' self.form_method = 'post' self.helper.form_action = reverse(settings.LOGIN_URL) self.helper.layout = layout.Layout( 'username', 'password', layout.Div(layout.Submit('login', 'Login', css_class='btn-success my-2 px-4'), css_class='text-center'), layout.Hidden('next', ''))
def __init__(self, *args, **kwargs): super(BulletinForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = "" self.helper.form_method = "POST" self.fields["bulletin_type"].widget = forms.RadioSelect() # delete empty choice for the type del self.fields["bulletin_type"].choices[0] self.helper.layout = layout.Layout( layout.Fieldset( _("Main data"), layout.Field("bulletin_type"), layout.Field("title", css_class="input-block-level"), layout.Field("description", css_class="input-blocklevel", rows=3), ), layout.Fieldset( _("Image"), layout.Field("image", css_class="input-block-level"), layout.HTML( u""" {% load i18n%} <p class="help-block"> {% trans "Available formats are JPG, GIF, PNG. Minimal size is 800 x 800 px." %} </p> """ ), title=_("Image upload"), css_id="image_fieldset", ), layout.Fieldset( _("Contact"), layout.Field("contact_person", css_class="input-blocklevel"), layout.Div( bootstrap.PrependedText("phone", """<span class="glyphicon glyphicon-earphone"></span>""", css_class="input-blocklevel"), bootstrap.PrependedText("email", "@", css_class="input-block-level", placeholder="*****@*****.**"), css_id="contact_info", ), ), bootstrap.FormActions( layout.Submit("submit", _("Save")) ) )
def __init__(self, data, *args, **kwargs): self.domain = kwargs.pop('domain') kwargs['initial'] = self.initial_data super(DialerSettingsForm, self).__init__(data, *args, **kwargs) self.helper = hqcrispy.HQFormHelper() self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( hqcrispy.B3MultiField( _("Telephony Services"), hqcrispy.InlineField('is_enabled'), ), crispy.Div(crispy.Field('aws_instance_id'), ), crispy.Div(crispy.Field('dialer_page_header'), ), crispy.Div(crispy.Field('dialer_page_subheader'), ), hqcrispy.FormActions( crispy.ButtonHolder(Submit('submit', _("Update")))))
def __init__(self, *args, **kwargs): super(ImportIndicatorsFromJsonFileForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-lg-2' self.helper.field_class = 'col-lg-8' self.helper.layout = crispy.Layout( crispy.Field('json_file'), crispy.Field('override_existing'), FormActions( twbs.StrictButton(_("Import Indicators"), type='submit', css_class='btn-primary'), ), )
def __init__(self, data, *args, **kwargs): self.domain = kwargs.pop('domain') kwargs['initial'] = self.initial_data super(HmacCalloutSettingsForm, self).__init__(data, *args, **kwargs) self.helper = hqcrispy.HQFormHelper() self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( hqcrispy.B3MultiField( _("Signed Callout Config"), hqcrispy.InlineField('is_enabled'), ), crispy.Div(crispy.Field('destination_url'), ), crispy.Div(crispy.Field('api_key'), ), crispy.Div(crispy.Field('api_secret'), ), hqcrispy.FormActions( crispy.ButtonHolder(Submit('submit', _("Update")))))
def _initialize_crispy_layout(self): self.helper = FormHelper(self) self.helper.form_class = 'form-horizontal' 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.offset_class = 'col-sm-offset-3 col-md-offset-2' self.helper.layout = crispy.Layout( crispy.Fieldset('Forwarding Settings', *self.get_ordered_crispy_form_fields()), hqcrispy.FormActions( twbscrispy.StrictButton( self.submit_btn_text, type="submit", css_class='btn-primary', )))
def get_form_helper(self): helper = FormHelper() helper.form_style = 'inline' helper.form_show_labels = False helper.layout = crispy.Layout( twbscrispy.InlineField('column'), twbscrispy.InlineField('data_element_id'), twbscrispy.InlineField('category_option_combo_id'), twbscrispy.InlineField('comment'), twbscrispy.StrictButton( mark_safe(f'<i class="fa fa-plus"></i> {_("Add")}'), # nosec: no user input css_class='btn-primary', type='submit', ) ) return helper
def __init__(self, *args, **kwargs): super(SearchForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_tag = False self.helper.method = "GET" self.helper.layout = layout.Layout( Div( Div('search', css_class="col-md-3"), Div('min_price', css_class="col-md-3"), Div('max_price', css_class="col-md-3"), Submit('submit', 'Search', css_class="btn-success align-self-center ml-5"), css_class="row", ))
def __init__(self, *args, **kwargs): super(SubscribeSMSForm, self).__init__(*args, **kwargs) self.helper = HQFormHelper() self.helper.layout = crispy.Layout( crispy.Fieldset( _('Subscribe settings'), twbscrispy.PrependedText('stock_out_facilities', ''), twbscrispy.PrependedText('stock_out_commodities', ''), twbscrispy.PrependedText('stock_out_rates', ''), twbscrispy.PrependedText('non_report', '')), hqcrispy.FormActions( twbscrispy.StrictButton( _("Update settings"), type="submit", css_class="btn-primary", ), ))