Exemplo n.º 1
0
class NotificationForm(ModelForm):

    class Meta:
        model = Notification
        exclude = ['coder', 'last_time', 'secret']
        help_texts = {
            'method': ('You can <a href="/settings#filtres-tab">configure filters</a> for each method'),
            'before': ('How much before event to send notifications'),
            'period': ('Frequency of notifications'),
        }

    def __init__(self, coder, *args, **kwargs):
        super(NotificationForm, self).__init__(*args, **kwargs)

        methods = coder.get_notifications()
        self.fields['method'] = ChoiceField(choices=methods)

    helper = FormHelper()
    helper.form_method = 'POST'
    helper.form_class = 'form-horizontal'
    helper.label_class = 'col-sm-1'
    helper.field_class = 'col-sm-4'
    helper.layout = Layout(
        Field('method', css_class='input-sm'),
        AppendedText('before', 'minute(s)', css_class='input-sm'),
        Field('period', css_class='input-sm'),
        Hidden('action', 'notification'),
        Hidden('pk', ''),
        FormActions(Submit('add', 'Add', css_class='btn-primary'))
    )
Exemplo n.º 2
0
 def __init__(self, *args, **kwargs):         
     self.person_name = kwargs.get('person_name','')# faz parte do edit do profile person type
     self.person_id = kwargs.get('person_id','')# faz parte do edit do profile person type 
     self.department_id = kwargs.get('department_id','')# faz parte do create do profile person type   
     if self.person_name and self.person_id:
         del(kwargs['person_name'])# faz parte do edit do profile person type
         del(kwargs['person_id'])# faz parte do edit do profile person type  
     if self.department_id:
         del(kwargs['department_id'])             
     super().__init__(*args, **kwargs)    
     self.helper = FormHelper()          
     self.helper.layout = Layout(
         Hidden('user_created', '{{ user.id }}'),
         Hidden('user_updated', '{{ user.id }}'),            
         Hidden('person',self.person_id),#Isso funciona somente no EDIT        
         Hidden('department', self.department_id),
         #'search_person',
         Field('search_person', value=self.person_name),#Isso funciona somente no EDIT
         'person_type',                                                                       
         HTML('''               
              <div class="row">    
                 <div class="col-sm-6">
                     <span class="float-left">
                         <button type="submit" class="btn btn-primary">Salvar</button>  	                              
                     </span>
                 </div>
                 <div class="col-sm-6">
                     <span class="float-right">
                         <a href="{% url 'url_profilepersontypes_list' department.id %}" class="btn btn-warning">Voltar</a>
                     </span>  
                 </div>
             </div>'''
         ),         
     )
