コード例 #1
0
    def __init__(self, *args, **kwargs):
        super(PropertySearchForm, self).__init__(*args, **kwargs)
        self.fields['searchArea'].widget = HiddenInput()
        self.helper = FormHelper()
        self.helper.form_id = 'PropertySearchForm'
        self.helper.form_class = 'form-horizontal'
        self.helper.label_class = 'col-lg-3'
        self.helper.field_class = 'col-lg-8'
        self.helper.render_unmentioned_fields = False

        self.helper.form_method = 'get'
        self.helper.form_action = ''
        self.helper.layout = Layout(
            Fieldset(
                'Search',
                HTML(
                    '<input type="checkbox" onclick="toggleDraw(this);" name="searchPolygon" value="polygon">Draw search area on map</input>'
                ),
                #Field('parcel'),
                Field('streetAddress'),
                Field('status'),
            ),
            Fieldset(
                '',
                HTML(
                    '<a href="javascript:void(0);" class="btn btn-default" id="searchToggle" role="button">Show more search options >>></a><br/>'
                )),
            Fieldset('',
                     Field('nsp'),
                     Field('structureType'),
                     Field('cdc'),
                     Field('zone'),
                     Field('zipcode'),
                     Field('sidelot_eligible'),
                     Field('homestead_only'),
                     Field('bep_demolition'),
                     Field('renew_owned'),
                     Field('price_obo'),
                     css_class='moreSearchOptions'),
            FormActions(
                #Button('cancel', 'Reset'),
                Submit('save', 'Search')))
コード例 #2
0
ファイル: forms.py プロジェクト: ocwc/ocwc-members
    def __init__(self, *args, **kwargs):
        self.election = kwargs.pop("election")
        super(VoteForm, self).__init__(*args, **kwargs)

        self.fields["institutional_candidates"].choices = [
            (i.id, i) for i in self.election.candidate_set.filter(
                vetted=True, seat_type="institutional").order_by("order")
        ]

        self.helper = FormHelper(self)
        self.helper.form_show_errors = True

        propositions = self.election.proposition_set.filter(
            published=True).order_by("title")
        # proposition1 = propositions[0]
        # proposition2 = propositions[1]
        # proposition3 = propositions[2]
        # proposition4 = propositions[3]
        # proposition5 = propositions[4]
        # proposition6 = propositions[5]

        self.helper.layout = Layout(
            Div(HTML("<h2>2020 Open Education Global Elections</h2>"),
                css_class="row"),
            # Div(
            #     HTML('<div class="large-8 columns">Please see the background information on the Proposed bylaws changes for an explanation of these proposed changes, and then vote on each issue below. <br /></br ><a target="_blank" style="font-weight: bold;" href="https://docs.google.com/document/d/1Hszn22Iu5GTtEalvRDpVNDOTYOfoO6DA8vFhYP-kWyo/edit">Click here for background information</a>.<br /><br /></div>'),
            #     css_class='row'
            # ),
            Div(HTML("<p>Fields marked with * are mandatory</p>"),
                css_class="row"),
            # Div(
            #     HTML("<h4>%s</h4>" % proposition1.title),
            #     HTML("<p>%s</p>" % proposition1.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote1'),
            #     css_class='row'),
            #
            # Div(
            #     HTML("<h4>%s</h4>" % proposition2.title),
            #     HTML("<p>%s</p>" % proposition2.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote2'),
            #     css_class='row'),
            #
            # Div(
            #     HTML("<h4>%s</h4>" % proposition3.title),
            #     HTML("<p>%s</p>" % proposition3.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote3'),
            #     css_class='row'),
            #
            # Div(
            #     HTML("<h4>%s</h4>" % proposition4.title),
            #     HTML("<p>%s</p>" % proposition4.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote4'),
            #     css_class='row'),
            #
            # Div(
            #     HTML("<h4>%s</h4>" % proposition5.title),
            #     HTML("<p>%s</p>" % proposition5.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote5'),
            #     css_class='row'),
            #
            # Div(
            #     HTML("<h4>%s</h4>" % proposition6.title),
            #     HTML("<p>%s</p>" % proposition6.description),
            #     css_class='row'),
            # Div(
            #     Field('proposition_vote6'),
            #     css_class='row'),
            Div(
                HTML(
                    "<p>Open Education Global by-laws require us to have 10 Board of Directors chosen by members. This year we need to "
                    "elect 5 new Board members. To ensure we get the necessary 5 new Board members we ask OEG members to cast all 5 "
                    "votes. This will also help ensure we get a diverse and inclusive Board with representation from around the world. <br /><br />To "
                    "inform your decision making about who to vote for we invite you to review the information about each candidate "
                    'at <a href="https://www.oeglobal.org/about-us/elections/" target="_blank">https://www.oeglobal.org/about-us/elections/</a></p>'
                ),
                css_class="row",
            ),
            Div(Field("institutional_candidates"), css_class="row"),
            # Div(
            #     Field('organizational_candidates'),
            #     css_class='row'),
            Div(Field("name"), css_class="row"),
        )
        self.helper.layout.append(Submit("submit", "Submit"))
コード例 #3
0
 def __init__(self, *args, **kwargs):
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Field('nome'), Field('note'), Field('escludi_stat'),
         FormActions(Submit('save', 'Invia', css_class="btn-primary")))
     super(GruppoForm, self).__init__(*args, **kwargs)
コード例 #4
0
ファイル: forms.py プロジェクト: jamesggraf/kegbot-server
class BreweryDbLookupForm(forms.ModelForm):
    class Meta:
        model = models.Beverage
        fields = ('name', 'style', 'producer', 'vintage_year', 'abv_percent',
                  'original_gravity', 'specific_gravity', 'ibu', 'srm',
                  'color_hex', 'star_rating', 'untappd_beer_id', 'description')

    brewery_db_image_url = forms.Field(
        required=False, help_text='URL to an image for this beer type.')

    brewer_name = forms.CharField(label='Brewer Name', required=True)
    brewer_state = forms.CharField(label='Brewer State', required=False)
    brewer_city = forms.CharField(label='Brewer City', required=False)
    brewer_url = forms.CharField(label='Brewer URL', required=False)
    brewer_description = forms.CharField(label='Brewer Description',
                                         required=False)

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Field('name', required=True), Field('style'),
        Field('producer_name', type='hidden'),
        Field('vintage_year', type='hidden'), Field('abv_percent'),
        Field('original_gravity'), Field('specific_gravity'), Field('ibu'),
        Field('srm'), Field('color_hex', type='hidden'),
        Field('star_rating', type='hidden'),
        Field('untappd_beer_id', type='hidden'), Field('description'),
        Field('producer', type='hidden'),
        Field('brewery_db_image_url', css_class='input-xlarge'),
        Field('brewer_name'), Field('brewer_state'), Field('brewer_city'),
        Field('brewer_url', css_class='input-xlarge'),
        Field('brewer_description'),
        FormActions(Submit('submit', 'Save', css_class='btn-primary'), ))
コード例 #5
0
ファイル: forms_project.py プロジェクト: tmcmil/Ghostwriter
 def __init__(self, *args, **kwargs):
     super(ProjectObjectiveForm, self).__init__(*args, **kwargs)
     self.fields["deadline"].widget.attrs["placeholder"] = "mm/dd/yyyy"
     self.fields["deadline"].widget.attrs["autocomplete"] = "off"
     self.fields["deadline"].widget.input_type = "date"
     self.fields["objective"].widget.attrs[
         "placeholder"] = "Obtain commit privileges to git"
     self.helper = FormHelper()
     # Disable the <form> tags because this will be inside an instance of `ProjectForm()`
     self.helper.form_tag = False
     # Disable CSRF so `csrfmiddlewaretoken` is not rendered multiple times
     self.helper.disable_csrf = True
     # Hide the field labels from the model
     self.helper.form_show_labels = False
     # Layout the form for Bootstrap
     self.helper.layout = Layout(
         # Wrap form in a div so Django renders form instances in their own element
         Div(
             # These Bootstrap alerts begin hidden and function as undo buttons for deleted forms
             Alert(
                 content=("""
                     <strong>Objective Deleted!</strong>
                     Deletion will be permanent once the form is submitted. Click this alert to undo.
                     """),
                 css_class="alert alert-danger show formset-undo-button",
                 style="display:none; cursor:pointer;",
                 template="alert.html",
                 block=False,
                 dismiss=False,
             ),
             Div(
                 HTML("""
                     <p><strong>Objective #<span class="counter">{{ forloop.counter }}</span></strong></p>
                     <hr>
                     """),
                 Row(
                     Column(
                         FieldWithButtons(
                             "deadline",
                             HTML("""
                                 <button
                                     class="btn btn-secondary"
                                     type="button"
                                     onclick="copyEndDate($(this).closest('div').find('input'))"
                                 >
                                 Copy
                                 </button>
                                 """),
                         ),
                         css_class="form-group col-md-6 mb-0",
                     ),
                     css_class="form-row",
                 ),
                 "objective",
                 Row(
                     Column(
                         Field("DELETE", style="display: none;"),
                         Button(
                             "formset-del-button",
                             "Delete Objective",
                             css_class=
                             "btn-sm btn-danger formset-del-button",
                         ),
                         css_class="form-group col-md-12 text-center",
                     ),
                     css_class="form-row",
                 ),
                 HTML("""
                     <p class="form-spacer"></p>
                     """),
                 css_class="formset",
             ),
             css_class="formset-container",
         ))
