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', ''), ) 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, request, *args, **kwargs): self.request = request super().__init__(*args, **kwargs) self.fields['categories'].widget = forms.CheckboxSelectMultiple() title_field = layout.Field("title", css_class="input-block-level") content_field = layout.Field("content", css_class="input-block-level", rows="3") main_fieldset = layout.Fieldset(_("Main data"), title_field, content_field) picture_field = layout.Field("picture", css_class="input-block-level") format_html = layout.HTML( """{% include "ideas/includes/picture_guidelines.html" %}""") picture_fieldset = layout.Fieldset(_("Picture"), picture_field, format_html, title=_("Image upload"), css_id="picture_fieldset") categories_field = layout.Field("categories", css_class="input-block-level") categories_fieldset = layout.Fieldset(_("Categories"), categories_field, css_id="categories_fieldset") inline_translations = layout.HTML( """{% include "ideas/forms/translations.html" %}""") submit_button = layout.Submit("save", _("Save")) actions = bootstrap.FormActions(submit_button) self.helper = helper.FormHelper() self.helper.form_action = self.request.path self.helper.form_method = "POST" self.helper.layout = layout.Layout( main_fieldset, inline_translations, picture_fieldset, categories_fieldset, actions, )
def __init__(self, *args, **kwargs): super(ExampleUserLoginForm, self).__init__(*args, **kwargs) # Here's what makes the form a Crispy Form: self.helper = FormHelper() # This is necessary to make the form a horizontal form self.helper.form_class = 'form-horizontal' # What do all these col-sm-3, col-md-2, col-lg-6 things mean? They # specify the column sizes for the label and field columns depending # on what the screen size is. This is called Responsive Design, and # you should visit # [Bootstrap 3's Responsive Docs](http://getbootstrap.com/css/#responsive-utilities) # for more information. self.helper.label_class = 'col-sm-3 col-md-2 col-lg-2' self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6' # This is the layout of the form where we can explicitly specify the # order of fields and group fields into fieldsets. self.helper.layout = crispy.Layout( crispy.Fieldset( # This is the title for the group of fields that follows: _("Basic Information"), 'full_name', # crispy.Field is used as the default display component crispy.Field( 'email'), # effectively the same as the line above 'password', 'password_repeat', ), crispy.Fieldset( _("Advanced Information"), 'is_staff', twbscrispy.PrependedText('phone_number', '+', placeholder='15555555555'), ), hqcrispy.FormActions( twbscrispy.StrictButton(_("Create User"), type='submit', css_class='btn-primary'), twbscrispy.StrictButton(_("Cancel"), css_class='btn-default'), ), )
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-block-level", 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, and PNG. Minimal size is 800 × 800 px." %}</p> """), title=_("Image upload"), css_id="image_fieldset", ), layout.Fieldset( _("Contact"), layout.Field("contact_person", css_class="input-block-level"), layout.Div( bootstrap.PrependedText( "phone", """<span class="glyphicon glyphicon-earphone"></span>""", css_class="input-block-level"), bootstrap.PrependedText("email", "@", css_class="input-block-level", placeholder="*****@*****.**"), css_id="contact_info", ), ), bootstrap.FormActions(layout.Submit("submit", _("Save")), ))
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 __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 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", ), 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 gateway_specific_fields(self): return crispy.Fieldset( _("Airtel (through TCL) Settings"), 'host_and_port', 'user_name', 'password', 'sender_id', 'circle_name', 'campaign_name', )
def __init__(self, *args, **kwargs): super(SocialProfileUpdateForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout = layout.Layout( layout.Fieldset('', 'avatar', 'tagline', 'bio', 'location'), bootstrap.FormActions( layout.Submit('submit', 'Update profile', css_class='btn btn-success'), ))
def __init__(self, *args, **kwargs): super().__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 gateway_specific_fields(self): return crispy.Fieldset( _("HTTP Settings"), 'url', 'method', 'message_param', 'number_param', 'include_plus', 'additional_params', )
def __init__(self, *args, **kwargs): super(CrispyTaskForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = "" 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 = layout.Layout( layout.Div(layout.Fieldset(_("Main data"), layout.Field('title', wrapper_class='col-md-6'), layout.Field('type', wrapper_class='col-md-6'), layout.Field('status', wrapper_class='col-md-9'), layout.Field('background', wrapper_class='col-md-3'), #css_class='form-row' ),), layout.Fieldset(_("Main data"), layout.Field("location", css_class="input-block-level"), layout.Field("description", css_class="input-blocklevel", rows="3"), layout.Field("private"), layout.Field("classification"),), layout.Fieldset(_("Authorisation"), layout.Field("authorisation"), layout.Field("assigned_to"), layout.Field("manager"),), layout.Fieldset(_("Main data"), bootstrap.Accordion( bootstrap.AccordionGroup('First Group', layout.Field('brief', wrapper_class='card')), ),), layout.Fieldset(_("Main data"), bootstrap.TabHolder( bootstrap.Tab('First Tab', layout.Field('location', wrapper_class='col-md-6')), bootstrap.Tab('Second Tab',layout.Field('description', wrapper_class='col-md-6')), ),), bootstrap.FormActions(layout.Submit("submit", _("Save")),),)
def __init__(self, account, domain, creating_user, data=None, *args, **kwargs): super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs) from corehq.apps.users.views.mobile import MobileWorkerListView 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( crispy.Fieldset( _("Basic Information"), 'company_name', 'first_name', 'last_name', crispy.Field('email_list', css_class='input-xxlarge accounting-email-select2', data_initial=json.dumps(self.initial.get('email_list'))), 'phone_number', ), crispy.Fieldset( _("Mailing Address"), 'first_line', 'second_line', 'city', 'state_province_region', 'postal_code', crispy.Field('country', css_class="input-large accounting-country-select2", data_country_code=self.current_country or '', data_country_name=COUNTRIES.get(self.current_country, '')), ), hqcrispy.FormActions( crispy.HTML( '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % { 'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]), 'text': _("Back to Mobile Workers List") } ), StrictButton( _("Confirm Billing Information"), type="submit", css_class='btn btn-primary disabled', ), ), )
def __init__(self, *args, **kwargs): super(DriverJobRequestForm, self).__init__(*args, **kwargs) self.adjust_vehicle_type_widget() self.helper.layout[2].insert(1, 'phone_requirement') self.helper.layout.insert( 3, layout.Fieldset( '', layout.Div('vehicle_type', css_class="radios-wrapper"), 'own_vehicle', 'minimum_delivery_box', ))
def _get_ajax_layout(self, include_bike_field=True): form_layout = layout.Layout( layout.Fieldset( None, "bike", "lost", "details", "position", )) if not include_bike_field: form_layout[0].pop(0) return form_layout
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 section_registration(self): fields = [ hqcrispy.FieldWithHelpBubble( "sms_case_registration_enabled", help_bubble_text=_( "When this option is enabled, a person " "can send an SMS into the system saying 'join " "[project]', where [project] is your project " "space name, and the system will automatically " "create a case tied to that person's phone number."), data_bind="value: sms_case_registration_enabled", ), crispy.Div( hqcrispy.FieldWithHelpBubble( "sms_case_registration_type", placeholder=_("Enter a Case Type"), help_bubble_text=_("Cases that self-register over SMS " "will be given this case type."), ), hqcrispy.FieldWithHelpBubble( "sms_case_registration_owner_id", help_bubble_text=_( "Cases that self-register over SMS " "will be owned by this user or user group."), ), hqcrispy.FieldWithHelpBubble( "sms_case_registration_user_id", help_bubble_text=_( "The form submission for a " "self-registration will belong to this user."), ), data_bind="visible: showRegistrationOptions", ), hqcrispy.FieldWithHelpBubble( "sms_mobile_worker_registration_enabled", help_bubble_text=_( "When this option is enabled, a person " "can send an SMS into the system saying 'join " "[project] worker [username]' (where [project] is your " " project space and [username] is an optional username)" ", and the system will add them as a mobile worker."), ), hqcrispy.FieldWithHelpBubble( 'registration_welcome_message', help_bubble_text=_( "Choose whether to send an automatic " "welcome message to cases, mobile workers, or both, " "after they self-register. The welcome message can be " "configured in the SMS languages and translations page " "(Messaging -> Languages -> Messaging Translations)."), ), ] return crispy.Fieldset(_("Registration Settings"), *fields)
def __init__(self, request, *args, **kwargs): self.request = request super().__init__(*args, **kwargs) title_field = layout.Field("title") content_field = layout.Field("content", rows="3") main_fieldset = layout.Fieldset(_("Main data"), title_field, content_field) picture_field = layout.Field("picture") format_html = layout.HTML( """{% include "ideas1/includes/picture_guidelines.html" %}""") picture_fieldset = layout.Fieldset( _("Picture"), picture_field, format_html, title=_("Image upload"), css_id="picture_fieldset", ) categories_field = layout.Field( "categories", template="core/includes/checkboxselectmultiple_tree.html") categories_fieldset = layout.Fieldset(_("Categories"), categories_field, css_id="categories_fieldset") submit_button = layout.Submit("save", _("Save")) actions = bootstrap.FormActions(submit_button, css_class="my-4") self.helper = helper.FormHelper() self.helper.form_action = self.request.path self.helper.form_method = "POST" self.helper.layout = layout.Layout( main_fieldset, picture_fieldset, categories_fieldset, actions, )
def __init__(self, *args, **kwargs): user = kwargs.pop("user") bike = kwargs.pop("bike", None) is_ajax = kwargs.pop("is_ajax", None) action = kwargs.pop("action", None) submit_value = _( "Report lost bike") if not bike else _("Update bike status") super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = "statusForm" if action is not None: self.helper.form_action = action if is_ajax: form_layout = layout.Layout( layout.Fieldset( None, "bike", "lost", "details", "position", ) ) else: form_layout = layout.Layout( layout.Div( layout.Div( layout.Field("bike"), layout.Field("lost"), layout.Field("details"), css_class="col-lg-3" ), layout.Div( layout.Field("position"), css_class="col-lg-9", ), css_class="row" ), bootstrap.FormActions( layout.Submit("submit", submit_value) ), ) self.helper.layout = form_layout if bike is None: # TODO: show only bikes that are not currently lost self.fields["bike"].queryset = models.Bike.objects.filter( owner=user) self.instance.lost = True del self.fields["lost"] else: current_status = bike.get_current_status() self.fields["lost"].initial = current_status.lost self.instance.bike = bike del self.fields["bike"]
def __init__(self, *args, **kwargs): super(ArticleCreateForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_action = reverse("inventex:article-create") self.helper.form_method = "POST" self.helper.add_input(Submit('Submit', 'submit')) prod_client_layout = layout.Layout( layout.Fieldset( "Produit et type de client", layout.Field('type_client'), layout.Field('type_de_produit'), )) self.helper.layout = prod_client_layout
def __init__(self, *args, **kwargs): super(EmailListForm, self).__init__(*args, **kwargs) self.helper = helper.FormHelper(self) self.helper.form_action = "" self.helper.layout = layout.Layout( layout.Fieldset( _('Enter list of e-mails for new users'), 'email_list' ), layout.Div( layout.Submit('submit', _('Submit'), css_class='btn btn-primary') ) )
def __init__(self, *args, **kwargs): super(MigrationForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.label_class = 'col-sm-2' self.helper.field_class = 'col-sm-10' self.helper.layout = crispy.Layout( crispy.Fieldset( _("Case Migration"), 'case_type', 'migration_xml', ), hqcrispy.FormActions( crispy.ButtonHolder(crispy.Submit('submit', _("Submit")))))
def get_field_layout(self): return [ layout.Div('title', css_class="cradmin-focusfield cradmin-focusfield-lg"), layout.Fieldset( 'Image', 'image', ), layout.Div('intro', css_class="cradmin-focusfield"), layout.Div('body', css_class="cradmin-focusfield"), layout.Fieldset( 'Advanced', 'publishing_time', 'unpublish_time', 'attachment', 'internal_notes' ), # layout.Div( # 'publishing_time', # 'internal_notes', # css_class='cradmin-globalfields' # ), ]
def gateway_specific_fields(self): domain_backends = SQLMobileBackend.get_domain_backends( SQLMobileBackend.SMS, self.domain, ) backend_choices = [('', _("No Fallback Backend"))] backend_choices.extend([(backend.couch_id, backend.name) for backend in domain_backends if backend.id != self.backend_id]) self.fields['fallback_backend_id'].choices = backend_choices return crispy.Fieldset(_("Infobip Settings"), 'account_sid', 'auth_token', 'personalized_subdomain', 'scenario_key', 'fallback_backend_id')
def __init__(self, *args, **kwargs): from corehq.apps.locations.forms import LocationSelectWidget from corehq.apps.users.views import get_editable_role_choices self.domain = kwargs.pop('domain') self.couch_user = kwargs.pop('couch_user') super(CommCareUserFilterForm, self).__init__(*args, **kwargs) self.fields['location_id'].widget = LocationSelectWidget(self.domain) self.fields['location_id'].help_text = ExpandedMobileWorkerFilter.location_search_help if is_icds_cas_project(self.domain) and not self.couch_user.is_domain_admin(self.domain): roles = get_editable_role_choices(self.domain, self.couch_user, allow_admin_role=True, use_qualified_id=False) self.fields['role_id'].choices = roles else: roles = UserRole.by_domain(self.domain) self.fields['role_id'].choices = [('', _('All Roles'))] + [ (role._id, role.name or _('(No Name)')) for role in roles] self.fields['domains'].choices = [(self.domain, self.domain)] if len(DomainPermissionsMirror.mirror_domains(self.domain)) > 0: self.fields['domains'].choices = [('all_project_spaces', _('All Project Spaces'))] + \ [(self.domain, self.domain)] + \ [(domain, domain) for domain in DomainPermissionsMirror.mirror_domains(self.domain)] self.helper = FormHelper() self.helper.form_method = 'GET' self.helper.form_id = 'user-filters' self.helper.form_class = 'form-horizontal' self.helper.form_action = reverse('download_commcare_users', args=[self.domain]) 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 self.helper.layout = crispy.Layout( crispy.Fieldset( _("Filter and Download Users"), crispy.Field('role_id', css_class="hqwebapp-select2"), crispy.Field('search_string'), crispy.Field('location_id'), crispy.Field('columns'), crispy.Field('domains'), ), hqcrispy.FormActions( twbscrispy.StrictButton( _("Download All Users"), type="submit", css_class="btn btn-primary submit_button", ) ), )
class ProposalFormHelper(helper.FormHelper): """Defines layout for the Proposal form. Fields here must be the same as in `EditProposalForm`. """ form_id = 'edit-proposal-form' layout = layout.Layout( layout.Fieldset( "Informacje podstawowe", FormRow( Column('name', css_class='col-md-8'), Column('language', css_class='col-md-4'), ), FormRow( Column('semester', css_class='col-md-4'), Column('course_type', css_class='col-md-4'), Column( CustomCheckbox('has_exam'), CustomCheckbox('recommended_for_first_year'), css_class='col-md-4 px-4'), css_class='align-items-end', ), Markdown('description'), FormRow( Column('hours_lecture', css_class='col-md-2'), Column('hours_exercise', css_class='col-md-2'), Column('hours_lab', css_class='col-md-2'), Column('hours_exercise_lab', css_class='col-md-2'), Column('hours_seminar', css_class='col-md-2'), Column('hours_recap', css_class='col-md-2'), css_class='align-items-end', ), FormRow( Column('points'), Column('status'), )), CollapsableFieldset( "Informacje szczegółowe", 'name_en', Markdown('teaching_methods'), Markdown('preconditions'), Markdown('objectives'), Markdown('contents'), Markdown('teaching_effects'), Markdown('literature'), Markdown('verification_methods'), Markdown('passing_means'), Markdown('student_labour'), css_id='syllabus-fields', ), layout.Submit('submit', "Zapisz"), )
def section_general(self): fields = [ BootstrapMultiField( _("Default SMS Response"), InlineField( "use_default_sms_response", data_bind="value: use_default_sms_response", ), InlineField( "default_sms_response", css_class="input-xxlarge", placeholder=_("Enter Default Response"), data_bind="visible: showDefaultSMSResponse", ), 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", ), 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."), ), BootstrapMultiField( "", 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", ), 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."), ), ] return crispy.Fieldset(_("General Settings"), *fields)
def __init__(self, *args, **kwargs): button_text = kwargs.pop('button_text', _("Create SMS Gateway")) self._cchq_domain = kwargs.pop('domain') self._cchq_backend_id = kwargs.pop('backend_id') super(BackendForm, self).__init__(*args, **kwargs) self.helper = HQFormHelper() self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( crispy.Fieldset( _('General Settings'), *self.general_fields ), self.gateway_specific_fields, crispy.Fieldset( _("Phone Numbers"), crispy.Div( data_bind="template: {" " name: 'ko-load-balancing-template', " " data: $data" "}", ), data_bind="visible: use_load_balancing", ), hqcrispy.FormActions( StrictButton( button_text, type="submit", css_class='btn-primary' ), ), ) if self._cchq_backend_id: # When editing, don't allow changing the name because name might be # referenced as a contact-level backend preference. # By setting disabled to True, Django makes sure the value won't change # even if something else gets posted. self.fields['name'].disabled = True
def __init__(self, domain, *args, **kwargs): super(HostedCCZLinkForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) save_button_text = _('Update') if self.instance.pk else _('Create') self.helper.layout.append(Submit('save', save_button_text)) if self.instance.pk: del self.fields['password'] else: self.fields['password'].widget = forms.PasswordInput() if self.instance.pk: self.helper.layout.append(Submit('delete', _('Delete'))) self.helper.layout = crispy.Fieldset(_("CCZ Hosting Link"), self.helper.layout) self.fields['identifier'].widget.attrs.update({'class': 'text-lowercase'}) self.instance.domain = domain
def __init__(self, *args, **kwargs): button_text = kwargs.pop('button_text', _("Create SMS Connection")) super(BackendForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form form-horizontal' self.helper.form_method = 'POST' self.helper.layout = crispy.Layout( crispy.Fieldset( _('General Settings'), crispy.Field('name', css_class='input-xxlarge'), crispy.Field('description', css_class='input-xxlarge', rows="3"), crispy.Field('reply_to_phone_number', css_class='input-xxlarge'), crispy.Field('give_other_domains_access', data_bind="checked: share_backend"), crispy.Div( 'authorized_domains', data_bind="visible: showAuthorizedDomains", ), ), self.gateway_specific_fields, crispy.Fieldset( _("Phone Numbers"), crispy.Div(data_bind="template: {" " name: 'ko-load-balancing-template', " " data: $data" "}", ), data_bind="visible: use_load_balancing", ), FormActions( StrictButton(button_text, type="submit", css_class='btn-primary'), ), )