Exemplo n.º 3
0
    def helper(self):
        helper = FormHelper()
        helper.form_id = 'id-searchForm'
        helper.form_method = 'get'
        helper.form_action = ''

        helper.layout = Layout(
            Fieldset(
                '',
                'well',
                'addr',
                'legal',
                'owner',
                # start_lat_long and end_lat_long are programatically generated
                # based on an identifyWells operation on the client.
                Hidden('start_lat_long', ''),
                Hidden('end_lat_long', ''),
            ),
            FormActions(
                Submit('s', 'Search', css_class='formButtons'),
                HTML(
                    '<a class="btn btn-default" id="reset-id-s" href="{% url \'search\' %}">Reset</a>'
                ),
            ))

        return helper
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     self.sample_index_obj = kwargs.pop('sample_index_obj')
     print(self.sample_index_obj.worksheet.index_set)
     super(EditIndexForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.fields['pos'].initial = self.sample_index_obj.pos
     self.fields['i7_index'].initial = self.sample_index_obj.index1
     self.fields['i5_index'].initial = self.sample_index_obj.index2
     # index_options = IndexToIndexSet.objects.filter(index_set= self.sample_index_obj.worksheet.index_set).values_list('index1', 'index1_id')
     # self.fields['i7_index'].choices = index_options
     # self.fields['pool'].initial = self.sample_index_obj.pool
     self.helper.form_id = 'index-settings-form'
     self.helper.form_method = 'POST'
     self.helper.add_input(
         Submit('submit',
                'Update',
                css_class='btn btn-outline-light w-25 buttons1'))
     self.helper.layout = Layout(
         Hidden('sample_index_obj', self.sample_index_obj.id),
         Hidden('pos', self.sample_index_obj.pos),
         # Field('pool'),
         Field('i7_index'),
         Field('i5_index'),
         HTML('<br>'),
     )
Exemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Hidden('user_created', '{{ user.id }}'),
         Hidden('user_updated', '{{ user.id }}'),
         'name',
         Row(Column('cnpj', css_class='form-group col-md-4 mb-0'),
             Column('state_registration',
                    css_class='form-group col-md-4 mb-0'),
             Column('abbreviation', css_class='form-group col-md-4 mb-0'),
             css_class='form-row'),
         'tax_regime',
         'company_type',
         Row(Column('address', css_class='form-group col-md-4 mb-0'),
             Column('address_num', css_class='form-group col-md-1 mb-0'),
             Column('address_burgh', css_class='form-group col-md-2 mb-0'),
             Column('state_city', css_class='form-group col-md-3 mb-0'),
             Column('zip_code', css_class='form-group col-md-2 mb-0'),
             css_class='form-row'),
         HTML('''
              <div class="row">    
                 <div class="col-sm-6">
                     <span class="float-left">
                         <button type="submit" class="btn btn-primary">Salvar</button>  	  
                         <button type="reset" class="btn btn-secondary">Limpar formulário</button>
                     </span>
                 </div>
                 <div class="col-sm-6">
                     <span class="float-right">
                         <a href="{% url 'url_companies_list'%}" class="btn btn-warning">Voltar</a>
                     </span>  
                 </div>
             </div>'''),
     )
Exemplo n.º 6
0
 def __init__(self, *args, **kwargs):
     super().__init__(
         Div(Div(Field("rights_begin", v_model="rightsBegin"),
                 css_class="col-5"),
             Div(Field("start_date",
                       pattern=r"\d{4}-\d{2}-\d{2}",
                       required="required"),
                 css_class="col-4",
                 v_if="rightsBegin=='start_date'"),
             Div(Field("start_date_period", required="required"),
                 css_class="col-4",
                 v_if="rightsBegin=='start_date_period'"),
             Div(Hidden(name="start_date_period", value="0"),
                 v_if="rightsBegin=='start_date_period_zero'"),
             css_class="row"),
         Div(Div(Field("rights_end", v_model="rightsEnd"),
                 css_class="col-5"),
             Div(Field("end_date",
                       pattern=r"\d{4}-\d{2}-\d{2}",
                       required="required"),
                 css_class="col-4",
                 v_if="rightsEnd=='end_date'"),
             Div(Field("end_date_period", required="required"),
                 css_class="col-4",
                 v_if="rightsEnd=='end_date_period'"),
             Div(Hidden(
                 name="end_date_open",
                 value="true",
             ),
                 v_if="rightsEnd=='end_date_open'"),
             css_class="row"),
         Div(Div("basis_note", css_class="form-group col"),
             css_class="row"))
Exemplo n.º 7
0
 def __init__(self, *args, **kwargs):                        
     self.person = kwargs.get("person","")
     del (kwargs['person'])
     super().__init__(*args, **kwargs) 
     self.fields['profile_person_type'].queryset= ProfilePersonType.objects.filter(person_id=self.person, person_type_id=3)
     self.helper = FormHelper()       
     self.helper.layout = Layout(
         Hidden('user_created', '{{ user.id }}'),
         Hidden('user_updated', '{{ user.id }}'),                      
         'profile_person_type',
         'medical_specialty',
         'course',
         'crm_num',
         'crm_uf',                                                                       
         HTML('''               
              <div class="row">    
                 <div class="col-sm-6">
                     <span class="float-left">
                         <button type="submit" class="btn btn-primary">Salvar</button>  	                              
                     </span>
                 </div>
                 <div class="col-sm-6">
                     <span class="float-right">
                         <a href="{% url 'url_doctors_list' %}" class="btn btn-warning">Voltar</a>
                     </span>  
                 </div>
             </div>'''
         ),         
     )