コード例 #6
0
ファイル: forms.py プロジェクト: tanveerahmad1517/cmj
    def __init__(self, *args, **kwargs):
        yaml_layout = kwargs.pop('yaml_layout')

        q_field = Div(
            FieldWithButtons(
                Field('q',
                      placeholder=_('Filtrar Lista'),
                      autocomplete='off',
                      type='search',
                      onkeypress='atualizaContatos(event)'),
                StrictButton(_('Filtrar'),
                             css_class='btn-default',
                             type='button',
                             onclick='atualizaContatos(event)')),
            Div(css_class='form-group-contato-search '
                'controls-radio-checkbox'))

        q = [
            _('Seleção de Contatos'),
            [(q_field, 5),
             (Div(Field('contatos'), css_class='form-group-contatos'), 7)]
        ]
        yaml_layout.append(q)

        for fieldset in yaml_layout:
            for linha in fieldset:
                for idx, field in enumerate(linha):
                    if field[0] == 'importancia':
                        linha[idx] = (InlineRadios('importancia'), field[1])

        self.helper = FormHelper()

        self.helper.field_class = 'controls'
        self.helper.layout = SaplFormLayout(*yaml_layout)

        super(ProcessoForm, self).__init__(*args, **kwargs)

        if not self.instance.pk:
            self.fields['data'].initial = date.today()

        self.fields['q'].help_text = _('Digite parte do nome, nome social ou '
                                       'apelido do Contato que você procura.')

        self.fields['topicos'].widget = forms.SelectMultiple(
            attrs={'size': '8'})
        self.fields['topicos'].queryset = TopicoProcesso.objects.all()

        self.fields['assuntos'].widget = forms.SelectMultiple(
            attrs={'size': '8'})
        self.fields['assuntos'].queryset = AssuntoProcesso.objects.filter(
            workspace=self.initial['workspace'])

        # Utilizando template bootstrap3 customizado
        self.fields['importancia'].widget = forms.RadioSelect()
        self.fields['importancia'].choices = IMPORTANCIA_CHOICE

        self.fields['status'].widget = forms.RadioSelect()
        # self.fields['status'].inline_class = True
        self.fields['status'].choices = [
            (ass.pk, ass) for ass in StatusProcesso.objects.order_by('id')
        ]

        self.fields['classificacoes'].widget = forms.CheckboxSelectMultiple()
        # self.fields['classificacoes'].inline_class = True

        self.fields['contatos'].widget = forms.CheckboxSelectMultiple()
        self.fields['contatos'].queryset = Contato.objects.all()
        self.fields['contatos'].choices = [
            (c.pk, c) for c in self.instance.contatos.order_by('nome')]\
            if self.instance.pk else []
        self.fields['contatos'].help_text = _(
            'Procure por Contatos na caixa de buscas e arraste '
            'para esta caixa os Contatos interessados neste Processo.')
コード例 #7
0
ファイル: forms.py プロジェクト: jamesggraf/kegbot-server
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()
コード例 #8
0
ファイル: forms.py プロジェクト: gavchan/cmsman
    def __init__(self, *args, **kwargs):
        self.item_obj = kwargs.pop('item_obj', None)
        self.drug_obj = kwargs.pop('drug_obj', None)
        self.set_match_drug = kwargs.pop('set_match_drug', None)
        self.next_url = kwargs.pop('next_url', '')
        super(InventoryItemQuickEditModalForm, self).__init__(*args, **kwargs)
        
        self.helper = FormHelper()
        self.helper.render_unmentioned_fields = False
        self.helper.form_id = 'id-InventoryItemQuickEditModalForm'
        self.helper.form_class = 'cmmForms'
        self.helper.form_method = 'post'
        next_url = "%s?next=%s" % (
            reverse('cmsinv:InventoryItemQuickEditModal', args=(self.item_obj.pk, )),
            self.next_url
            )
        self.helper.form_action = next_url
        self.initial['version'] = 1
        if self.set_match_drug and self.drug_obj:
            # print(f"{self.item_obj.registration_no} set to {self.drug_obj.reg_no}")
            self.initial['registration_no'] = self.drug_obj.reg_no

        self.helper.layout = Layout(
            Row(
                Column('discontinue', css_class='form-group col-sm-4'),
                Column('is_master_drug_list', css_class='form-group col-sm-4'),
                Column('is_clinic_drug_list', css_class='form-group col-sm-4'),
                css_class='form-row mb-0',
            ),
            Row(
                Column('inventory_type', css_class='form-group col-sm-2'),
                Column('alias', css_class='form-group col-sm-6'),
                Column('registration_no', css_class='form-group col-sm-2'),
                Column('clinic_drug_no', css_class='form-group col-sm-2'),
                css_class='form-row mb-0',
            ),
            Row(
                Column(
                    StrictButton('RegDrug <i class="fad fa-arrow-circle-right"></i>', css_class="btn_update_product btn-sm btn-secondary"), 
                    css_class="form-group col-sm-2 mb-0"
                    ),
                Column('product_name', css_class='form-group col-sm-8 mb-0'),
                Column('unit', css_class='form-group col-sm-2'),
                css_class='form-row mb-0',
            ),
            Row(
                Column(
                    StrictButton('RegDrug <i class="fad fa-arrow-circle-right"></i>', css_class="btn_update_label btn-sm btn-secondary"),
                    css_class="form-group col-sm-2 mb-0"
                ),
                Column('label_name', css_class='form-group col-sm-8 mb-0'),
                Column('unit_price', css_class='form-group col-sm-2'),
                css_class='form-row',
            ),
            Row(
                Column(
                    StrictButton('RegDrug <i class="fad fa-arrow-circle-right"></i>', css_class="btn_update_generic btn-sm btn-secondary"),
                    css_class="form-group col-sm-2 mb-0"
                ),
                Column('generic_name', css_class='form-group col-sm-10 mb-0'),
                css_class='form-row',
            ),
            Row(
                Column(
                    StrictButton('RegDrug <i class="fad fa-arrow-circle-right"></i>', css_class="btn_update_ingredient btn-sm btn-secondary"),
                    css_class="form-group col-sm-2 mb-0"
                ),
                Column(
                    Field('ingredient', css_class='form-group col-md-10 mb-0', rows="2"),
                ),
                css_class='form-row'
            ),
            Hidden('last_updated', timezone.now()),
            Hidden('version', self.instance.version + 1),
            FormActions(
                Submit('submit', 'Submit' ),
                HTML("""
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                """)
            ),
        )
