def __init__(self, is_superuser=False, *args, **kwargs): super(InitiateAddSMSBackendForm, self).__init__(*args, **kwargs) backend_classes = get_available_backends() backend_choices = [] for name, klass in backend_classes.items(): if is_superuser or name == "TelerivetBackend": try: friendly_name = klass.get_generic_name() except NotImplementedError: friendly_name = name backend_choices.append((name, friendly_name)) self.fields['backend_type'].choices = backend_choices self.helper = FormHelper() self.helper.form_class = "form form-horizontal" self.helper.layout = crispy.Layout( BootstrapMultiField( _("Create Another Connection"), InlineField('action'), InlineField('backend_type'), StrictButton(mark_safe('<i class="icon-plus"></i> %s' % "Add Another Gateway"), css_class='btn-success', type='submit', style="margin-left:5px;"), ), )
class FoodboxFormsetHelper(FormHelper): layout = Layout( InlineField('name', readonly=True), Field('half_kickin'), InlineField('gets_supplemental'), )
class ScoreListFormHelper(FormHelper): form_method = "GET" form_id = "score-search-form" form_class = "form-inline" field_template = "bootstrap3/layout/inline_field.html" field_class = "col-xs-3" label_class = "col-xs-3" form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fas fa-search"></i> Filter Score Types', Row( InlineField("name"), InlineField("section"), InlineField("type"), InlineField("start_year"), FormActions( StrictButton( '<i class="fa fa-search"></i> Filter', type="submit", css_class="btn-primary", ), Submit("cancel", "Clear", css_class="btn-primary"), ), ), ), )
class RegionChapterTaskFormHelper(FormHelper): form_method = "GET" form_id = "event-search-form" form_class = "form-inline" field_template = "bootstrap3/layout/inline_field.html" field_class = "col-xs-3" label_class = "col-xs-3" form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fas fa-search"></i> Filter Tasks', Row( InlineField("task__name"), InlineField("task__owner"), InlineField("date"), FormActions( StrictButton( '<i class="fa fa-search"></i> Search', type="submit", css_class="btn-primary", ), Submit("cancel", "Clear", css_class="btn-primary"), ), ), ), )
class CustomerListFormHelper(FormHelper): form_id = 'customer-search-form' form_class = 'form-inline' field_template = 'bootstrap3/layout/inline_field.html' field_class = 'col-xs-3' label_class = 'col-xs-3' form_show_errors = True help_text_inline = False html5_required = True form_method = 'GET' layout = Layout( Fieldset( '<i class="fa fa-search"></i> Search Customer Records', InlineField('account_number'), InlineField('customer_last_name'), InlineField('customer_first_name'), InlineField('primary_phone'), ), FormActions( StrictButton( '<i class="fa fa-search"></i> Search', type='submit', css_class='btn-primary', style='margin-top:10px;') ) )
class UserListFormHelper(FormHelper): def __init__(self, *args, **kwargs): super(UserListFormHelper, self).__init__(*args, **kwargs) # InlineField.fields = '' form_id = 'user_list_form' form_class = 'form-inline' field_template = 'bootstrap3/layout/inline_field.html' # field_class = 'col-xs-3' # label_class = 'col-xs-3' form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fa fa-search"></i> Search Staff Records', InlineField('first_name'), InlineField('last_name'), InlineField('username'), InlineField('email'), ), FormActions( Submit('search', 'Search', css_class='btn btn-primary'), HTML(""" <a href="{% url 'accounts:user-list'%}"> <input type="button" class="btn btn-default" value="Reset"> </a> """) ) )
class AdvisorListFormHelper(FormHelper): form_method = "GET" form_id = "user-search-form" form_class = "form-inline" field_template = "bootstrap3/layout/inline_field.html" field_class = "col-xs-3" label_class = "col-xs-3" form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fas fa-search"></i> Filter Advisors', Row( Column(InlineField("name__icontains")), Column(InlineField("region")), Column(InlineField("chapter")), Column( FormActions( StrictButton( '<i class="fa fa-search"></i> Filter', type="submit", css_class="btn-primary", ), Submit("cancel", "Clear", css_class="btn-primary"), ) ), ), ), )
class EmployeeFilterFormHelper(FormHelper): # See https://django-crispy-forms.readthedocs.io/en/latest/form_helper.html form_class = "form form-inline" form_id = "employee-search-form" form_method = "GET" form_tag = True html5_required = True layout = Layout( Div( Fieldset( #str(_("Search employee")) "<span class='fa fa-search'></span> " + str(_("")), Div( InlineField("employee_number", wrapper_class="col-4"), InlineField("name__icontains", wrapper_class="col-4"), InlineField("surname__icontains", wrapper_class="col-4"), InlineField("profil", wrapper_class="col-4"), InlineField("level", wrapper_class="col-4"), css_class="row", ), css_class="col-10 border p-3", ), FormActions( Submit("submit", _("Filter")), css_class="col-2 text-right align-self-center", ), css_class="row", ))
def __init__(self, *args, **kwargs): super(ExampleForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-exampleForm' self.helper.form_class = 'blueForms' # self.helper.field_template = 'bootstrap3/layout/inline_field.html' self.helper.layout = Layout( # InlineField('like_website', readonly=True), # 'like_website', # CommonLayout, 'todo', 'date', 'reminder', InlineField('favorite_food'), InlineField('favorite_number'), InlineField('notes'), Div( 'favorite_food', 'favorite_bread', css_class='container-fluid' ), # StrictButton('Sign in', css_class='btn-default'), ) self.helper.form_method = 'post' # self.helper.form_action = 'submit_survey' self.helper.add_input(Submit('submit', 'Submit'))
def __init__(self, is_superuser=False, *args, **kwargs): super(InitiateAddSMSBackendForm, self).__init__(*args, **kwargs) from corehq.messaging.smsbackends.telerivet.models import SQLTelerivetBackend backend_classes = get_sms_backend_classes() backend_choices = [] for api_id, klass in backend_classes.items(): if is_superuser or api_id == SQLTelerivetBackend.get_api_id(): friendly_name = klass.get_generic_name() backend_choices.append((api_id, friendly_name)) backend_choices = sorted(backend_choices, key=lambda backend: backend[1]) self.fields['hq_api_id'].choices = backend_choices self.helper = HQFormHelper() self.helper.layout = crispy.Layout( hqcrispy.B3MultiField( _("Create Another Gateway"), InlineField('action'), Div(InlineField('hq_api_id', css_class="ko-select2"), css_class='col-sm-6 col-md-6 col-lg-4'), Div(StrictButton(mark_safe( '<i class="fa fa-plus"></i> Add Another Gateway'), css_class='btn-primary', type='submit', style="margin-left:5px;"), css_class='col-sm-3 col-md-2 col-lg-2'), ), )
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", ), )
class EmployeeListFormHelper(FormHelper): form_id = 'customer-search-form' form_class = 'form-inline' field_template = 'bootstrap3/layout/inline_field.html' field_class = 'col-xs-3' label_class = 'col-xs-3' form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fa fa-search"></i> Search Employee Records', InlineField('e_gender'), InlineField('e_desg__d_discp'), InlineField('e_desg__d_code'), ), FormActions( StrictButton( '<i class="fa fa-search"></i> Search', type='submit', css_class='btn-primary', style='margin-top:10px;') ) )
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 test_inline_field(self): form = SampleForm() form.helper = FormHelper() form.helper.layout = Layout( InlineField("first_name", wrapper_class="col-4"), InlineField("is_company", wrapper_class="col-4"), ) form.helper.form_class = "row row-cols-lg-auto align-items-center" assert parse_form(form) == parse_expected("test_inline_field.html")
def crispy_form_fields(self, context): crispy_form_fields = super(AppTranslationsBulkUploadForm, self).crispy_form_fields(context) if context.get('can_select_language'): crispy_form_fields.extend( [InlineField('language', data_bind="value: lang")]) if context.get('can_validate_app_translations'): crispy_form_fields.extend([crispy.Div(InlineField('validate'))]) return crispy_form_fields
class DateFilterForm(CrispyFilterMixin, forms.Form): von = forms.DateField(label="Von", required=False) bis = forms.DateField(label="Bis", required=False) __layout = Layout( InlineField( 'von', css_class="datepicker", ), InlineField( 'bis', css_class="datepicker", ), )
def __init__(self, *args, **kwargs): super(StockForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-inline' self.helper.field_template = 'bootstrap3/layout/inline_field.html' self.helper.layout = Layout( HTML('<div class="form-group"><label>Select Stock:</label></div>'), InlineField('select_stock', css_class='input-sm'), HTML( '<div class="form-group"><label>Select Method:</label></div>'), InlineField('select_method', css_class='input-sm'), InlineField('days', css_class='input-sm'), FormActions(Submit('Plot', 'Go', css_class='btn-plot btn-sm'), ), )
class UserListFormHelper(FormHelper): form_method = "GET" form_id = "user-search-form" form_class = "form-inline" field_template = "bootstrap3/layout/inline_field.html" field_class = "col-xs-3" label_class = "col-xs-3" form_show_errors = True help_text_inline = False html5_required = True layout = Layout( Fieldset( '<i class="fas fa-search"></i> Filter Members', Row( InlineField("name__icontains"), InlineField("major"), InlineField("graduation_year__icontains"), FormActions( StrictButton( '<i class="fa fa-search"></i> Filter', type="submit", css_class="btn-primary", ), Submit("cancel", "Clear", css_class="btn-primary"), StrictButton( '<i class="fa fa-download"></i> Download CSV', type="submit", value="Download CSV", name="csv", id="download-csv", css_class="btn-secondary", style="display: none;", ), StrictButton( '<i class="fa fa-envelope-square"></i> Email ALL', type="submit", value="Email ALL", name="email", css_class="btn-danger", id="email-all", style="display: none;", ), ), ), Row( InlineField("current_status"), ), ), )
def crispy_form_fields(self, context): crispy_form_fields = super(LocationReassignmentRequestForm, self).crispy_form_fields(context) crispy_form_fields.extend([ crispy.Div(InlineField('action_type')), ]) return crispy_form_fields
class POCListFormHelper(FormHelper): form_method = 'GET' FormHelper.form_class = 'form-horizontal' field_class = 'col-lg-6' label_class = 'col-lg-3' layout = Layout( Fieldset( '<i class="fa fa-search"></i> Search Point of Contact Records', InlineField('FName'), InlineField('LName'), 'PartnerID', 'ContractID', 'CustomerID', ), Submit('submit', 'Apply Filter'), )
def __init__(self, *args, **kwargs): self.from_entity = kwargs.pop('from_entity', None) self.to_entity = kwargs.pop('to_entity', None) self.chat = kwargs.pop('chat', None) assert bool(self.from_entity and self.to_entity) != bool( self.from_entity and self.chat) super().__init__(*args, **kwargs) self.helper = FormHelperWithDefaults() if (self.chat): self.helper.form_action = reverse( 'im:chat_send', kwargs={ 'chat_slug': self.chat.get_slug(current_user=self.from_entity) }) else: self.helper.form_action = reverse( 'im_entity:user_send', kwargs={'slug': self.to_entity.slug}) self.helper.form_class = 'form-vertical' self.helper.layout = Layout( InlineField('text', style="height: 55px"), Submit( 'submit', pgettext_lazy(context=self.from_entity.get_gender(), message='Send')), )
def __init__(self, *args, **kwargs): super(SkillFormSetHelper, self).__init__(*args, **kwargs) self.form_method = 'post' self.layout = Layout(InlineField('name','value'), 's_type', ) self.render_required_fields = True,
def __init__(self, *args, **kwargs): try: self.storyobject = kwargs.pop('storyobject') except KeyError: self.storyobject = None choice_story = Story.objects.get(storyobject=self.storyobject) storyoptions = StoryOptions.objects.get(story=choice_story) context_choices = [('Type_1', getattr(storyoptions, 'statistic_type_name_1')), ('Type_2', getattr(storyoptions, 'statistic_type_name_2')), ('Type_3', getattr(storyoptions, 'statistic_type_name_3')), ('Type_4', getattr(storyoptions, 'statistic_type_name_4'))] INITIAL_CHOICES = [1, 2, 3 ,4] stat_type = forms.ChoiceField() super(StatisticForm, self).__init__(*args, **kwargs) self.fields['stat_type'].choices = context_choices self.helper = FormHelper(self) self.layout = Layout(InlineField('name','value'), 'stat_type', ) self.helper.layout.append( FormActions( HTML("""<a role="button" class="btn btn-default" href="/personas/storyobject/{{ storyobject.slug }}/#abilities">Cancel</a>"""), Submit('save', 'Submit'),))
class ReportListFormHelper(FormHelper): def __init__(self, *args, **kwargs): super(ReportListFormHelper, self).__init__(*args, **kwargs) InlineField.fields = '' class Meta: model = Report labels = { "Date": "report_Date", "Site": "site", "Department": "department", "Program": "program", "Summary": "summary", "Feedback": "feedback_challenges", } form_id = 'report-search-form' form_class = 'form-inline' field_template = 'bootstrap3/layout/inline_field.html' form_show_labels = True form_show_errors = True help_text_inline = False html5_required = True form_tag = True layout = Layout( 'Staff', 'Date', 'Site', 'Department', 'Program', Fieldset( '<i class="fa fa-search"></i>Search Form', InlineField('report_user'), # InlineField('report_date'), InlineField('site'), InlineField('department'), InlineField('program'), ), FormActions( Submit('search', 'Search', css_class='btn btn-primary'), HTML(""" <a href="{% url 'reports:report-list'%}"> <input type="button" class="btn btn-default" value="Reset"> </a> """)))
def helper(self): helper = FormHelperWithDefaults() helper.form_class = 'form-inline' helper.form_action = reverse('accounts:change_email_privacy', kwargs={'pk': self.instance.id}) helper.field_template = 'bootstrap3/layout/inline_field.html' helper.layout = Layout(InlineField('access', css_class='input-sm'), ) return helper
def __init__(self, *args, **kwargs): super(GalleryImageForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.layout = Layout(InlineField('title','data')) self.helper.layout.append( FormActions( HTML("""<a role="button" class="btn btn-default" href="/personas/storyobject/{{ storyobject.slug }}/#combat">Cancel</a>"""), Submit('save', 'Submit'),))
class ContractListFormHelper(FormHelper): form_method = 'GET' field_template = 'bootstrap3/layout/inline_field.html' field_class = 'col-xs-3' label_class = 'col-xs-3' layout = Layout( Fieldset( '<i class="fa fa-search"></i> Search Contract Records', InlineField('IssuingCompany'), InlineField('ContractNumber'), ), #'resource_first_name', #'resource_last_name', #'HUBzone', #'employment_status', Submit('submit', 'Apply Filter'), )
def __init__(self, *args, **kwargs): super(Inventory_ItemForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-inline' self.helper.field_template = 'bootstrap3/layout/inline_field.html' self.helper.form_method = 'post' self.helper.form_action = '' self.helper.layout = Layout( HTML('<td>'), InlineField('ingredient', title='Name'), HTML('</td><td>'), Div(Div(InlineField('amount'), css_class='col-md-6'), Div(InlineField('measurement'), css_class='col-md-6'), css_class='row'), HTML('</td><td></td><td></td><td>'), InlineField('remarks'), HTML('</td><td>'), StrictButton( '<span class="glyphicon glyphicon-plus" aria-hidden="true"></span><span class="sr-only">Add</span>', type='submit', css_class='btn btn-default btn-sm'), HTML('</td>'))
def __init__(self, *args, **kwargs): super(Meal_ReceipeForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_class = 'form-inline' self.helper.field_template = 'bootstrap3/layout/inline_field.html' self.helper.form_method = 'post' self.helper.form_action = '' self.helper.layout = Layout( HTML('<td>'), InlineField('receipe'), HTML('</td><td>'), InlineField('person_count'), HTML('</td><td></td><td></td><td>'), InlineField('remarks'), HTML('</td><td>'), StrictButton('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span><span class="sr-only">Add</span>', type='submit', css_class='btn btn-default btn-sm'), HTML('</td>') )
def __init__(self, *args, **kwargs): super(FeedbackForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'feedback' self.helper.form_class = 'blueForms' self.helper.form_method = 'post' self.helper.form_action = '.' self.helper.label_class = 'col-4 text-right col-form-label' self.helper.field_class = 'col-8' self.helper.help_text_inline = True self.helper.layout = Layout( InlineField('sender'), InlineField('subject'), InlineField('message'), ) self.helper.add_input(Submit('submit', 'Submit'))