Exemplo n.º 8
0
 def __init__(self, *args, **kwargs):
     #Serve para pegar qual Empresa pertence os peritos
     self.department_id = kwargs.get('department_id', None)
     del (kwargs['department_id'])
     super().__init__(*args, **kwargs)
     #A linha abaixo serve para sobreescrever os valores que vão aparecer no Select do profile person type
     self.fields['doctor'].empty_label = "ESCOLHA"
     #Neste caso, preciso no seletec que apareça apenas os peritos da Empresa do usuário que está logado
     self.fields['doctor'].queryset = Doctor.objects.filter(
         profile_person_type__department__in=self.department_id)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Hidden('user_created', '{{ user.id }}'),
         Hidden('user_updated', '{{ user.id }}'),
         'doctor',
         'version',
         'forensic_scan',
         'goal',
         HTML('''               
              <div class="row">    
                 <div class="col-sm-6">
                     <span class="float-left">
                         <button type="submit" class="btn btn-primary">Salvar</button>  	                              
                     </span>
                 </div>
                 <div class="col-sm-6">
                     <span class="float-right">
                         <a href="{% url 'url_locationobjectives_list' %}" class="btn btn-warning">Voltar</a>
                     </span>  
                 </div>
             </div>'''),
     )
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     # We must pop the kwargs before we pass to super()
     # https://stackoverflow.com/a/8973101
     caf_id = kwargs.pop("caf_id")
     org_id = kwargs.pop("org_id")
     super().__init__(*args, **kwargs)
     caf = CAF.objects.get(pk=caf_id)
     cancel_redirect = reverse("caf:detail", args=[caf_id])
     self.fields["caf"].queryset = CAF.objects.filter(pk=caf_id)
     self.fields["dft_categorisation"].label = "DfT Categorisation"
     self.fields["oes_categorisation"].label = "OES Categorisation"
     self.helper = FormHelper(self)
     self.helper.layout = Layout(
         Fieldset(
             "",
             Field("name", css_class="form-control-lg"),
             "essential_service",
             "function",
             "dft_categorisation",
             "oes_categorisation",
             Hidden("caf", caf_id),
             Hidden("organisation", org_id),
         ),
         ButtonHolder(
             Submit("submit", "Submit", css_class="btn-primary"),
             Button(
                 "cancel",
                 "Cancel",
                 onclick=f"location.href='{cancel_redirect}';",
                 css_class="btn-danger",
             ),
         ),
     )
