def __init__(self, *args, **kwargs): super(BaseFormHelper, self).__init__(*args, **kwargs) self.form_class = 'form-horizontal' self.help_text_inline = True self.form_method = 'POST' save_btn = Submit('submit', 'Save') save_btn.field_classes = 'btn btn-primary' self.add_input(save_btn)
def __init__(self, *args, **kwargs): super(ExpenseForm, self).__init__(*args, **kwargs) self.helper = FormHelper() submit = Submit("Submit", _("Save")) submit.field_classes = "btn btn-default" self.helper.layout = Layout(Div(Column("description", "category", "amount", Field("expense_date", css_class="datepicker"), css_class='col-md-6'), Column("lead", "chargeable", "corporate_card", "receipt", "comment", css_class='col-md-6'), css_class='row'), submit)
def __init__(self, *args, **kwargs): super(BaseFormHelper, self).__init__(*args, **kwargs) self.form_class = 'form-horizontal' self.form_method = 'POST' self.help_text_inline = True save_button = Submit('save', 'Save') save_button.field_classes = 'btn-primary btn-large' self.add_input(save_button) cancel_button = Submit('cancel', 'Cancel') self.add_input(cancel_button)
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.form_method = "post" self.helper.form_action = "example_form" submit = Submit("submit", "Submit") submit.field_classes = "ui button" self.helper.add_input(submit)
def __init__(self, *args, **kwargs): super(RecordCreateForm, self).__init__(*args, **kwargs) self.fields['order_date'].initial = datetime.today().strftime('%d/%m/%Y') self.fields['infobase_id'].help_text = '''To link to an Infobase record, enter the Infobase object ID exactly as it appears in Infobase (i.e. case-sensitive, no spaces). E.g.: eA498596''' # Add in a "Save and add another" button. save_another_button = Submit('save-another', 'Save and add another') save_another_button.field_classes = ' btn btn-default' layout = Layout( 'name', 'uploaded_file', 'infobase_id', 'description', 'order_date', Div( self.save_button, save_another_button, self.cancel_button, css_class='col-sm-offset-4 col-md-offset-3 col-lg-offset-2') ) self.helper.add_layout(layout)
def __init__(self, *args, **kwargs): super(ConditionCreateForm, self).__init__(*args, **kwargs) help_html = HTML('''<p>Add a subdivision or development condition that requires a clearance. Add additional conditions separately by clicking <strong>Save and add another</strong>.</p>''') # Add in a "Save and add another" button. save_another_button = Submit('save-another', 'Save and add another') save_another_button.field_classes = 'btn btn-default' layout = Layout( help_html, 'model_condition', 'proposed_condition_html', 'condition_html', 'identifier', Div( self.save_button, self.cancel_button, save_another_button, css_class='col-sm-offset-4 col-md-offset-3 col-lg-offset-2') ) self.helper.add_layout(layout)
def __init__(self, *args, **kwargs): super(CrispyContactMsgForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'CF' self.helper.form_class = 'form-horizontal' self.helper.form_method = 'post' self.helper.form_action = 'contactme-post-contact-form' self.helper.label_class = 'col-lg-3 col-md-3' self.helper.field_class = 'col-lg-8 col-md-8' self.helper.layout = Fieldset( "Your contact details", 'timestamp', 'security_hash', Field('honeypot', wrapper_class="hide"), 'name', 'email', 'message' ) send = Submit('submit', 'send', data_name="post") preview = Submit('preview', 'preview', css_class="btn btn-default") preview.field_classes = 'btn btn-default' self.helper.add_input(send) self.helper.add_input(preview)
def __init__(self, *args, **kwargs): super(CrispyXtdCommentForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'CF' self.helper.form_class = 'form-horizontal' self.helper.form_method = 'post' self.helper.form_action = django_comments.get_form_target() self.helper.label_class = 'col-lg-3 col-md-3' self.helper.field_class = 'col-lg-8 col-md-8' self.helper.layout = Fieldset( "Your comment", 'content_type', 'object_pk', 'timestamp', 'security_hash', Field('honeypot', wrapper_class="hide"), 'name', 'email', 'url', 'comment', 'followup', 'reply_to' ) send = Submit('submit', 'send', data_name="post") preview = Submit('preview', 'preview', css_class="btn btn-default") preview.field_classes = 'btn btn-default' self.helper.add_input(send) self.helper.add_input(preview)
def __init__(self, reference_type=None, reference_to=None, *args, **kwargs): forms.Form.__init__(self, *args, **kwargs) legend = 'Reply to this' submit_value = 'Leave a Reply' ajax_form = 'list-None-form' submit_id = 'action-button' cancel_id = 'cancel-button' action = Submit('action', submit_value) action.field_classes = 'btn_reply' cancel = Submit('action', 'Cancel') cancel.field_classes = 'btn_cancel' self.reference_to = reference_to self.reference_type = reference_type self.helper = FormHelper() self.helper.form_action = reverse('comment_create', args=(reference_type, reference_to)) self.helper.layout = Layout( Field('name', css_class='field span12'), Field('pingback', css_class="field span12"), Field('comment', css_class="field span12"), action, cancel ) self.helper.layout.insert(0, HTML('<legend>%s</legend>' % legend))
def __init__(self, *args, **kwargs): forms.Form.__init__(self, *args, **kwargs) legend = "Edit Blog Post" submit_value = 'Save' ajax_form = 'list-None-form' submit_id = 'action-button' cancel_id = 'cancel-button' action = Submit('action', submit_value) action.field_classes = 'btn_reply' cancel = Submit('action', 'Cancel') cancel.field_classes = 'btn_cancel' self.helper = FormHelper() self.helper.layout = Layout( Field('title', css_class='input-xlarge'), Field('seo_tags', css_class='input-xlargs'), Field('is_markdown', css_class='input-xlarge'), Field('created_on', css_class='input-xlarge'), Field('summary', css_class='field span12'), Field('body', css_class='field span12'), action, cancel ) self.helper.layout.insert(0, HTML('<legend>%s</legend>' % legend))
def __init__(self, *args, **kwargs): staffing_dates = kwargs.pop("staffing_dates", []) super(MassStaffingForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.fields["charge"] = forms.fields.FloatField(label=_("Charge"), min_value=0.25, max_value=31) self.fields["comment"] = forms.fields.CharField(label=_("Comment"), max_length=100, required=False) self.fields["all_consultants"] = forms.fields.BooleanField(label=_("All active consultants"), required=False) self.fields["staffing_dates"] = forms.fields.MultipleChoiceField( label=_("Staffing dates"), choices=staffing_dates ) self.fields["missions"] = forms.ModelMultipleChoiceField(widget=MissionMChoices, queryset=Mission.objects.all()) self.fields["consultants"] = forms.ModelMultipleChoiceField( widget=ConsultantMChoices, queryset=Consultant.objects.all() ) submit = Submit("Submit", _("Save")) submit.field_classes = "btn btn-default" self.helper.layout = Layout( Div( Column("missions", "consultants", "all_consultants", css_class="col-md-6"), Column("charge", "staffing_dates", "comment", css_class="col-md-6"), css_class="row", ), submit, )
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'POST' self.helper.add_input(Submit('submit', '작성!'))
def __init__(self, *args, user, linked_task=None, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit("save", "Submit")) self.fields["files"].widget.user = user self._linked_task = linked_task
class ChangeRequestCreateForm(forms.ModelForm): """Base ModelForm class for ChangeRequest models. In order to improve user experience, the DepartmentUser select fields are replaced with basic validation-exempt ChoiceFields that are filled client-side via AJAX. Inputted data is then saved to the model after form validation. """ save_button = Submit('save', 'Save draft', css_class='btn-lg') endorser_choice = UserChoiceField( required=False, label='Endorser', help_text='The person who will endorse this change prior to CAB') implementer_choice = UserChoiceField( required=False, label='Implementer', help_text='The person who will implement this change') def __init__(self, *args, **kwargs): super(ChangeRequestCreateForm, self).__init__(*args, **kwargs) # Add a CSS class to user choice fields, to upgrade them easier using JS. self.fields['endorser_choice'].widget.attrs['class'] = 'select-user-choice' self.fields['endorser_choice'].label = 'Endorser email' self.fields['implementer_choice'].widget.attrs['class'] = 'select-user-choice' self.fields['implementer_choice'].label = 'Implementer email' self.fields['test_result_docs'].help_text += ' - OPTIONAL' self.fields['implementation'].help_text = 'Implementation/deployment instructions, including any rollback procedure' self.helper = BaseFormHelper() self.helper.layout = Layout( Fieldset( 'Instructions', Div( HTML('<p>Note that all fields below need not be completed until the point of submission for endorsement (RFCs may be saved as drafts).</p><br>'), css_id='div_id_instructions' ), ), Fieldset( 'Overview', 'title', 'description', ), Fieldset( 'Endorsement and Implementer', HTML('<p>Endorser and implementer must be nominated prior to submission for endorsement.'), 'endorser_choice', 'implementer_choice', ), Fieldset( 'Testing and Implementation', HTML('<p>Test and implementation dates & times must be supplied prior to submission for endorsement.'), 'test_date', 'test_result_docs', 'planned_start', 'planned_end', 'outage', Div( HTML('''<p>Please note that implementation instructions must be supplied prior to submission for endorsement. Text instructions or an uploaded document (e.g. Word, PDF) are acceptable. Implemenation instructions should include any details related to post-change testing and any rollback procedures.</p><br>'''), css_id='div_id_implementation_note' ), 'implementation', 'implementation_docs', ), Fieldset( 'Communication', Div( HTML('<p>Please include details about any required communications (timing, stakeholders, instructions, etc.)</p><br>'), css_id='div_id_communication' ), 'communication', 'broadcast', ), Fieldset( 'IT Systems', Div( HTML('<p>IT Systems that are affected by this change request.') ), 'it_systems', ), FormActions(self.save_button), ) class Meta: model = ChangeRequest fields = [ 'title', 'description', 'test_date', 'test_result_docs', 'planned_start', 'planned_end', 'implementation', 'implementation_docs', 'outage', 'communication', 'broadcast', 'it_systems'] def clean(self): if self.cleaned_data['planned_start'] and self.cleaned_data['planned_end']: if self.cleaned_data['planned_start'] > self.cleaned_data['planned_end']: msg = 'Planned start cannot be later than planned end.' self._errors['planned_start'] = self.error_class([msg]) self._errors['planned_end'] = self.error_class([msg]) return self.cleaned_data
def __init__(self, *args, **kwargs): super(ProposalForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit('submit', _('Submit')))
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.layout = Layout( AppendedText('importo', '<i class="icon-money"></i>'), FormActions(Submit('save', 'Salva', css_class="btn-primary"))) super(IncassaForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(FeedbackForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.layout.append(FormActions(Submit('save', 'Send message'), ))
def __init__(self, *args, **kwargs): super(ImportForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('submit', 'Import')) self.helper.form_method = 'get' self.helper.form_action = '/list'
class KegForm(forms.Form): keg_size = forms.ChoiceField(choices=keg_sizes.CHOICES, initial=keg_sizes.HALF_BARREL, required=True) initial_volume = forms.FloatField(label='Initial Volume', initial=0.0, required=False, help_text='Keg\'s Initial Volume') beer_name = forms.CharField(required=False) # legacy brewer_name = forms.CharField(required=False) # legacy beverage_name = forms.CharField(label='Beer Name', required=False) beverage_id = forms.CharField(widget=forms.HiddenInput(), required=False) producer_name = forms.CharField(label='Brewer', required=False) producer_id = forms.CharField(widget=forms.HiddenInput(), required=False) style_name = forms.CharField(required=True, label='Style', help_text='Example: Pale Ale, Stout, etc.') description = forms.CharField(max_length=256, label='Description', widget=forms.Textarea(), required=False, help_text='Optional user-visible description of the keg.') notes = forms.CharField(label='Notes', required=False, widget=forms.Textarea( ), help_text='Optional private notes about this keg, viewable only by admins.') connect_to = forms.ModelChoiceField( queryset=ALL_TAPS, label='Connect To', required=False, help_text='If selected, immediately activates the keg on this tap. ' '(Any existing keg will be ended.)') helper = FormHelper() helper.form_class = 'form-horizontal beer-select' helper.layout = Layout( Field('beverage_name', css_class='input-xlarge'), Field('beverage_id', type='hidden'), Field('producer_name', css_class='input-xlarge'), Field('producer_id', type='hidden'), Field('style_name', css_class='input-xlarge'), Field('keg_size', css_class='input-xlarge'), Field('initial_volume', css_class='input-volume'), Field('description', css_class='input-block-level', rows='3'), Field('notes', css_class='input-block-level', rows='3'), Field('connect_to', css_class='input-block-level'), FormActions( Submit('submit_add_keg', 'Save', css_class='btn-primary'), ) ) def clean_beverage_name(self): beverage_name = self.cleaned_data.get('beverage_name') if not beverage_name: beverage_name = self.cleaned_data.get('beer_name') if not beverage_name: raise forms.ValidationError('Must specify a beverage name') self.cleaned_data['beverage_name'] = beverage_name return beverage_name def clean_producer_name(self): producer_name = self.cleaned_data.get('producer_name') if not producer_name: producer_name = self.cleaned_data.get('brewer_name') if not producer_name: raise forms.ValidationError('Must specify a producer name') self.cleaned_data['producer_name'] = producer_name return producer_name def save(self): if not self.is_valid(): raise ValueError('Form is not valid.') keg_size = self.cleaned_data.get('keg_size') if keg_size != 'other': full_volume_ml = None else: full_volume_ml = self.cleaned_data.get('initial_volume') # TODO(mikey): Support non-beer beverage types. cd = self.cleaned_data b = get_kegbot_backend() keg = b.create_keg( beverage_name=cd['beverage_name'], producer_name=cd['producer_name'], beverage_type='beer', style_name=cd['style_name'], keg_type=cd['keg_size'], full_volume_ml=full_volume_ml, notes=cd['notes'], description=cd['description']) tap = cd['connect_to'] if tap: if tap.is_active(): b.end_keg(tap.current_keg) b.attach_keg(tap, keg) return keg
class ChangeKegForm(forms.Form): keg_size = forms.ChoiceField(choices=keg_sizes.CHOICES, initial=keg_sizes.HALF_BARREL, required=True) initial_volume = forms.FloatField(label='Initial Volume', initial=0.0, required=False, help_text='Keg\'s Initial Volume') beer_name = forms.CharField(required=False) # legacy brewer_name = forms.CharField(required=False) # legacy beverage_name = forms.CharField(label='Beer Name', required=False) beverage_id = forms.CharField(widget=forms.HiddenInput(), required=False) producer_name = forms.CharField(label='Brewer', required=False) producer_id = forms.CharField(widget=forms.HiddenInput(), required=False) style_name = forms.CharField(required=True, label='Style', help_text='Example: Pale Ale, Stout, etc.') helper = FormHelper() helper.form_class = 'form-horizontal beer-select' helper.layout = Layout( Field('beverage_name', css_class='input-xlarge'), Field('beverage_id', type='hidden'), Field('producer_name', css_class='input-xlarge'), Field('producer_id', type='hidden'), Field('style_name', css_class='input-xlarge'), Field('keg_size', css_class='input-xlarge'), Field('initial_volume', css_class='input-volume'), FormActions( Submit('submit_change_keg_form', 'Activate Keg', css_class='btn-primary'), ) ) def clean_beverage_name(self): beverage_name = self.cleaned_data.get('beverage_name') if not beverage_name: beverage_name = self.cleaned_data.get('beer_name') if not beverage_name: raise forms.ValidationError('Must specify a beverage name') self.cleaned_data['beverage_name'] = beverage_name return beverage_name def clean_producer_name(self): producer_name = self.cleaned_data.get('producer_name') if not producer_name: producer_name = self.cleaned_data.get('brewer_name') if not producer_name: raise forms.ValidationError('Must specify a producer name') self.cleaned_data['producer_name'] = producer_name return producer_name def save(self, tap): if not self.is_valid(): raise ValueError('Form is not valid.') b = get_kegbot_backend() if tap.is_active(): b.end_keg(tap.current_keg) keg_size = self.cleaned_data.get('keg_size') full_volume_ml = self.cleaned_data.get('full_volume_ml') if keg_size != 'other': full_volume_ml = None else: full_volume_ml = self.cleaned_data.get('initial_volume') # TODO(mikey): Support non-beer beverage types. cd = self.cleaned_data keg = b.start_keg( tap, beverage_name=cd['beverage_name'], producer_name=cd['producer_name'], beverage_type='beer', style_name=cd['style_name'], keg_type=cd['keg_size'], full_volume_ml=full_volume_ml) if cd.get('description'): keg.description = cd['description'] keg.save()
class TapForm(forms.ModelForm): class FlowMeterModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, meter): if meter.tap: return u'{} (connected to {})'.format(meter, meter.tap.name) else: return str(meter) class FlowToggleModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, toggle): if toggle.tap: return u'{} (connected to {})'.format(toggle, toggle.tap.name) else: return str(toggle) class ThermoSensorModelChoiceField(forms.ModelChoiceField): def label_from_instance(self, sensor): last_log = sensor.LastLog() if last_log: return u'{} (Last report: {})'.format(sensor, naturaltime(last_log.time)) else: return str(sensor) meter = FlowMeterModelChoiceField( queryset=ALL_METERS, required=False, empty_label='Not connected.', help_text='Tap is routed thorough this flow meter. If unset, reporting is disabled.') toggle = FlowToggleModelChoiceField( queryset=ALL_TOGGLES, required=False, empty_label='Not connected.', help_text='Optional flow toggle (usually a relay/valve) connected to this tap.') temperature_sensor = ThermoSensorModelChoiceField( queryset=ALL_THERMOS, required=False, empty_label='No sensor.', help_text='Optional sensor monitoring the temperature at this tap.') class Meta(object): model = models.KegTap fields = ('name', 'notes', 'temperature_sensor', 'sort_order') def __init__(self, *args, **kwargs): super(TapForm, self).__init__(*args, **kwargs) if self.instance: self.fields['meter'].initial = self.instance.current_meter() self.fields['toggle'].initial = self.instance.current_toggle() self.fields['temperature_sensor'].initial = self.instance.temperature_sensor def save(self, commit=True): if not commit: raise ValueError('TapForm does not support commit=False') instance = super(TapForm, self).save(commit=True) b = get_kegbot_backend() b.connect_meter(instance, self.cleaned_data['meter']) b.connect_toggle(instance, self.cleaned_data['toggle']) return instance helper = FormHelper() helper.form_class = 'form-horizontal' helper.layout = Layout( Field('name', css_class='input-xlarge'), Field('meter', css_class='input-xlarge'), Field('toggle', css_class='input-xlarge'), Field('temperature_sensor', css_class='input-xlarge'), Field('sort_order', css_class='input-xlarge'), Field('notes', css_class='input-block-level', rows='3'), FormActions( Submit('submit_tap_form', 'Save Settings', css_class='btn-success'), ) )
def __init__(self, *args, **kwargs): super(PersonForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('submit', 'Submit'))
def add_button(desc, label): self.helper.add_input(Submit(desc, label))
def __init__(self, *args, **kwargs): super(CourseCreationForm, self).__init__(*args, **kwargs) self.helper.add_input(Submit("submit", _("Validate and create")))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Submit comment'))
def __init__(self, *args, **kwargs): # needed because HTML template string below =( translations = { 'projects_in_this_site': _('Projects in this Site'), 'project_name': _('Project Name'), 'program': _('Program'), 'activity_code': _('Activity Code'), 'view': _('View'), } # get the user object from request to check user permissions self.request = kwargs.pop('request') self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_class = '' self.helper.label_class = '' self.helper.field_class = '' self.helper.form_error_title = 'Form Errors' self.helper.error_text_inline = True self.helper.help_text_inline = True self.helper.html5_required = True submit_section = Div() if self.request.has_write_access: submit_section = Div( FormActions( Submit('submit', _('Save changes'), css_class=''), Reset('reset', _('Reset'), css_class='') ), css_class='form-actions', ) # Organize the fields in the site profile form using a layout class self.helper.layout = Layout( HTML("""<br/>"""), TabHolder( Tab(_('Profile'), Fieldset(_('Description'), 'name', 'type','status', ), Fieldset(_('Contact Info'), 'contact_leader', 'date_of_firstcontact', 'contact_number', 'num_members', ), ), Tab(_('Location'), Fieldset(_('Places'), 'country', Field('latitude', step="any"), Field('longitude', step="any"), ), Fieldset(_('Map'), 'map', ), ), Tab(_('Demographic Information'), Fieldset(_('Households'), 'total_num_households','avg_household_size', 'male_0_5', 'female_0_5', 'male_6_9', 'female_6_9', 'male_10_14', 'female_10_14','male_15_19', 'female_15_19', 'male_20_24', 'female_20_24', 'male_25_34', 'female_25_34', 'male_35_49', 'female_35_49', 'male_over_50', 'female_over_50', 'total_population', ), Fieldset(_('Land'), 'classify_land','total_land','total_agricultural_land','total_rainfed_land','total_horticultural_land', 'populations_owning_land', 'avg_landholding_size', 'households_owning_livestock','animal_type' ), Fieldset(_('Literacy'), 'literate_males','literate_females','literacy_rate', ), Fieldset(_('Demographic Info Data Source'), 'info_source' ), ), ), submit_section, ) super(SiteProfileForm, self).__init__(*args, **kwargs) if not self.request.has_write_access: for name, field in self.fields.items(): field.disabled = True #override the office queryset to use request.user for country countries = ( self.request.user.tola_user.managed_countries.all() | Country.objects.filter(id__in=self.request.user.tola_user.programaccess_set.filter(role='high').values('country_id')) ).distinct() self.fields['date_of_firstcontact'].label = _("Date of First Contact") self.fields['approved_by'].queryset = TolaUser.objects.filter(country__in=countries).distinct() self.fields['filled_by'].queryset = TolaUser.objects.filter(country__in=countries).distinct() self.fields['country'].queryset = countries
def __init__(self, *args, **kwargs): super(ScanForm, self).__init__(*args, **kwargs) instance = kwargs.get('instance') self.helper = FormHelper() self.helper.add_input(Submit('submit', ugettext('submit').capitalize())) selected_ids = [o.id for o in instance.scan_type.all()] if instance else [] nodes_html = self.get_nodes_html( Type.objects.get(name='Scan', parent=None), selected_ids) self.fields['scan_map'].label = 'Map title' if instance and instance.pk: self.fields['file'].widget.attrs['disabled'] = True self.helper.layout = Layout( Div(HTML('<div class="form-header">' + ugettext('data').capitalize() + '</div>'), 'name', 'scan_date', 'scan_map', 'scan_reference', 'scan_person', css_class='form-float'), Div( HTML('<div class="form-header">' + ugettext('types').capitalize() + '</div>'), HTML(nodes_html), HTML('<div style="clear:both;"></div>'), 'info'), Div('scan_type', 'file', css_class='hidden')) else: self.helper.layout = Layout( Div(HTML('<div class="form-header">' + ugettext('data').capitalize() + '</div>'), 'file', HTML('<p>' + ugettext('Max file size') + ': ' + filesizeformat(settings.ALLOWED_SCAN_SIZE) + '<br />' + ugettext('allowed files') + ': ' + ', '.join(settings.ALLOWED_SCAN_EXTENSIONS) + '</p>'), 'name', 'scan_date', 'scan_map', 'scan_reference', 'scan_person', css_class='form-float'), Div( HTML('<div class="form-header">' + ugettext('types').capitalize() + '</div>'), HTML(nodes_html), HTML('<div style="clear:both;"></div>'), 'info'), Div('scan_type', css_class='hidden'), Div( HTML(''' <script> $(document).ready(function () {{ $('#id_file').on("change", function() {{ /* check and warn if filesize is too big */ if ($('#id_file')[0].files[0].size > {allowed_upload_size}) {{ alert('{file_too_big_error}') }} /* if name is empty, fill with filename without the extension */ if ($('#id_name').val() == '') {{ var filename = $('#id_file')[0].files.length ? $('#id_file')[0].files[0].name : ''; $('#id_name').val(filename.replace(/\.[^/.]+$/, "")); }} }}); }}); </script>'''.format( allowed_upload_size=settings.ALLOWED_SCAN_SIZE, file_too_big_error=ugettext( 'This file is too big.')))))
def __init__(self, *args, **kwargs): self.helper = FormHelper() self.helper.layout = Layout( Field('nome'), Field('sigla'), Field('stato'), FormActions(Submit('save', 'Salva', css_class="btn-primary"))) super(UnitaForm, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(GenericFilterFormHelper, self).__init__(*args, **kwargs) self.helper = FormHelper() self.form_class = 'genericFilterForm' self.form_method = 'GET' self.add_input(Submit('Filter', 'Search'))
def __init__(self, *args, **kwargs): super(ParticipationQueryForm, self).__init__(*args, **kwargs) self.helper.add_input(Submit("list", _("List"))) self.helper.add_input(Submit("apply", _("Apply operation")))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input( Submit('extras_next', 'Next', css_class='btn btn-secondary'))
class MentorProfileForm(BaseModelForm): def __init__(self, *args, **kwargs): super(MentorProfileForm, self).__init__(*args, **kwargs) self.error_class = DivErrorList self.fields['full_names'].label = "Full names" self.fields['phone'].label = "Mobile contact" self.fields['summary'].label = "Please provide a summary about your educational, professional and" \ " entrepreneurial experience" self.fields['picture'].label = "Profile Picture" self.fields[ 'support_type'].label = "Where can you support the innovations?" self.fields[ 'support_stage'].label = "At what stage of development can you support the innovation?" competencies = forms.CharField(widget=forms.Textarea(), label="What are your core competencies?") support_type = forms.MultipleChoiceField( choices=( ('financial modelling', "Financial modelling"), ('business modelling', "Business modelling"), ('customer development', "Customer development"), ('legal', "Legal"), ('sales marketing', "Sales and Marketing"), ('technical support', "Technical Support"), ('building minimal viable product', "Building a minimum viable product"), ('raising funds', "Raising funds"), ('building a board', "Building a board"), ), widget=forms.CheckboxSelectMultiple) support_stage = forms.MultipleChoiceField( choices=( ('concept stage', "Concept stage"), ('seed stage (finding product market fit)', "Seed stage (finding product market fit)"), ('venture captial (growth)', "Venture captial (growth)"), ('private equity (scaling and expansion)', "Private Equity (scaling and expansion)"), ), widget=forms.CheckboxSelectMultiple) full_names = forms.CharField() phone_regex = RegexValidator( regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format:" " '+256 XXX XXX'. Up to 15 digits allowed.") phone = forms.CharField( validators=[phone_regex], widget=forms.TextInput(attrs={ 'class': "", 'placeholder': '+256 XXX XXX' })) country = forms.CharField(max_length=20) picture = forms.ImageField(required=False, validators=[validate_img]) linkedin = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) twitter = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) blog = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) facebook = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) website = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) summary = forms.CharField(widget=forms.Textarea(attrs={'class': ""})) gender = forms.ChoiceField( choices=(('male', "Male"), ('female', "Female")), widget=forms.RadioSelect, initial='female', ) helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.layout = Layout( Field('full_names', css_class='text-small'), Field('gender'), Field('phone', css_class='text-small'), Field('country', css_class='text-small'), Field('summary', rows="3", css_class='text-large'), Field('picture', css_class='file-upload'), Field('linkedin', css_class='text-small'), Field('facebook', css_class='text-small'), Field('twitter', css_class='text-small'), Field('blog', css_class='text-small'), Field('website', css_class='text-small'), Field('competencies', css_class='text-large', rows=3), InlineCheckboxes('support_stage', ), InlineCheckboxes('support_type', ), FormActions( HTML( '<a class="cancelBtn btn btn-primary" href={% url "index:home" %}>Cancel</a>' ), Submit('next', 'Save', css_class="cancelBtn")), ) class Meta: model = Mentor fields = ('gender', 'phone', 'country', 'summary', 'picture', 'linkedin', 'twitter', 'blog', 'website', 'full_names', 'support_stage', 'support_type', 'competencies', 'facebook')
def __init__(self, *args, **kwargs): """Add Crispy Forms helpers.""" super(ProfileForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('submit', 'Save'))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('submit', "Submit"))
def __init__(self, *args, **kwargs): super(MentorForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit('mentor_submit', _('Guardar'))) self.helper.add_input( Reset('mentor_reset', _('Limpiar'), css_class='btn-default'))
def __init__(self, *args, **kwargs): super(DataFilterForm, self).__init__(*args, **kwargs) self.helper = FormHelper(self) self.helper.form_method = 'POST' self.helper.form_class = 'form-horizontal' self.helper.label_class = 'col-sm-2' self.helper.field_class = 'col-sm-4' self.helper.form_action = '#apisearchresult' self.helper.layout = Layout( TabHolder( Tab( 'Filters', HTML( '<p style="margin-left: 10px; margin-bottom: 20px; font-size: 15px; font-weight:\ 600">General properties</p>'), Div(Div('element_set', css_class="span4"), css_class='row-fluid'), Div(Div('composition', css_class="span4"), Div('icsd', css_class="span4"), css_class='row-fluid'), HTML( '<br><p style="margin-left: 10px; margin-bottom: 20px; font-size: 15px; font-weight:\ 600">Structural properties</p>'), Div(Div('ntypes', css_class="span4"), Div('natoms', css_class="span4"), css_class='row-fluid'), Div(Div('prototype', css_class="span4"), Div('generic', css_class="span4"), css_class='row-fluid'), HTML( '<br><p style="margin-left: 10px; margin-bottom: 20px; font-size: 15px; font-weight:\ 600">DFT calculated properties</p>'), Div(Div('stability', css_class="span4"), Div('band_gap', css_class="span4"), css_class='row-fluid'), Div(Div('delta_e', css_class="span4"), css_class='row-fluid'), HTML( '<br><p style="margin-left: 10px; margin-bottom: 20px; font-size: 15px; font-weight:\ 600">Manual Input Filters</p>'), Div(Field('filter', css_class="span8"), css_class='row-fluid'), ), Tab( 'Order of Results', Field('sort_by', css_class="input-sm"), Field('desc', css_class="input-sm"), Field('limit', css_class="input-sm"), Field('sort_offset', css_class="input-sm"), ), ), # ButtonHolder( # Submit('search', 'Search',css_class='btn-primary'), # Reset('clear', 'Clear'), # ), ) self.helper.add_input( Submit('search', 'Search', css_class='btn-primary')) self.helper.add_input( Reset('clear', 'Reset input fields', css_class='btn-warning'))
def __init__(self, *args, **kwargs): self.distribution = kwargs.pop('distribution') super().__init__(*args, **kwargs) if not EmailAddressee.objects.count(): email_addressee_start_values = [ ('Hospitalists', '*****@*****.**', True, True), ('Cheryl', '*****@*****.**', True, True), ('Susan', '*****@*****.**', True, True), ('Intensivists', '*****@*****.**', True, False), ('ID docs', '*****@*****.**', True, False) ] for (displayed_name, email_address, visible, pre_checked) in email_addressee_start_values: EmailAddressee.objects.get_or_create( displayed_name=displayed_name, email_address=email_address, visible=visible, pre_checked=pre_checked)[0] self.fields[ 'recipient_choices'].queryset = EmailAddressee.objects.filter( visible=True) self.initial['recipient_choices'] = EmailAddressee.objects.filter( pre_checked=True) instance = self.instance instance.distribution = self.distribution if self.distribution.date == timezone.localdate(): self.initial[ 'subject'] = f'Pt Assignment - {self.distribution.date.strftime("%a %m/%d/%y")}' else: self.initial['subject'] = f'Pt Assignment for {self.distribution.date.strftime("%a %m/%d/%y")} ' + \ f'sent on {timezone.localtime().strftime("%a %m/%d/%y")}' instance.html_message = render_to_string( 'distribution/simple_assignment_table.html', instance.assemble_pt_assignment_context()) # instance.save() self.helper = FormHelper() self.helper.form_id = 'id_email_distribution_form' self.helper.form_method = 'post' self.helper.layout = Layout( Div( HTML('<h5>Subject:</h5>'), Field('subject', wrapper_class='subject-field ml-5'), css_class='form-row subject-textbox', ), HTML('<h5>To:</h5>'), Div(Field('recipient_choices', wrapper_class='recipient_field ml-5', css_class='position-static'), css_class='form-row recipient-checkboxes'), Div(Submit('submit', 'Send Email', css_id='id_email_patient_distribution', css_class='btn-primary', wrapper_class='text-center'), css_class='text-center')) self.helper.form_show_labels = False
def __init__(self, *args, **kwargs): super(signupForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.form_action = 'entry_page' self.helper.html5_required = True self.fields['child_birthday'].widget.format = '%d-%m-%Y' self.helper.layout = Layout( Hidden('form_id', 'signup', id="id_form_id"), Fieldset( 'Barnets oplysninger', Div(Div(Field('child_gender'), css_class="col-md-2"), Div(Field('child_name'), css_class="col-md-10"), Div(Field('child_birthday', css_class="datepicker", input_formats=(settings.DATE_INPUT_FORMATS)), css_class="col-md-4"), Div(Field('child_email'), css_class="col-md-4"), Div(Field('child_phone'), css_class="col-md-4"), css_class="row")), Fieldset( 'Forældres oplysninger', Div(Div(Field('parent_name'), css_class="col-md-12"), Div(Field('parent_email'), css_class="col-md-6"), Div(Field('parent_phone'), css_class="col-md-6"), css_class="row")), Fieldset( 'Adresse oplysninger', Div(Div(Field('search_address', id="search-address"), css_class="col-md-10"), Div(Field('manual_entry', id="manual-entry"), css_class="col-md-2"), Div(Field('streetname', readonly=True, css_class="autofilled-address"), css_class="col-md-9"), Div(Field('housenumber', readonly=True, css_class="autofilled-address"), css_class="col-md-1"), Div(Field('floor', readonly=True, css_class="autofilled-address"), css_class="col-md-1"), Div(Field('door', readonly=True, css_class="autofilled-address"), css_class="col-md-1"), Div(Field('zipcode', readonly=True, css_class="autofilled-address"), css_class="col-md-2"), Div(Field('city', readonly=True, css_class="autofilled-address"), css_class="col-md-5"), Div(Field('placename', readonly=True, css_class="autofilled-address"), css_class="col-md-5"), Hidden('dawa_id', '', id="id_dawa_id"), css_class="row")), Submit('submit', 'Opret', css_class="btn-success"))
def __init__(self, *args, **kwargs): super(CompareForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.layout = Layout( Row(HTML("""<h3> First Group</h3>""")), Div( #Fieldset( Field('fluid', wrapper_class='col-md-2', css_class='form-control'), Field('sex', wrapper_class='col-md-2', css_class='form-control'), Field('healthy', wrapper_class='col-md-2', css_class='form-control'), Field('extraction', wrapper_class='col-md-2', css_class='form-control'), Field('library', wrapper_class='col-md-2', css_class='form-control'), Field('exosome', wrapper_class='col-md-2', css_class='form-control'), css_class='form-row'), Row(HTML("""<h3> Second Group</h3>""")), Div( # Fieldset( Field('fluid2', wrapper_class='col-md-2', css_class='form-control'), Field('sex2', wrapper_class='col-md-2', css_class='form-control'), Field('healthy2', wrapper_class='col-md-2', css_class='form-control'), Field('extraction2', wrapper_class='col-md-2', css_class='form-control'), Field('library2', wrapper_class='col-md-2', css_class='form-control'), Field('exosome2', wrapper_class='col-md-2', css_class='form-control'), Field('RCfilter', wrapper_class='col-md-2', css_class='form-control'), ButtonHolder( # Submit('submit', 'RUN', css_class='btn btn-primary', onclick="alert('Neat!'); return true") Submit( 'submit', 'COMPARE', onclick= "$('#loadpage').show(); $('#divPageContent').hide();", css_class='btn btn-primary btn-form') # onsubmit="alert('Neat!'); return false") ), # ButtonHolder( # # Submit('submit', 'RUN', css_class='btn btn-primary', onclick="alert('Neat!'); return true") # Submit('submit', 'FILTER', onclick="$('#loadpage').show(); $('#divPageContent').hide();", # css_class='btn btn-primary btn-form') # # onsubmit="alert('Neat!'); return false") # ), css_class='form-row'))
def __init__(self, *args, **kwargs): """Add crispyform helper to form.""" super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit('submit', 'Send email'))
class ProgramManagerProfileForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(ProgramManagerProfileForm, self).__init__(*args, **kwargs) self.fields['full_names'].label = "Full names" self.fields['phone'].label = "Mobile contact" self.fields['summary'].label = "Please provide a summary about your educational, professional and" \ " entrepreneurial experience" full_names = forms.CharField() phone_regex = RegexValidator( regex=r'^\+?1?\d{9,15}$', message="Phone number must be entered in the format:" " '+256 XXX XXX'. Up to 15 digits allowed.") phone = forms.CharField( validators=[phone_regex], widget=forms.TextInput(attrs={ 'class': "", 'placeholder': '+256 XXX XXX' })) country = forms.CharField(max_length=20) picture = forms.ImageField(required=False, validators=[validate_img]) resume = forms.FileField(validators=[validate_doc], required=False) linkedin = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) twitter = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) blog = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) facebook = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) website = forms.CharField( required=False, widget=forms.URLInput(attrs={'placeholder': "http://example.com"})) summary = forms.CharField(widget=forms.Textarea(attrs={'class': ""})) gender = forms.ChoiceField( choices=(('male', "Male"), ('female', "Female")), widget=forms.RadioSelect, initial='female', ) helper = FormHelper() helper.form_method = 'post' helper.form_class = 'form-horizontal' helper.layout = Layout( Field('full_names', css_class='text-small'), Field('gender'), Field('age', css_class='sign_text'), Field('phone', css_class='text-small'), Field('country', css_class='text-small'), Field('expertise', rows="3", css_class='text-large'), Field('picture', css_class='file-upload'), Field('resume', css_class='file-upload'), Field('linkedin', css_class='text-small'), Field('facebook', css_class='text-small'), Field('twitter', css_class='text-small'), Field('blog', css_class='text-small'), Field('website', css_class='text-small'), FormActions( HTML( '<a class="cancelBtn btn btn-primary" href={% url "index:home" %}>Cancel</a>' ), Submit('next', 'Save', css_class="cancelBtn")), ) class Meta: model = ProgramManager fields = ('gender', 'phone', 'country', 'summary', 'picture', 'resume', 'linkedin', 'twitter', 'blog', 'website', 'full_names', 'age')