コード例 #9
0
class NewVMForm(forms.Form):
    def __init__(self, *args, **kwargs):
        user = kwargs.pop("user", None)
        super(NewVMForm, self).__init__(*args, **kwargs)
        self.fields.get("vmgroup").queryset = Group.objects.filter(user=user)

    vmname = forms.CharField(label=_('VM name'), max_length=100)
    vmos = forms.ModelChoiceField(label=_('Operating System'), queryset=OS.objects.all().order_by('os_family', 'os_version'), empty_label=_('Please select one'))
    vmgroup = forms.ModelChoiceField(label=_('Assign to group'), queryset=Group.objects.all(), empty_label=_('None'), required=False)
    cpus = forms.ChoiceField(label=_('CPUs'), choices=(enumerate(range(1, 9), 1)))
    mem = forms.ChoiceField(label=_('RAM'), choices=(enumerate([str(x) + ' GB' for x in range(1, 128)], 1)))
    hdd = forms.IntegerField(label=_('Storage in GB'), initial=20)
    ipaddress = forms.GenericIPAddressField(label=_('IP address'), required=False)
    vmuser = forms.CharField(label=_('OS user'), initial='administrator')
    vmpswd = forms.CharField(label=_('Password for OS user'), initial='changeme')
    observations = forms.CharField(label=_('Observations'), widget=forms.Textarea(), required=False)
    location = forms.ModelChoiceField(label=_('Prefered location'), required=False, queryset=Location.objects.all(), empty_label=_('Please select one'))
    environment = forms.ModelChoiceField(label=_('Environment'), required=False, queryset=Environment.objects.all(), empty_label=_('Please select one'))
    helper = FormHelper()
    helper.form_method = 'POST'
    helper.attrs = {'class': 'ui form'}
    helper.layout = Layout(
        HTML('<h4 class="ui dividing header">' + str(_('VM characteristics')) + '</h4>'),
        Div(Field('vmname'), css_class='field'),
        Div(
            Div(Field('vmos', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('cpus', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('mem', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('hdd', css_class="ui selection number"), css_class='field'),
            css_class='ui inline equal width fields',
        ),
        HTML('<h4 class="ui dividing header">' + str(_('Additional Configuration')) + '</h4>'),
        Div(
            Div(Field('vmgroup', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('ipaddress', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('vmuser', css_class="ui selection fluid dropdown"), css_class='field'),
            Div(Field('vmpswd', css_class="ui selection fluid dropdown"), css_class='field'),
            css_class='ui inline equal width fields',
        ),
        HTML('<h4 class="ui dividing header">' + str(_('Speacial options')) + '</h4>'),
        Div(
            Div(Field('environment', css_class='ui selection fluid dropdown'), css_class='field'),
            Div(Field('location', css_class='ui selection fluid dropdown'), css_class='field'),
            css_class='ui inline equal width fields',
        ),
        Div(Field('observations'), css_class='field'),
        Submit('save_changes', _('Send VM creation request'), css_class="ui positive button")
    )
コード例 #10
0
ファイル: forms.py プロジェクト: gavchan/cmsman
 def __init__(self, *args, **kwargs):
     self.regdrug_obj = kwargs.pop('regdrug_obj', None)
     self.vendor_obj = kwargs.pop('vendor_obj', None)
     super(NewInventoryItemForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.render_unmentioned_fields = False
     self.helper.form_id = 'id-InventoryItemForm'
     self.helper.form_class = 'cmmForms'
     self.helper.form_method = 'post'
     if self.regdrug_obj:
         url_with_query = "%s?reg_no=%s" % (
             reverse('cmsinv:NewInventoryItem', None),
             self.regdrug_obj.reg_no 
         )
     elif self.vendor_obj:
         url_with_query = "%s?vendor=%s" % (
             reverse('cmsinv:NewInventoryItem', None),
             self.vendor_obj.id
         )
     else:
         url_with_query = reverse('cmsinv:NewInventoryItem')
     print(url_with_query)
     self.helper.form_action = url_with_query
     self.initial['version'] = 0
     # self.initial['inventory_item_type'] = 1
     self.initial['inventory_type'] = 'Drug'
     self.initial['is_clinic_drug_list'] = True
     self.initial['is_master_drug_list'] = True
     self.initial['clinic_drug_no'] = InventoryItem.generateNextClinicDrugNo()
     if self.regdrug_obj:
         self.initial['product_name'] = self.regdrug_obj.name
         self.initial['label_name'] = self.regdrug_obj.name
         self.drug_reg_no = self.regdrug_obj.reg_no
         self.initial['registration_no'] = self.drug_reg_no
         self.initial['generic_name'] = self.regdrug_obj.gen_generic
         self.initial['ingredient'] = self.regdrug_obj.ingredients_list
     else:
         self.drug_reg_no = ''
     self.helper.layout = Layout(
         Row(
             Column('alias', css_class='form-group col-sm-4'),
             HTML("""
                 <div class="form-group col-sm-4 pb-1 mb-0">
                     <div class="pb-1 mb-1">Registration no</div>
                     <div id="id_registration_no" 
                          class="alert alert-secondary pt-2 pb-2" 
                         data-value="{{ regdrug_obj.name }}">
                         {{ regdrug_obj.reg_no }}&nbsp;
                     </div>
                 </div>
             """),
             # Column('registration_no', css_class='form-group col-sm-4'),
             Column('clinic_drug_no', css_class='form-group col-sm-4'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('product_name', css_class='form-group col-md-4 col-sm-6'),
             Column('product_name_chinese', css_class='form-group col-md-4 col-sm-3'),
             # Column(UneditableField('inventory_item_type'), css_class='form-group col-md-4 col-sm-3'),
             # Column('certificate_holder', css_class='form-group col-md-4 col-sm-4'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('label_name', css_class='form-group col-md-4 col-sm-6'),
             Column('label_name_chinese', css_class='form-group col-md-4 col-sm-3'),
             Column('inventory_type', css_class='form-group col-md-4 col-sm-3'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('generic_name', css_class='form-group col-md-4 col-sm-6'),
             Column('generic_name_chinese', css_class='form-group col-sm-4'),
             Column(
                 Row('discontinue'),
                 Row('is_clinic_drug_list'),
                 css_class='form-group col-sm-4'
             ),
             css_class='form-row mb-0',
         ),
         Row(
             Column(Field('ingredient', css_class='form-group col-sm-8', rows="1")),
             Column(
                 Row('is_master_drug_list'),
                 Row('dangerous_sign'),
                 css_class='form-group col-sm-4'
             ),
             css_class='form-row mb-0',
         ),
         Row(
             Column('standard_cost', css_class='form-group col-sm-3'),
             Column('avg_cost', css_class='form-group, col-sm-3'),
             Column('unit_price', css_class='form-group col-sm-3'),
             Column('location', css_class='form-group col-sm-3'),
             css_class='form-row mb-0',
         ),
         Row(
              HTML("""
                 <div class="form-group col-sm-3 pb-1 mb-0">
                     <div class="pb-1 mb-1">Stock Qty</div>
                     <div id="id_stock_qty" 
                          class="alert alert-secondary pt-2 pb-2" 
                         data-value="0">
                         0
                     </div>
                 </div>
             """),
             Column('expected_qty', css_class='form-group col-sm-3'),
             Column('reorder_level', css_class='form-group col-sm-3'),
             Column('priority', css_class='form-group col-sm-3'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('dosage', css_class='form-group col-sm-3'),
             Column('unit', css_class='form-group col-sm-3'),
             Column('frequency', css_class='form-group col-sm-3'),
             Column('duration', css_class='form-group col-sm-3'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('instruction', css_class='form-group col-sm-6 mb-0'),
             Column('advisory', css_class='form-group col-sm-6 mb-0'),
             css_class='form-row mb-0',
         ),
         Row(
             Column(Field('remarks', css_class='form-horizontal col-md-6', rows="1")),
             Column('mini_dosage_unit', css_class='form-group col-sm-3'),
             Column('mini_dispensary_unit', css_class='form-group col-sm-3'),
             css_class='form-row mb-0',
         ),
         FormActions(
             Submit('submit', 'Submit'),
             Button(
                 'back', 'Cancel',
                 css_class='btn-light',
                 onclick="javascript:history.go(-1);"
             )
         ),
     )
コード例 #11
0
ファイル: forms.py プロジェクト: gavchan/cmsman
 def __init__(self, *args, **kwargs):
     super(InventoryItemUpdateForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.render_unmentioned_fields = False
     self.helper.form_id = 'id-InventoryItemForm'
     self.helper.form_class = 'cmmForms'
     self.helper.form_method = 'post'
     self.helper.form_action = reverse('cmsinv:InventoryItemUpdate', args=(self.instance.pk,))
     self.helper.layout = Layout(
         Row(
             Column('alias', css_class='form-group col-sm-4'),
             Column('registration_no', css_class='form-group col-sm-4'),
             Column('clinic_drug_no', css_class='form-group col-sm-4'),
             css_class='mb-0',
         ),
         Row(
             Column('product_name', css_class='form-group col-md-4 col-sm-6'),
             Column('product_name_chinese', css_class='form-group col-md-4 col-sm-3'),
             # Column(UneditableField('inventory_item_type'), css_class='form-group col-md-4 col-sm-3'),
             Column('certificate_holder', css_class='form-group col-md-4 col-sm-4'),
             css_class='mb-0',
         ),
         Row(
             Column('label_name', css_class='form-group col-md-4 col-sm-6'),
             Column('label_name_chinese', css_class='form-group col-md-4 col-sm-3'),
             Column('inventory_type', css_class='form-group col-md-4 col-sm-3'),
             css_class='mb-0',
         ),
         Row(
             Column('generic_name', css_class='form-group col-md-4 col-sm-6'),
             Column('generic_name_chinese', css_class='form-group col-sm-4'),
             Column(
                 Row('discontinue'),
                 Row('is_clinic_drug_list'),
                 css_class='form-group col-sm-4'
             ),
             css_class='form-row mb-0',
         ),
         Row(
             Column(Field('ingredient', css_class='form-group col-sm-8', rows="1")),
             Column(
                 Row('is_master_drug_list'),
                 Row('dangerous_sign'),
                 css_class='form-group col-sm-4'
             ),
             css_class='mb-0',
         ),
         Row(
             Column('standard_cost', css_class='form-group col-sm-3'),
             Column('avg_cost', css_class='form-group, col-sm-3'),
             Column('unit_price', css_class='form-group col-sm-3'),
             Column('location', css_class='form-group col-sm-3'),
             css_class='mb-0',
         ),
         Row(
             HTML("""
                 <div class="form-group col-sm-3 pb-1 mb-0">
                     <div class="pb-1 mb-1">Stock Qty</div>
                     <div id="id_stock_qty" 
                          class="alert alert-secondary pt-2 pb-2"
                          data-value="{{ item_obj.stock_qty }}">
                          {{ item_obj.stock_qty }}
                     </div>
                 </div>
             """),
             Column('expected_qty', css_class='form-group col-sm-3'),
             Column('reorder_level', css_class='form-group col-sm-3'),
             Column('priority', css_class='form-group col-sm-3'),
             css_class='form-row mb-0',
         ),
         Row(
             Column('dosage', css_class='form-group col-sm-3'),
             Column('unit', css_class='form-group col-sm-3'),
             Column('frequency', css_class='form-group col-sm-3'),
             Column('duration', css_class='form-group col-sm-3'),
             css_class='mb-0',
         ),
         Row(
             Column('instruction', css_class='form-group col-sm-6 mb-0'),
             Column('advisory', css_class='form-group col-sm-6 mb-0'),
             css_class='mb-0',
         ),
         Row(
             Column(Field('remarks', css_class='form-horizontal col-md-6', rows="1")),
             Column('mini_dosage_unit', css_class='form-group col-sm-3'),
             Column('mini_dispensary_unit', css_class='form-group col-sm-3'),
             css_class='mb-0',
         ),
         FormActions(
             Submit('submit', 'Submit'),
             Button(
                 'back', 'Cancel',
                 css_class='btn-light',
                 onclick="javascript:history.go(-1);"
             )
         ),
     )
コード例 #12
0
def create_sale_form(performance, sale, post_data = None):

    # Validate parameters
    assert performance
    assert is_next(performance)
    assert performance.has_open_checkpoint
    assert not performance.has_close_checkpoint
    assert sale

    # Get initial values from sale
    initial_data = {
        'buttons': sale.buttons,
        'fringers': sale.fringers.count(),
    }

    # Get ticket types and add initial values
    ticket_types = []
    for ticket_type in sale.festival.ticket_types.order_by('seqno'):
        ticket_types.append(ticket_type)
        initial_data[SaleForm.ticket_field_name(ticket_type)] = sale.tickets.filter(description = ticket_type.name).count()

    # Get eFringers and add initial values
    efringers = []
    efringers_in_sale = []
    if sale.customer_user:
        for fringer in sale.customer_user.fringers.order_by('name'):
            efringers.append(fringer)
            if sale.tickets.filter(fringer = fringer).exists():
                efringers_in_sale.append(fringer)
                initial_data[SaleForm.efringer_field_name(fringer)] = True

    # Get volunteer complimentary tickets details
    volunteer = sale.customer_user.volunteer if sale.customer_user and sale.customer_user.is_volunteer else None
    if volunteer:
        volunteer_earned = volunteer.comps_earned
        volunteer_used = volunteer.comps_used
        volunteer_available = volunteer.comps_available
        initial_data['volunteer'] = sale.tickets.filter(user = volunteer.user, description = 'Volunteer').exists()

    # Create form
    form = SaleForm(ticket_types, efringers, data = post_data, initial = initial_data)

    # Add crispy form helper
    form.helper = FormHelper()
    form.helper.form_id = 'sale-form'
    form.helper.form_class = 'form-horizontal'
    form.helper.label_class = 'col-6'
    form.helper.field_class = 'col-6'
    tabs = [Tab('Tickets', *(Field(form.ticket_field_name(tt)) for tt in form.ticket_types), css_class = 'pt-2')]
    if sale.customer_user:
        tab_content = []
        if form.efringers:
            fringers_available = []
            fringers_used = []
            fringers_empty = []
            for fringer in form.efringers:
                if fringer in efringers_in_sale or fringer.is_available(performance):
                    fringers_available.append(fringer)
                else:
                    form.fields[SaleForm.efringer_field_name(fringer)].disabled = True
                    if fringer.is_available():
                        fringers_used.append(fringer)
                    else:
                        fringers_empty.append(fringer)
            if fringers_available:
                tab_content.append(HTML("<p>Available for this performance.</p>"))
                tab_content.extend(Field(form.efringer_field_name(ef)) for ef in fringers_available)
            if fringers_used:
                tab_content.append(HTML("<p>Already used for this performance.</p>"))
                tab_content.extend(Field(form.efringer_field_name(ef)) for ef in fringers_used)
            if fringers_empty:
                tab_content.append(HTML("<p>No tickets remaining.</p>"))
                tab_content.extend(Field(form.efringer_field_name(ef)) for ef in fringers_empty)
        else:
            tab_content.append(HTML("<p>None.</p>"))
        tabs.append(Tab(
            'eFringers',
            *tab_content,
            css_class = 'pt-2',
        ))
    if volunteer:
        status = f"Used {volunteer_used} of {volunteer_earned} volunteer tickets."
        if volunteer_available > 0:
            tabs.append(Tab('Volunteer', HTML(f"<p>{status}<p>"), Field('volunteer'), css_class = 'pt-2'))
        else:
            tabs.append(Tab('Volunteer', HTML(f"<p>{status}<p>"), css_class = 'pt-2'))
    tabs.append(Tab('Other', 'buttons', 'fringers', css_class = 'pt-2'))
    form.helper.layout = Layout(
        TabHolder(*tabs),
        Button('update', 'Update', css_class = 'btn-primary',  onclick = f"saleUpdate()"),
    )

    # Return form
    return form
コード例 #13
0
ファイル: forms.py プロジェクト: j-benoit/Prayon
    def __init__(self, *args, **kwargs):
        super(UpdatedInfoForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.attrs = {"name": "chronoForm"}
        for field_name, field in self.fields.items():
            self.fields[field_name].widget.attrs["placeholder"] = field_name

        # self.helper.form_show_labels = False
        self.fields["typ"].label = False

        self.fields["old_num"].validators = [
            RegexValidator('[:,!.?;]',
                           message="Merci de supprimer les ponctuations",
                           inverse_match=True)
        ]
        self.fields["num_imp"].validators = [
            RegexValidator('[:,!.?;]',
                           message="Merci de supprimer les ponctuations",
                           inverse_match=True)
        ]
        # self.fields["num_trav"].validators = [
        #     RegexValidator('(\d{1,4})?/(\d{2})?$', message="Merci de renseigner le champ comme ceci : NNNN/NN")]

        # Get comment from Work_data
        record = Work_data.objects.get(id_SAP__pk=self.instance.pk)
        comment = record.comment
        if '[POSTRAIT' in comment:
            liasse = self.instance.num_cadastre[:7]
            record_liasse = ExtractSAP.objects.filter(
                num_cadastre__startswith=liasse)
            self.table_liasse = LiasseTable(record_liasse)
        self.fields["backlog_comment"].initial = comment
        self.fields["chronotime"].initial = record.time_tracking

        # Set visibibilty depending of content
        test_fields = ["poste", "P1", "P2", "P3", "P4", "P5", "P6"]
        for test_field in test_fields:
            if not getattr(record.id_SAP, test_field):
                if test_field == "poste":
                    self.fields["label_Poste"].widget = HiddenInput()
                    self.fields["label_Poste"].label = ""
                else:
                    self.fields["label_" + test_field].widget = HiddenInput()
                    self.fields["label_" + test_field].label = ""
                self.fields[test_field].widget = HiddenInput()
                self.fields[test_field].label = ""

        self.helper.layout = Layout(
            Row(
                Column(css_class="col col-md-1 mb-0", ),
                Column(
                    Row(
                        Column(
                            Field(
                                "site",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-label-group col-md-3 mb-0",
                        ),
                        Column(
                            Field(
                                "div",
                                template="trackdrawing/custom_inputs.html",
                                # readonly=True,
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        Column(
                            Field(
                                "num_cadastre",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "rev_cadastre",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "rev_cadastre", comment),
                                    onclick=
                                    'handleDoubtField(this, "rev_cadastre")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        css_class="form-label-group",
                    ),
                    Row(
                        Column(
                            Row(
                                Column("typ",
                                       required=True,
                                       css_class="col-md-11 mb-0"),
                                Column(
                                    StrictButton(
                                        "?",
                                        # css_class="btn-success" ,
                                        css_class=self.choose_btn_class(
                                            "typ", comment),
                                        name="btn_typ",
                                        onclick='handleDoubtField(this, "typ")',
                                    ),
                                    css_class="col-md-1 mb-0",
                                ),
                            ),
                            css_class="col-md-4 mb-0"),
                        Column(
                            Field("num",
                                  template="trackdrawing/custom_inputs.html"),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        Column(
                            Field(
                                "folio",
                                template="trackdrawing/custom_inputs.html",
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        css_class="form-label-group",
                    ),
                    Row(
                        Column(
                            FieldWithButtons(
                                "title",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "title", comment),
                                    onclick='handleDoubtField(this, "title")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                            ),
                            css_class="col-md-8 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "date",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "date", comment),
                                    onclick='handleDoubtField(this, "date")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "author",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "author", comment),
                                    onclick='handleDoubtField(this, "author")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        css_class="form-label-group",
                    ),
                    Row(
                        Column(
                            FieldWithButtons(
                                "tag",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "tag", comment),
                                    onclick='handleDoubtField(this, "tag")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "fournisseur",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "fournisseur", comment),
                                    onclick=
                                    'handleDoubtField(this, "fournisseur")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "ext_ref",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "ext_ref", comment),
                                    onclick='handleDoubtField(this, "ext_ref")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "old_num",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "old_num", comment),
                                    onclick='handleDoubtField(this, "old_num")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            css_class="form-group col-md-3 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            FieldWithButtons(
                                "num_imp",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "num_imp", comment),
                                    onclick='handleDoubtField(this, "num_imp")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "num_trav",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "num_trav", comment),
                                    onclick=
                                    'handleDoubtField(this, "num_trav")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        Column(
                            FieldWithButtons(
                                "ordre_nv",
                                StrictButton(
                                    "?",
                                    css_class=self.choose_btn_class(
                                        "ordre_nv", comment),
                                    onclick=
                                    'handleDoubtField(this, "ordre_nv")',
                                ),
                                template="trackdrawing/custom_input_btn.html",
                                required=True,
                            ),
                            # Field(
                            #     "file_exists",
                            #     template="trackdrawing/custom_inputs.html",
                            # ),
                            css_class="form-group col-md-4 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "poste",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_Poste",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P1",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P1",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P2",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P2",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P3",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P3",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P4",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P4",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P5",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P5",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(
                            Field(
                                "P6",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-2 mb-0",
                        ),
                        Column(
                            Field(
                                "label_P6",
                                template="trackdrawing/custom_inputs.html",
                                readonly=True,
                            ),
                            css_class="form-group col-md-10 mb-0",
                        ),
                        css_class="form-row",
                    ),
                    Row(
                        Column(StrictButton(
                            "Fichier Illisible",
                            css_class="btn btn-success",
                            onClick="illisible(this)",
                            name="btn_illisible",
                        ),
                               css_class="form-group col-md-3 mb-0"),
                        Column(StrictButton(
                            "Schéma électrique",
                            css_class="btn btn-success",
                            onClick="electrique(this)",
                            name="btn_elec",
                        ),
                               css_class="form-group col-md-3 mb-0"),
                        Column(StrictButton(
                            "Fichier mauvaise qualité",
                            css_class="btn btn-success",
                            onClick="qualite(this)",
                            name="btn_qualite",
                        ),
                               css_class="form-group col-md-3 mb-0"),
                        Column(StrictButton(
                            "Numéro de cadastre",
                            css_class="btn btn-success",
                            onClick="cadastre(this)",
                            name="btn_num_cadatsre",
                        ),
                               css_class="form-group col-md-3 mb-0"),
                        css_class="form-row",
                    ),
                    Row(
                        Column("backlog_comment",
                               css_class="form-group col-md-12 mb-0"),
                        css_class="form-row",
                    ),
                    css_class="col-md-10 mb-0",
                ),
                Column(
                    Field(
                        "chronotime",
                        template="trackdrawing/custom_inputs.html",
                        readonly=True,
                        value="00:00:00",
                    ),
                    css_class="col-md-1 mb-0 display_chrono",
                ),
            ), )

        if self.instance.status in [
                'OPEN', 'CLOSED', 'BACKLOG', 'CHECKED', 'INVALID',
                'TO_RE-CHECK'
        ]:
            self.helper.layout.append(
                Row(
                    Column(css_class="col col-md-1 mb-0", ),
                    Column(
                        Row(
                            Submit("submit", "Submit"),
                            HTML(
                                '<a class="btn btn-success" href={% url "show_image" num_cadastre=form.instance.pk%} target="pdfview" onClick="chronoStart()" id="id_view">View Drawing</a>'
                            ),
                            # StrictButton(
                            #     "Pause timer",
                            #     css_class="btn btn-success",
                            #     onClick="chronoStart()",
                            #     name="startstop",
                            # ),
                            HTML(
                                '<button type="submit" class="btn btn-secondary" name="backlog">'
                                '<i class="fas fa-arrow-alt-circle-right"></i>Backlog'
                                "</button>"),
                            css_class="form-row",
                        ),
                        css_class="col col-md-10 mb-0",
                    ),
                    Column(css_class="col col-md-1 mb-0", ),
                ), )

        if self.instance.status in ['TO_RE-CHECK'
                                    ] and self.Can_Valid_Liasse(record_liasse):
            self.helper.layout.append(
                Row(
                    Column(css_class="col col-md-1 mb-0", ),
                    Column(
                        HTML('<br>'),
                        HTML(
                            '<button type="submit" class="btn btn-secondary" name="validateAll" style="width: 100%">'
                            '<i class="fas fa-arrow-alt-circle-right"></i>Validate All Drawings'
                            "</button>"),
                        css_class="col col-md-10 mb-0",
                    ),
                    Column(css_class="col col-md-1 mb-0", ),
                ), )
コード例 #14
0
class ConceptingForm1(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super(ConceptingForm1, self).__init__(*args, **kwargs)
        self.fields['name'].label = "Idea name"
        self.fields['description'].label = "Please describe your idea"
        self.fields['sectors'].label = "What sectors do you operate in?"
        self.fields[
            'challenge_to_solve'].label = "What challenges or need is your idea trying to solve?"
        self.fields[
            'challenge_faced'].label = "What challenges are you facing?"
        self.fields['other_challenges'].label = ""

    name = forms.CharField(widget=forms.TextInput(attrs={
        'class': "",
        'placeholder': 'name of idea'
    }))
    description = forms.CharField(widget=forms.Textarea())
    sectors = forms.MultipleChoiceField(
        choices=(
            ('agriculture', "Agriculture"),
            ('manufacturing', "Manufacturing and Assembly"),
            ('financial', "Financial Services"),
            ('renewable', "Renewable Energy"),
            ('information security', "Information Security"),
            ('education', "Education"),
            ('health', "Healthcare & Services"),
            ('infrastructure', "Infrastructure"),
            ('transport', "Transport"),
        ),
        widget=forms.CheckboxSelectMultiple,
    )
    other_sectors = forms.CharField(required=False, max_length=2000)
    challenge_to_solve = forms.CharField(widget=forms.Textarea())
    challenge_faced = forms.MultipleChoiceField(
        choices=(
            ('mentorship', "Mentorship"),
            ('office space', "Office Space"),
            ('networking', "To network"),
            ('training', "Training on how to run a business"),
            ('technical', "Technical Training"),
            ('team', "To build a team"),
            ('funding', "Funding"),
            ('others', "Others"),
        ),
        widget=forms.CheckboxSelectMultiple,
    )
    logo = forms.ImageField(validators=[validate_img], required=False)
    other_challenges = forms.CharField(widget=forms.Textarea(), required=False)

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Field('name', css_class='input-length form-control text-small'),
        Field('description',
              rows="3",
              css_class='input-length form-control text-large'),
        InlineCheckboxes('sectors'),
        Field('other_sectors',
              css_class='input-length3 form-control text-small'),
        Field('challenge_to_solve',
              rows="3",
              css_class='input-length form-control text-large'),
        InlineCheckboxes('challenge_faced'),
        Field('other_challenges', css_class='text-small'),
        Field('logo', css_class='file-upload'),
        FormActions(
            Submit('concepting_form_1', 'Next',
                   css_class="cancelBtn btnNext"), ))

    class Meta:
        model = Innovation
        fields = ('name', 'description', 'sectors', 'other_sectors',
                  'challenge_faced', 'challenge_to_solve', 'logo',
                  'other_challenges')
コード例 #15
0
ファイル: forms.py プロジェクト: bderenzi/commcare-hq
def hidden_bound_field(field_name):
    return Field(
        field_name,
        type='hidden',
        data_bind='value: %s' % field_name,
    )
コード例 #16
0
class MemberForm(forms.Form):
    nickname = forms.CharField(
        label='Nickname',
        max_length=100,
        required=True,
        error_messages=error_messages,
    )

    name = forms.CharField(
        label='Ad soyad',
        max_length=100,
        required=True,
        error_messages=error_messages,
    )

    email = forms.EmailField(
        label='E-posta',
        required=True,
        error_messages=error_messages,
    )

    email_visibility = forms.ChoiceField(
        label='',
        choices=(
            ('visible', 'E-posta adresimin yayınlanmasında sakınca yoktur.'),
            ('invisible', 'E-posta adresimin yayınlanmasın.'),
        ),
        widget=forms.RadioSelect,
        initial='visible',
    )

    institution = forms.CharField(
        label='Okuduğunuz/Çalıştığınız kurum',
        required=False,
    )

    department = forms.CharField(
        label='Okuduğunuz bölüm/Pozisyonunuz',
        required=False,
    )

    irc = forms.CharField(
        label='IRC nickname',
        required=False,
    )

    twitter = forms.CharField(
        label='Twitter kullanıcı adınız',
        required=False,
    )

    github = forms.CharField(
        label='Github kullanıcı adınız',
        required=False,
    )

    teams = forms.MultipleChoiceField(
        label='Yer almak istediğiniz ekip(ler)',
        choices=(
            ('project', 'Proje ekibi'),
            ('translation', 'Çeviri ekibi'),
            ('event', 'Etkinlik ekibi'),
        ),
        widget=forms.CheckboxSelectMultiple,
        required=False,
    )

    description = forms.CharField(
        label='Eklemek istedikleriniz',
        widget=forms.Textarea(),
        required=False,
    )

    helper = FormHelper()
    helper.form_tag = False
    helper.form_class = 'form-horizontal'
    helper.label_class = 'col-md-2'
    helper.field_class = 'col-md-8'
    helper.layout = Layout(
        Field('nickname',
              css_class='form-control',
              style='margin-bottom: 25px'),
        Field('name', css_class='form-control', style='margin-bottom: 25px'),
        Field('email', css_class='form-control', style='margin-bottom: 5px'),
        Field('email_visibility',
              style='padding-left: 25px; margin-bottom: 25px'),
        Field('institution',
              css_class='form-control',
              style='margin-bottom: 25px'),
        Field('department',
              css_class='form-control',
              style='margin-bottom: 25px'),
        Field('irc', css_class='form-control', style='margin-bottom: 25px'),
        Field('twitter', css_class='form-control',
              style='margin-bottom: 25px'),
        Field('github', css_class='form-control', style='margin-bottom: 25px'),
        Field('teams', style='padding-left: 30px; margin-bottom: 25px'),
        Field('description',
              rows='3',
              css_class='form-control',
              style='margin-bottom: 25px'),
        FormActions(
            Submit('send',
                   'Formu Gonder',
                   css_class='btn-primary',
                   style='margin-bottom: 25px'), ))
コード例 #17
0
 def __init__(self, user, *args, **kwargs):
     super(ApplicationForm, self).__init__(*args, **kwargs)
     self.user = user
     token = 'Update' if self.user.profile.submitted_app else 'Submit'
     
     self.helper = FormHelper(self)
     self.helper.form_class = 'form-horizontal'
     self.helper.label_class = 'col-lg-2'
     self.helper.field_class = 'col-lg-10'
     self.helper.layout = Layout(
         Field('main_character'),
         HTML('<hr>'),
         Field('char_class'),
         HTML('<hr>'),
         Field('char_spec'),
         HTML('<hr>'),
         Field('armory_link'),
         HTML('<hr>'),
         Field('recent_parses'),
         HTML('<hr>'),
         Field('screenshot'),
         HTML('<hr>'),
         Field('addons'),
         HTML('<hr>'),
         Field('computer_specs'),
         HTML('<hr>'),
         Field('authenticator'),
         HTML('<hr>'),
         Field('over_18'),
         HTML('<hr>'),
         Field('how_did_you_hear'),
         HTML('<hr>'),
         Field('previous_guild'),
         HTML('<hr>'),
         Field('experience'),
         HTML('<br>'),
         Field('battle_tag'),
         HTML('<br>'),
         FormActions(
             Submit('save', token + ' Application'),
             Button('cancel', 'Cancel', onclick="window.location='/'"),
         ),
         HTML('<br><br>'),
     )
     
     self.fields['main_character'].label = "Main Character"
     self.fields['armory_link'].label = "Link your Armory"
     self.fields['char_class'].label = "Character Class"
     self.fields['over_18'].label = "Are you 18 or older?"
     self.fields['char_spec'].label = "What is your primary raiding specialization?"
     self.fields['recent_parses'].label = "Link some recent parses (Mandatory, application will be ignored until they are provided)"
     self.fields['computer_specs'].label = "List your computer specs"
     self.fields['screenshot'].label = "Link a screenshot of your UI during combat"
     self.fields['addons'].label = "What addons do you use?"
     self.fields['experience'].label = "Tell us about your previous raiding history.  What content did you clear and with which guilds?"
     self.fields['how_did_you_hear'].label = "How did you hear about Clockwork and why do you want to join us?"
     self.fields['previous_guild'].label = "Tell us about your previous guild.  What makes us a more attractive option?"
     self.fields['authenticator'].label = "Do you use an authenticator?"
     self.fields['battle_tag'].label = "Provide us your battle tag so we may contact you about your application."
コード例 #18
0
    def __init__(self, *args, **kwargs):
        is_gift_voucher = kwargs.pop("is_gift_voucher", False)
        super().__init__(*args, **kwargs)
        self.fields["start_date"].input_formats = ['%d-%b-%Y']
        self.fields["expiry_date"].input_formats = ['%d-%b-%Y']
        self.fields['code'].validators = [validate_code]
        self.fields['discount'].validators = [validate_discount]
        self.fields['discount_amount'].validators = [validate_greater_than_0]
        self.fields['max_vouchers'].validators = [validate_greater_than_0]
        self.fields['block_configs'].queryset = BlockConfig.objects.filter(active=True)
        self.fields['block_configs'].required = False
        self.fields['total_voucher'] = forms.BooleanField(
            required=False, label="Applied to total",
            help_text="Discount applied to total checkout value, irrespective of items/block purchases"
        )
        self.child_instance = None
        if self.instance.id:
            if TotalVoucher.objects.filter(id=self.instance.id).exists():
                self.child_instance = TotalVoucher.objects.get(id=self.instance.id)
            else:
                self.child_instance = BlockVoucher.objects.get(id=self.instance.id)
            self.fields['total_voucher'].initial = isinstance(self.child_instance, TotalVoucher)
            if isinstance(self.child_instance, BlockVoucher):
                self.fields['block_configs'].initial = self.child_instance.block_configs.values_list("id", flat=True)
            if self.child_instance.gift_voucher.exists():
                is_gift_voucher = True
        self.fields['purchaser_email'].disabled = True

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Fieldset(
                "Voucher details",
                "code",
                "activated",
                HTML("<p>Enter either a discount % or fixed discount amount</p>"),
                Row(
                    Column(AppendedText("discount", "%")),
                    Column(PrependedText("discount_amount", "£")),
                ),
            ),
            Fieldset(
                "Valid Items",
                HTML("<p>Select valid block types OR tick to create a voucher applied to checkout total</>"),
                Row(
                    Column("block_configs"),
                    Column("total_voucher"),
                ),
            ),
            Fieldset(
                "Voucher restrictions",
                Row(
                    Column(
                        AppendedText(
                            "start_date", "<i id='id_start_date_open' class='far fa-calendar'></i>", autocomplete="off",
                        ),
                    ),
                    Column(
                        AppendedText(
                            "expiry_date", "<i id='id_expiry_date_open' class='far fa-calendar'></i>", autocomplete="off",
                        )
                    )
                ),
            ),
            Row(
                Column(Field("max_vouchers", type="integer")),
                Column(Field("max_per_user", type="integer")),
            ),
            Fieldset(
                "Gift Voucher details",
                'name',
                Field("message", rows=10),
                'purchaser_email',
            ) if is_gift_voucher else Fieldset(
                '',
                Hidden('name', self.instance.name if self.instance.id else ''),
                Hidden('name', self.instance.message if self.instance.id else ''),
                Hidden('name', self.instance.purchaser_email if self.instance.id else '')
            ),
            Submit('submit', 'Save')
        )
コード例 #19
0
ファイル: forms.py プロジェクト: jamesggraf/kegbot-server
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 unicode(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 unicode(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 unicode(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:
        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'), ))
コード例 #20
0
ファイル: user.py プロジェクト: pacifi-test/test-jenkins
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        self.object = kwargs.pop('object', None)

        super(UserForm, self).__init__(*args, **kwargs)
        # print self.request.user
        # self.fields['hidden_field'] = forms.CharField(widget=forms.HiddenInput())
        # print self.hidden_field

        self.fields['password1'] = forms.CharField(
            label=capfirst(_(u'Password')),
            required=False,
            widget=forms.PasswordInput,
            initial='',
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['password2'] = forms.CharField(
            label=capfirst(_(u'Password confirmation')),
            required=False,
            widget=forms.PasswordInput,
            initial='',
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Enter the same password as above, for verification.'),
        )
        groups_final = {}
        self.fields['groups'] = forms.ModelMultipleChoiceField(
            label=u'%s %s' % (capfirst(_(u'groups')), capfirst(_(u'Roles'))),
            required=False,
            queryset=Group.objects.all(),
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        if self.object:
            self.fields['groups'].initial = [
                (e) for e in Group.objects.filter(user=self.object)
            ]

        self.fields['first_name'] = forms.CharField(
            label=capfirst(_(u'first name')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['last_name'] = forms.CharField(
            label=capfirst(_(u'last name')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['identity_type'] = forms.ChoiceField(
            label=capfirst(_(u'Identity type')),
            required=True,
            # widget=forms.RadioSelect(),
            choices=IDENTITY_TYPE_CHOICES,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['identity_num'] = forms.CharField(
            label=capfirst(_(u'number')),
            required=False,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['photo'] = forms.ImageField(
            label=capfirst(_(u'Photo')),
            required=False,
            initial='persons/default.png',
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Available formats are JPG, GIF, and PNG.'),
        )

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Field('person_id', ),
            Row(
                Div(Field('first_name', ), css_class='col-md-6'),
                Div(Field('last_name', ), css_class='col-md-6'),
            ),
            Row(
                Div(Field('identity_type', ), css_class='col-md-6'),
                Div(Field('identity_num', ), css_class='col-md-6'),
            ),
            Row(
                Div(Field('username',
                          autofocus=True,
                          autocomplete='off',
                          css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('email', ), css_class='col-md-6'),
            ),
            Row(
                Div(Field('password1', autocomplete='off'),
                    css_class='col-md-6'),
                Div(Field('password2', autocomplete='off'),
                    css_class='col-md-6'),
            ),
            Row(Div(Field('groups'), css_class='col-md-12'), ),
            Row(Div(Field('photo'), css_class='col-md-6'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
コード例 #21
0
ファイル: forms.py プロジェクト: jamesggraf/kegbot-server
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
コード例 #22
0
ファイル: forms.py プロジェクト: sgaist/zds-site
    def _create_layout(self, hide_help):
        html_part = HTML(
            _("<p>Demander de l'aide à la communauté !<br>"
              "Si vous avez besoin d'un coup de main, "
              "sélectionnez une ou plusieurs catégories d'aide ci-dessous "
              'et votre contenu apparaîtra alors sur <a href='
              '\"{% url \"content:helps\" %}\" '
              "alt=\"aider les auteurs\">la page d'aide</a>.</p>"))

        self.helper.layout = Layout(
            Field('title'),
            Field('description'),
            Field('tags'),
            Field('type'),
            Field('image'),
            Field('introduction', css_class='md-editor preview-source'),
            ButtonHolder(
                StrictButton(_('Aperçu'),
                             type='preview',
                             name='preview',
                             css_class='btn btn-grey preview-btn'), ),
            HTML(
                '{% if form.introduction.value %}{% include "misc/previsualization.part.html" \
            with text=form.introduction.value %}{% endif %}'),
            Field('conclusion', css_class='md-editor preview-source'),
            ButtonHolder(
                StrictButton(_('Aperçu'),
                             type='preview',
                             name='preview',
                             css_class='btn btn-grey preview-btn'), ),
            HTML(
                '{% if form.conclusion.value %}{% include "misc/previsualization.part.html" \
            with text=form.conclusion.value %}{% endif %}'),
            Field('last_hash'),
            Field('licence'),
            Field('subcategory',
                  template='crispy/checkboxselectmultiple.html'),
        )

        if not hide_help:
            self.helper.layout.append(html_part)
            self.helper.layout.append(Field('helps'))

        self.helper.layout.append(Field('msg_commit'))
        self.helper.layout.append(
            ButtonHolder(StrictButton('Valider', type='submit')))
コード例 #23
0
ファイル: forms.py プロジェクト: jamesggraf/kegbot-server
class BeverageForm(forms.ModelForm):
    class Meta:
        model = models.Beverage
        fields = ('name', 'style', 'producer', 'vintage_year', 'abv_percent',
                  'original_gravity', 'specific_gravity', 'ibu', 'srm',
                  'color_hex', 'star_rating', 'untappd_beer_id', 'description')

    new_image = forms.ImageField(
        required=False, help_text='Set/replace image for this beer type.')

    helper = FormHelper()
    helper.form_class = 'form-horizontal'
    helper.layout = Layout(
        Field('name', css_class='input-xlarge'),
        Field('style', css_class='input-xlarge'), Field('producer'),
        Field('vintage_year'), Field('abv_percent'), Field('original_gravity'),
        Field('specific_gravity'), Field('ibu'), Field('srm'),
        Field('color_hex'), Field('star_rating'), Field('untappd_beer_id'),
        Field('description'), Field('new_image'),
        FormActions(Submit('submit', 'Save', css_class='btn-primary'), ))
コード例 #24
0
 def __init__(self, *args, **kwargs):
     super(DisabledProjectAccessForm, self).__init__(*args, **kwargs)
     self.helper.layout[0] = Field('access_control', disabled=True)
コード例 #25
0
ファイル: forms.py プロジェクト: ocwc/ocwc-members
    def __init__(self, *args, **kwargs):
        instance = kwargs.get("instance")
        initial = {}
        if instance.status == "accepted":
            initial["acceptance"] = ACCEPTANCE_CHOICES[0][0]

        if instance.expertise:
            initial["expertise"] = instance.expertise.split(",")

        if initial:
            kwargs["initial"] = initial

        super(CandidateEditForm, self).__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_show_errors = True

        self.fields["candidate_first_name"].label = "First name"
        self.fields["candidate_last_name"].label = "Last name"
        self.fields["candidate_job_title"].label = "Job title"
        self.fields["candidate_phone_number"].label = "Phone number"
        self.fields["candidate_email"].label = "Email"
        self.fields["email_alternate"].label = "Alternative e-mail"
        self.fields["organization"].label = "Institution you represent"

        for field in [
                "biography",
                "vision",
                "ideas",
                "expertise",
                "expertise_expanded",
        ]:
            self.fields[field].required = True

        self.fields[
            "biography"].label = "Candidate Biography <br /><br />Please provide a brief summary of your experience and qualifications <br />This will be displayed on the ballot."
        self.fields[
            "vision"].label = "Candidate Vision and Goals <br /><br />Please provide a brief list of what you hope to accomplish for Open Education Global if you are elected to the board of directors.  This will be displayed on the ballot."

        self.fields[
            "ideas"].label = "Ideas for Open Education Global <br /><br />Please provide a brief description of your ideas for Open Education Global in general."
        self.fields[
            "expertise"].label = "Your expertise and skills <br /><br />Please provide a brief description of expertise and skills (e.g. technical knowledge, financial knowledge, influence in public policy)."
        self.fields[
            "external_url"].label = 'External Link <br /><br />You may optionally share a link to an external page such as a CV, blog or social networking profile page.  Please include the "http://" portion.'

        self.fields[
            "expertise_expanded"].label = "Please provide a brief description of your expertise and skills with special reference to the areas of expertise check boxes you selected above"

        self.helper.layout = Layout(
            Div(
                HTML("<h2>Update Your Candidacy for Board of Directors</h2>"),
                HTML(
                    u"<p>You have been nominated as a candidate for Open Education Global Board of Directors by {instance.sponsor_first_name} {instance.sponsor_last_name}. <br /> Please review this page and complete any missing information to accept your nomination.</p>"
                    .format(instance=instance)),
                css_class="row",
            ),
            Div(
                HTML("<h3>Personal Profile Information</h3>"),
                Field("candidate_first_name"),
                Field("candidate_last_name"),
                Field("candidate_job_title"),
                Field("candidate_email"),
                Field("email_alternate"),
                Field("candidate_phone_number"),
                Field("organization"),
                css_class="row",
            ),
            Div(
                HTML("<h3>Nominee Information</h3>"),
                Field("biography"),
                Field("vision"),
                Field("ideas"),
                Field("expertise"),
                Field("expertise_other"),
                Field("expertise_expanded"),
                Field("external_url"),
                css_class="row",
            ),
            Div(
                HTML("""<h3>Terms and Conditions</h3>
                        <h4>General responsibilities of Board Members</h4>
                        <ul>
                            <li>The Board of Directors is charged with setting the strategic direction of Open Education Global. Board members make high level decisions concerning the mission, outputs, finances, and services of Open Education Global. Board members are expected to act in the best interests of the organization and its members in all deliberations.</li>
                            <li>To fulfill its charge, the Board will hold four in meetings a year, two of which will be in person and two online. It is important that board members make every attempt to fully participate in all meetings.  While substitutions are permitted if necessary, the substitute will not be allowed to vote on the Board member's behalf.</li>
                            <li>The Board member's institution is expected to cover the cost of the Board member's travel to meetings and time that is given to Open Education Global.</li>
                            <li>The Board, or its sub-committees, conducts some business between in-person meetings. Board members should anticipate doing Board related work between Board meetings including online synchronous and asynchronous activities.</li>
                            <li>Likewise, it is anticipated that Board members will serve as liaisons with various standing committees and work groups, and will represent the Organization from time to time at various meetings and/or events.</li>
                        </ul>
                    <p>I AM AWARE THAT BOARD MEMBERS EXPEND CONSIDERABLE NON-REIMBURSED TIME AND MONEY IN THE FULFILLMENT OF THEIR DUTIES.  I ATTEST THAT I AM QUALIFIED AND ABLE TO SERVE IF ELECTED.</p>
                    <p><a href="https://drive.google.com/file/d/1Re2DdyQMkhXfUZPrw2YyfKyZYSV_RA5b/view" target="_blank">(See Open Education Global By-Laws Article III for qualification and responsibilities of Board Members).</a></p>
                    """),
                Field("agreement_cost"),
                Field("agreement_fund"),
                css_class="row terms",
            ),
            Div(Field("acceptance"), css_class="row"),
        )

        self.helper.layout.append(
            Submit("submit", "Update my Candidacy for Board of Directors"))
コード例 #26
0
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 (Liters)',
        initial=0.0,
        required=False,
        help_text='Keg\'s Initial Volume in Liters')

    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='User-visible description of the Keg.')
    notes = forms.CharField(
        label='Notes',
        required=False,
        widget=forms.Textarea(),
        help_text='Private notes about this keg, viewable only by admins.')

    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'),
        Div(Field('initial_volume', css_class='input-volume', type='hidden'),
            css_class='variable-units'), Field('description'), Field('notes'),
        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'])
        return keg
コード例 #27
0
ファイル: forms.py プロジェクト: ocwc/ocwc-members
    def __init__(self, *args, **kwargs):
        super(CandidateAddForm, self).__init__(*args, **kwargs)
        self.fields["organization"].choices = [
            (x.id, x.display_name) for x in Organization.active.all()
        ]

        self.helper = FormHelper(self)
        self.helper.form_show_errors = True

        self.helper.layout = Layout(
            Div(
                HTML("<h2>Nominate a Candidate for Board of Directors</h2>"),
                css_class="row",
            ),
            Div(
                HTML("<h3>Nominee Information</h3>"),
                Field("candidate_first_name"),
                Field("candidate_last_name"),
                Field("candidate_job_title"),
                Field("candidate_email"),
                Field("candidate_phone_number"),
                Field("reason"),
                Div(Field("expertise"),
                    Field("expertise_other"),
                    css_class="expertise"),
                Field("organization"),
                css_class="row",
            ),
            Div(
                HTML("<h3>Submitter Information</h3>"),
                Field("sponsor_first_name"),
                Field("sponsor_last_name"),
                Field("sponsor_email"),
                css_class="row",
            ),
            Div(
                HTML("""<h3>Terms and Conditions</h3>
                        <h4>General responsibilities of Board Members</h4>
                        <ul>
                            <li>The Board of Directors is charged with setting the strategic direction of Open Education Global. Board members make high level decisions concerning the mission, outputs, finances, and services of Open Education Global. Board members are expected to act in the best interests of the organization and its members in all deliberations.</li>
                            <li>To fulfil its charge, the Board will hold four meetings a year, two of which will be in person (situation permitting) and two online.</li>
                            <li>The Board member's institution is expected to cover the cost of the Board member's travel to meetings and time that is given to Open Education Global.</li>
                            <li>The Board, or its sub-committees, conducts some business between in-person meetings. Board members should anticipate doing Board related work between Board meetings including online synchronous and asynchronous activities.</li>
                            <li>Likewise, it is anticipated that Board members will serve as liaisons with various standing committees and work groups, and will represent the Organization from time to time at various meetings and/or events.</li>
                        </ul>
                    <p>I AM AWARE THAT BOARD MEMBERS EXPEND CONSIDERABLE NON-REIMBURSED TIME AND MONEY IN THE FULFILLMENT OF THEIR DUTIES. I ATTEST THAT I HAVE THE CONSENT OF THE NOMINEE IN THIS MATTER. I ALSO ATTEST THAT THE NOMINEE IS QUALIFIED AND ABLE TO SERVE IF ELECTED.</p>
                    <p><a href="https://drive.google.com/file/d/1Re2DdyQMkhXfUZPrw2YyfKyZYSV_RA5b/view" target="_blank">(See Open Education Global By-Laws Article III for qualification and responsibilities of Board Members).</a></p>
                    """),
                css_class="row terms",
            ),
            Div(Field("terms"), css_class="row"),
        )
        self.helper.layout.append(Submit("Submit", "submit"))
コード例 #28
0
ファイル: forms.py プロジェクト: bderenzi/commcare-hq
    def __init__(self, *args, **kwargs):
        if 'domain' not in kwargs:
            raise Exception("Expected domain in kwargs")
        self.domain = kwargs.pop('domain')
        self.enhancements_enabled = AUTO_CASE_UPDATE_ENHANCEMENTS.enabled(
            self.domain)
        super(AddAutomaticCaseUpdateRuleForm, self).__init__(*args, **kwargs)

        if not self.enhancements_enabled:
            # Always set the value of filter_on_server_modified to true when the
            # enhancement toggle is not set
            self.data = self.data.copy()
            self.initial['filter_on_server_modified'] = 'true'
            self.data['filter_on_server_modified'] = 'true'

        # We can't set these fields to be required because they are displayed
        # conditionally and we'll confuse django validation if we make them
        # required. However, we should show the asterisk for consistency, since
        # when they are displayed they are required.
        self.fields['update_property_name'].label = _(
            "Property") + '<span class="asteriskField">*</span>'
        self.fields['update_property_value'].label = _(
            "Value") + '<span class="asteriskField">*</span>'
        self.helper = FormHelper()
        self.helper.form_class = 'form form-horizontal'
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-4 col-md-3'
        self.helper.form_method = 'POST'
        self.helper.form_action = '#'

        if self.enhancements_enabled:
            self.allow_updates_without_closing()

        _update_property_fields = [
            _f for _f in [
                Field(
                    'update_property_name',
                    ng_model='update_property_name',
                    css_class='case-property-typeahead',
                ),
                Field(
                    'property_value_type',
                    ng_model='property_value_type',
                ) if self.enhancements_enabled else None,
                Field(
                    'update_property_value',
                    ng_model='update_property_value',
                )
            ] if _f
        ]

        _basic_info_fields = [
            _f for _f in [
                Field(
                    'name',
                    ng_model='name',
                ),
                Field(
                    'case_type',
                    ng_model='case_type',
                ),
                Field(
                    'filter_on_server_modified',
                    ng_model='filter_on_server_modified',
                ) if self.enhancements_enabled else None,
                hqcrispy.B3MultiField(
                    _("Close Case") + '<span class="asteriskField">*</span>',
                    Div(
                        hqcrispy.MultiInlineField(
                            'server_modified_boundary',
                            ng_model='server_modified_boundary',
                        ),
                        css_class='col-sm-6',
                    ),
                    Div(
                        HTML('<label class="control-label">%s</label>' %
                             _('days after the case was last modified.')),
                        css_class='col-sm-6',
                    ),
                    help_bubble_text=_(
                        "This will close the case if it has been "
                        "more than the chosen number of days since "
                        "the case was last modified. Cases are "
                        "checked against this rule weekly."),
                    css_id='server_modified_boundary_multifield',
                    label_class=self.helper.label_class,
                    field_class='col-sm-8 col-md-6',
                    ng_show='showServerModifiedBoundaryField()',
                ),
                Field(
                    'action',
                    ng_model='action',
                ),
                Div(*_update_property_fields, ng_show='showUpdateProperty()')
            ] if _f
        ]

        self.set_case_type_choices(self.initial.get('case_type'))
        self.helper.layout = Layout(
            Fieldset(_("Basic Information"), *_basic_info_fields),
            Fieldset(
                _("Filter Cases to Close (Optional)"),
                Field(
                    'conditions',
                    type='hidden',
                    ng_value='conditions',
                ),
                Div(ng_include='', src="'conditions.tpl'"),
            ),
            FormActions(
                StrictButton(
                    _("Save"),
                    type='submit',
                    css_class='btn btn-primary col-sm-offset-1',
                ), ),
        )
コード例 #29
0
 def __init__(self, *args, **kwargs):
     super(CustomSignupForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_tag = False
     self.helper.layout = Layout(
         Field("username", autocomplete=self.autocomplete_value),
         Field("first_name"),
         Field("last_name"),
         Field("email", autocomplete=self.autocomplete_value),
         Field("district", autocomplete=self.autocomplete_value),
         Field("phone_number"),
         Field("gender", autocomplete=self.autocomplete_value),
         Field("age", autocomplete=self.autocomplete_value),
         Field("skill", autocomplete=self.autocomplete_value),
         Field("password1", autocomplete=self.autocomplete_value),
         Field("password2", autocomplete=self.autocomplete_value),
     )
コード例 #30
0
ファイル: forms.py プロジェクト: rexlertech/rexler
 def __init__(self, *args, **kwargs):
     super(EditProfileForm, self).__init__(*args, **kwargs)
     self.fields['langlevel'] = forms.ChoiceField(
         choices=((str(x), x) for x in range(1, 101)))
     self.fields['langlevel'].label = '2° Language Level'
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Div(
             Field('cliname', css_class='form-control'),
             Field('gencode', css_class='form-control'),
             Field('clidescription', css_class='form-control'),
             css_class='col-md-8 col-xs-12 edit-details',
         ),
         Div(
             Field('marcode', css_class='form-control'),
             Field('clibirthdate', css_class='form-control'),
             Field('citcode', css_class='form-control'),
             Field('ethcode', css_class='form-control'),
             Field('educode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             Field('lancodefirst', css_class='form-control'),
             Field('lancodesecond', css_class='form-control'),
             Field('langlevel', css_class='form-control'),
             HTML('<label class="lblpercent">%</label>'),
             Field('ocucode', css_class='form-control'),
             Field('inccode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             HTML('<span class="title">Physical description</span><hr >'),
             css_class='col-xs-12 separator',
         ),
         Div(
             Field('bodycode', css_class='form-control'),
             Field('heicode', css_class='form-control'),
             Field('weicode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             Field('eyecode', css_class='form-control'),
             Field('haicode', css_class='form-control'),
             Field('hlecode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             HTML('<span class="title">Other</span><hr >'),
             css_class='col-xs-12 separator',
         ),
         Div(
             Field('frecodedrink', css_class='form-control'),
             Field('frecodesmoke', css_class='form-control'),
             Field('zodcode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         Div(
             Field('relcode', css_class='form-control'),
             Field('chicode', css_class='form-control'),
             css_class='col-md-6 col-xs-12 column-edit',
         ),
         FormActions(
             Submit('submit', 'SAVE',
                    css_class='btn-primary form-control')),
     )