Exemplo n.º 10
0
 def __init__(self, *args, **kwargs):
     super(vol_signupForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_method = 'post'
     self.helper.form_action = 'volunteer_signup'
     self.helper.html5_required = True
     self.fields['volunteer_birthday'].widget.format = '%d-%m-%Y'
     self.helper.layout = Layout(
         Hidden('form_id', 'vol_signup', id="id_form_id"),
         Fieldset(
             'Frivilliges oplysninger',
             Div(Div(Field('volunteer_gender'), css_class="col-md-2"),
                 Div(Field('volunteer_name'), css_class="col-md-10"),
                 Div(Field('volunteer_birthday',
                           css_class="datepicker",
                           input_formats=(settings.DATE_INPUT_FORMATS)),
                     css_class="col-md-3"),
                 Div(Field('volunteer_email'), css_class="col-md-3"),
                 Div(Field('volunteer_phone'), css_class="col-md-3"),
                 Div(Field('volunteer_department'), css_class="col-md-3"),
                 css_class="row")),
         Fieldset(
             'Adresse oplysninger',
             Div(Div(Field('search_address', id="search-address"),
                     css_class="col-md-10"),
                 Div(Field('manual_entry', id="manual-entry"),
                     css_class="col-md-2"),
                 Div(Field('streetname',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-9"),
                 Div(Field('housenumber',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-1"),
                 Div(Field('floor',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-1"),
                 Div(Field('door',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-1"),
                 Div(Field('zipcode',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-2"),
                 Div(Field('city',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-5"),
                 Div(Field('placename',
                           readonly=True,
                           css_class="autofilled-address"),
                     css_class="col-md-5"),
                 Hidden('dawa_id', '', id="id_dawa_id"),
                 css_class="row")),
         Submit('submit', 'Opret', css_class="btn-success"))
Exemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        super(BlogEntryUpdateForm, self).__init__(*args, **kwargs)
        # Field mappings for dynamic generation
        self.helper = FormHelper()
        self.helper.form_class = 'pure-form pure-form-stacked pure-u-1'
        # TODO: This can be moved to above super call to avoid self.initial initialize
        article = kwargs.pop('initial')
        # Explicitly initializing form to handle edits
        #if not self.is_bound:
        self.initial = {}

        layouts = []
        article_id = article.id

        for section in article.articlesection_set.all():
            if section.section_order == 1:
                layouts.append(
                    Div(
                        Field('title', wrapper_class='rep pure-control-group', css_class='rep'),  # Class rep tells it is replicable item
                        Field('score', wrapper_class='rep pure-control-group', css_class='rep'),  # Class rep tells it is replicable item
                        Div(
                            HTML("""{% load thumbnail %}{% load misc %}<div class='avatar pure-u-md-6-12'>Currently: {{ form.image|filename }}<input id="id_image" name="image" type="file">{% if form.image.value %}{% thumbnail form.image.value "300x200" as im %}<img src='{{ im.url }}{% endthumbnail %}'>{% endif %}></div>"""),
                            css_class='pure-u-1'
                        ),
                        #Field('image', wrapper_class='norep pure-control-group', css_class='rep'),  # Class norep tells the item must be removed from replica's
                        Field('content', wrapper_class='rep pure-control-group', css_class='rep'),
                        Hidden('id', section.id),
                        css_class='section',
                        css_id='sec',
                        data_section_id=1,
                        data_article_id=article_id
                    )
                )
            else:
                delim = '_' + str(section.section_order)
                secnum = section.section_order
                layouts.append(
                    Div(
                        Field('title' + delim, wrapper_class='rep pure-control-group', css_class='rep'),  # Class rep tells it is replicable item
                        Field('score' + delim, wrapper_class='rep pure-control-group', css_class='rep'),  # Class rep tells it is replicable item
                        Field('content' + delim, wrapper_class='rep pure-control-group', css_class='rep'),
                        Hidden('id' + delim, section.id),
                        css_class='section',
                        css_id='sec' + delim,
                        data_section_id=secnum
                    )
                )

        layouts.append(Field('tags', wrapper_class='norep pure-control-group', css_class='norep'))
        layouts.append(ButtonHolder(
            Hidden('article', article_id),
            Submit('submit', 'Update Post', css_id='submit', css_class='pure-button pure-button-primary'),
            css_id='buttons'
        ))

        self.helper.layout = Layout(
            *layouts
        )
Exemplo n.º 12
0
    def __init__(self, content, targeted, public=True, *args, **kwargs):
        super(WarnTypoForm, self).__init__(*args, **kwargs)

        self.content = content
        self.targeted = targeted

        # modal form, send back to previous page if any:
        if public:
            self.previous_page_url = targeted.get_absolute_url_online()
        else:
            self.previous_page_url = targeted.get_absolute_url_beta()

        # add an additional link to send PM if needed
        type_ = _(u'l\'article')

        if content.is_tutorial:
            type_ = _(u'le tutoriel')
        elif content.is_opinion:
            type_ = _(u'le billet')

        if targeted.get_tree_depth() == 0:
            pm_title = _(u"J'ai trouvé une faute dans {} « {} ».").format(
                type_, targeted.title)
        else:
            pm_title = _(
                u"J'ai trouvé une faute dans le chapitre « {} ».").format(
                    targeted.title)

        usernames = ''
        num_of_authors = content.authors.count()
        for index, user in enumerate(content.authors.all()):
            if index != 0:
                usernames += '&'
            usernames += 'username='******'<p>Pas assez de place ? <a href="{}?title={}&{}">Envoyez un MP {}</a> !</a>'
        ).format(
            reverse('mp-new'), pm_title, usernames,
            _(u"à l'auteur") if num_of_authors == 1 else _(u'aux auteurs'))

        version = content.sha_beta
        if public:
            version = content.sha_public

        # create form
        self.helper = FormHelper()
        self.helper.form_action = reverse(
            'content:warn-typo') + '?pk={}'.format(content.pk)
        self.helper.form_method = 'post'
        self.helper.form_class = 'modal modal-flex'
        self.helper.form_id = 'warn-typo-modal'
        self.helper.layout = Layout(
            Field('target'), Field('text'), HTML(msg),
            Hidden('pk', '{{ content.pk }}'), Hidden('version', version),
            ButtonHolder(StrictButton(_(u'Envoyer'), type='submit')))
Exemplo n.º 13
0
 def __init__(self, *args, **kwargs):
     self.drug_obj = kwargs.pop('drug_obj', None)
     self.vendor_obj = kwargs.pop('vendor_obj', None)
     self.next_url = kwargs.pop('next_url')
     super(NewItemForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_tag = True
     self.helper.render_unmentioned_fields = False
     self.helper.form_id = 'id-NewItemForm'
     self.helper.form_class = 'cmmForms'
     self.helper.form_method = 'post'
     if self.next_url:
         action_url = "%s?next=%s" % (
             reverse('inventory:NewItem'),
             self.next_url
         )
     else:
         action_url = reverse('inventory:NewItem')
     self.helper.form_action = action_url
     self.initial['active'] = True
     self.initial['item_type'] = ItemType.objects.get(name='Consumable').id
     self.initial['category'] = Category.objects.get(name='Consumable').id
     try:
         self.initial['vendor'] = self.vendor_obj.id
     except:
         pass
     self.helper.layout = Layout(
         Hidden('version', '1'),
         Row(
             Column('name', css_class='form-group col-md-8'),
             Column(UneditableField('cmsid'), css_class='form-group col-md-4'),
             css_class='form-row',
         ),
         Row(
             Column('note', css_class='form-group col-md-8 mb-0'),
             Column(UneditableField('reg_no'), css_class='form-group col-md-4'),
             css_class='form-row',
         ),
         Row(
             Column('vendor', css_class='form-group col-md-4 mb-0'),
             Column('category', css_class='form-group col-md-4 mb-0'),
             Column(UneditableField('item_type'), css_class='form-group col-md-4 mb-0'),
             css_class="form-row",
         ),
         Row(Column('is_active'), css_class='form-row'),
         Hidden('item_type',  ItemType.objects.get(name='Consumable').id),
         FormActions(
             Submit('submit', 'Submit'),
             Button(
                 'back', 'Cancel',
                 css_class='btn-light',
                 onclick="javascript:history.go(-1);"
             ),
         ),
     )
Exemplo n.º 14
0
    def __init__(self, content, targeted, public=True, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.content = content
        self.targeted = targeted

        # modal form, send back to previous page if any:
        if public:
            self.previous_page_url = targeted.get_absolute_url_online()
        else:
            self.previous_page_url = targeted.get_absolute_url_beta()

        # add an additional link to send PM if needed
        type_ = _("l'article")

        if content.is_tutorial:
            type_ = _("le tutoriel")
        elif content.is_opinion:
            type_ = _("le billet")

        if targeted.get_tree_depth() == 0:
            pm_title = _("J'ai trouvé une faute dans {} « {} ».").format(type_, targeted.title)
        else:
            pm_title = _("J'ai trouvé une faute dans le chapitre « {} ».").format(targeted.title)

        usernames = ""
        num_of_authors = content.authors.count()
        for index, user in enumerate(content.authors.all()):
            if index != 0:
                usernames += "&"
            usernames += "username="******"{}?title={}&{}">Envoyez un MP {}</a> !</a>').format(
            reverse("mp-new"), pm_title, usernames, _("à l'auteur") if num_of_authors == 1 else _("aux auteurs")
        )

        version = content.sha_beta
        if public:
            version = content.sha_public

        # create form
        self.helper = FormHelper()
        self.helper.form_action = reverse("content:warn-typo") + f"?pk={content.pk}"
        self.helper.form_method = "post"
        self.helper.form_class = "modal modal-flex"
        self.helper.form_id = "warn-typo-modal"
        self.helper.layout = Layout(
            Field("target"),
            Field("text"),
            HTML(msg),
            Hidden("pk", "{{ content.pk }}"),
            Hidden("version", version),
            ButtonHolder(StrictButton(_("Envoyer"), type="submit", css_class="btn-submit")),
        )
Exemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super(RejectForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('zds.tutorial.views.reject_tutorial')
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutModalText(),
            ButtonHolder(StrictButton(_(u'Rejeter'), type='submit'), ),
            Hidden('tutorial', '{{ tutorial.pk }}'),
            Hidden('version', '{{ version }}'),
        )
Exemplo n.º 16
0
    def __init__(self, topic, *args, **kwargs):
        super(MoveTopicForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('topic-edit')
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('forum'),
            Hidden('move', ''),
            Hidden('topic', topic.pk),
            StrictButton(_('Valider'), type='submit'),
        )
Exemplo n.º 17
0
    def __init__(self, *args, **kwargs):
        super(AskValidationForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('zds.tutorial.views.ask_validation')
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutModalText(),
            Field('source'),
            StrictButton(_(u'Confirmer'), type='submit'),
            Hidden('tutorial', '{{ tutorial.pk }}'),
            Hidden('version', '{{ version }}'),
        )
Exemplo n.º 18
0
    def __init__(self, topic, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse("topic-edit")
        self.helper.form_class = "modal modal-flex"
        self.helper.form_id = "move-topic"
        self.helper.form_method = "post"

        self.helper.layout = Layout(
            Field("forum"),
            Hidden("move", ""),
            Hidden("topic", topic.pk),
            StrictButton(_("Valider"), type="submit", css_class="btn-submit"),
        )
Exemplo n.º 19
0
    def __init__(self, *args, **kwargs):
        super(UserGalleryForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'clearfix'
        self.helper.form_action = reverse('zds.gallery.views.modify_gallery')
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('user', autocomplete='off'),
            Field('mode'),
            Hidden('gallery', '{{ gallery.pk }}'),
            Hidden('adduser', 'True'),
            StrictButton(_('Ajouter'), type='submit'),
        )
Exemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        super(ValidForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse('zds.tutorial.views.valid_tutorial')
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutModalText(),
            Field('source'),
            Field('is_major'),
            StrictButton('Publier', type='submit'),
            Hidden('tutorial', '{{ tutorial.pk }}'),
            Hidden('version', '{{ version }}'),
        )
Exemplo n.º 21
0
 def __init__(self, *args, **kwargs):
     self.id = kwargs.pop('id', -1)
     super(SortieForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.include_media = False
     self.helper.html5_required = True
     self.helper.form_class = 'col-sm-8'
     self.helper.layout = Layout(
         Div(Field('name', id="nomForm", autocomplete='off'),
             Field('matricule', id="matriculeForm", autocomplete='off'),
             css_class='form-inline'), Field('admission'),
         Field('remarques'), Field('datetime_arrive', autocomplete='off'),
         Field('datetime_sortie', autocomplete='off'),
         Hidden('type', 'sortie'), Hidden('id', self.id),
         Submit('submit', 'Soumettre'))
Exemplo n.º 22
0
 def __init__(self, *args, **kwargs):
     event = kwargs.pop("event")
     super(RegistrationAuthenticationForm, self).__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.form_action = reverse_lazy(
         "login_or_register_attendee", kwargs={"event": event.slug}
     )
     self.helper.form_method = "post"
     self.helper.field_template = "devday/form/field.html"
     self.helper.html5_required = True
     self.helper.layout = Layout(
         Div(
             Hidden(
                 "next",
                 value=reverse(
                     "attendee_registration", kwargs={"event": event.slug}
                 ),
             ),
             Field(
                 "username", template="devday/form/field.html", autofocus="autofocus"
             ),
             Field("password", template="devday/form/field.html"),
         ),
         Div(
             Submit("submit", _("Login"), css_class="btn-default"),
             css_class="text-center",
         ),
     )
Exemplo n.º 23
0
    def __init__(self, topic, user, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_method = "post"

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden("last_post", "{{ last_post_pk }}"),
        )

        if "text" in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))

        if topic.antispam(user):
            if "text" not in self.initial:
                self.helper["text"].wrap(
                    Field,
                    placeholder=_(
                        "Vous venez de poster. Merci de patienter "
                        "au moins 15 minutes entre deux messages consécutifs "
                        "afin de limiter le flood."),
                    disabled=True,
                )
        elif topic.is_locked:
            if "text" not in self.initial:
                self.helper["text"].wrap(
                    Field,
                    placeholder=_("Ce topic est verrouillé."),
                    disabled=True)
Exemplo n.º 24
0
def test_inputs(settings):
    form_helper = FormHelper()
    form_helper.add_input(Submit('my-submit', 'Submit', css_class="button white"))
    form_helper.add_input(Reset('my-reset', 'Reset'))
    form_helper.add_input(Hidden('my-hidden', 'Hidden'))
    form_helper.add_input(Button('my-button', 'Button'))

    template = get_template_from_string("""
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    """)
    c = Context({'form': TestForm(), 'form_helper': form_helper})
    html = template.render(c)

    assert 'button white' in html
    assert 'id="submit-id-my-submit"' in html
    assert 'id="reset-id-my-reset"' in html
    assert 'name="my-hidden"' in html
    assert 'id="button-id-my-button"' in html

    if settings.CRISPY_TEMPLATE_PACK == 'uni_form':
        assert 'submit submitButton' in html
        assert 'reset resetButton' in html
        assert 'class="button"' in html
    else:
        assert 'class="btn"' in html
        assert 'btn btn-primary' in html
        assert 'btn btn-inverse' in html
        assert len(re.findall(r'<input[^>]+> <', html)) == 8
Exemplo n.º 25
0
    def __init__(self, *args, **kwargs):
        super(TutorialForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_class = 'content-wrapper'
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('title'),
            Field('description'),
            Field('type'),
            Field('image'),
            Field('introduction', css_class='md-editor'),
            Field('conclusion', css_class='md-editor'),
            Hidden('last_hash', '{{ last_hash }}'),
            Field('subcategory'),
            Field('licence'),
            ButtonHolder(
                StrictButton('Valider', type='submit'),
            ),
        )

        if 'type' in self.initial:
            self.helper['type'].wrap(
                Field,
                disabled=True)
Exemplo n.º 26
0
    def __init__(self, tutorial, user, *args, **kwargs):
        super(NoteForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_action = reverse(
            'zds.tutorial.views.answer') + '?tutorial=' + str(tutorial.pk)
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_note', '{{ last_note_pk }}'),
        )

        if tutorial.antispam(user):
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=u'Vous venez de poster. Merci de patienter '
                    u'au moins 15 minutes entre deux messages consécutifs '
                    u'afin de limiter le flood.',
                    disabled=True)
        elif tutorial.is_locked:
            self.helper['text'].wrap(
                Field,
                placeholder=u'Ce tutoriel est verrouillé.',
                disabled=True
            )
Exemplo n.º 27
0
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop("user")
        super().__init__(*args, **kwargs)

        self.helper = FormHelper()
        self.helper.add_input(Submit("password-save", _("Change password"), css_class="pull-right"))
        self.helper.add_input(Hidden("form", "password"))
Exemplo n.º 28
0
    def __init__(self, *args, **kwargs):
        super(AdminForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper(self)
        self.helper.form_tag = False
        # 获取region
        init_region = RegionInfo.register_choices()[0][0]

        self.helper.layout = Layout(
            Div(Field('enter_alias',
                      css_class="form-control",
                      placeholder=u"企业名称"),
                Field('nick_name',
                      css_class="form-control",
                      placeholder=u"用户名(英文)"),
                Field('email', css_class="form-control", placeholder=u"管理员邮箱"),
                Hidden('machine_region', value=init_region),
                Field('password',
                      css_class="form-control",
                      placeholder=u"请输入至少8位数密码"),
                Field('password_repeat',
                      css_class="form-control",
                      placeholder=u"请再输入一次密码"),
                HTML(
                    """<div class="form-group" style="text-align:left;"><a href="http://doc.goodrain.com/cloudbang-agreement/201656" target="_blank">《云帮企业版用户服务协议》</a></div>"""
                ),
                FormActions(
                    Submit('register',
                           u'同意协议,创建账号',
                           css_class='btn btn-lg btn-success btn-block')),
                css_class="login-wrap"))
        self.helper.form_id = 'form-normal-reg'
        self.helper.form_class = 'form-horizontal'
Exemplo n.º 29
0
def test_inputs(settings):
    form_helper = FormHelper()
    form_helper.add_input(
        Submit("my-submit", "Submit", css_class="button white"))
    form_helper.add_input(Reset("my-reset", "Reset"))
    form_helper.add_input(Hidden("my-hidden", "Hidden"))
    form_helper.add_input(Button("my-button", "Button"))

    template = Template("""
        {% load crispy_forms_tags %}
        {% crispy form form_helper %}
    """)
    c = Context({"form": SampleForm(), "form_helper": form_helper})
    html = template.render(c)

    assert "button white" in html
    assert 'id="submit-id-my-submit"' in html
    assert 'id="reset-id-my-reset"' in html
    assert 'name="my-hidden"' in html
    assert 'id="button-id-my-button"' in html

    if settings.CRISPY_TEMPLATE_PACK == "uni_form":
        assert "submit submitButton" in html
        assert "reset resetButton" in html
        assert 'class="button"' in html
    else:
        assert 'class="btn"' in html
        assert "btn btn-primary" in html
        assert "btn btn-inverse" in html
        if settings.CRISPY_TEMPLATE_PACK == "bootstrap4":
            assert len(re.findall(r"<input[^>]+> <", html)) == 9
        else:
            assert len(re.findall(r"<input[^>]+> <", html)) == 8
Exemplo n.º 30
0
    def __init__(self, topic, user, *args, **kwargs):
        super(PostForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            CommonLayoutEditor(),
            Hidden('last_post', '{{ last_post_pk }}'),
        )

        if 'text' in self.initial:
            self.helper.layout.append(
                HTML(
                    "{% include 'misc/hat_choice.html' with edited_message=post %}"
                ))
        else:
            self.helper.layout.append(
                HTML("{% include 'misc/hat_choice.html' %}"))

        if topic.antispam(user):
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_(
                        'Vous venez de poster. Merci de patienter '
                        'au moins 15 minutes entre deux messages consécutifs '
                        'afin de limiter le flood.'),
                    disabled=True)
        elif topic.is_locked:
            if 'text' not in self.initial:
                self.helper['text'].wrap(
                    Field,
                    placeholder=_('Ce topic est verrouillé.'),
                    disabled=True)