コード例 #1
0
ファイル: forms.py プロジェクト: mmenguala/nav-debian
    def __init__(self, *args, **kwargs):
        super(DetentionProfileForm, self).__init__(*args, **kwargs)

        self.fields['qvlan'].choices = get_quarantine_vlans()
        did = self.data.get('detention_id') or self.initial.get('detention_id')
        self.fields['justification'].choices = get_justifications(did)

        self.helper = FormHelper()
        self.helper.form_action = ''
        self.helper.form_class = 'profileDetentionForm custom'
        self.helper.layout = Layout(
            'detention_id', 'title', 'description',
            Fieldset('Obligatory',
                     Row(Column('detention_type', css_class='medium-4'),
                         Column('justification', css_class='medium-4'),
                         Column('duration', css_class='medium-4')),
                     Div('qvlan', css_class='qvlanrow'),
                     css_class='secondary'),
            Fieldset('Extra options',
                     Row(
                         Column('keep_closed', css_class='medium-4'),
                         Column(CheckBox('exponential',
                                         css_class='input-align'),
                                css_class='medium-4'),
                         Div(css_class='medium-4 columns'),
                     ),
                     'mail',
                     'active_on_vlans',
                     css_class='secondary'),
            CheckBox('active', css_class='input-align'),
            Submit('submit', 'Save'))
コード例 #2
0
ファイル: forms.py プロジェクト: progdupeupl/pdp_website
    def __init__(self, user, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.user = user

        self.helper.layout = Layout(
            Div(
                HTML(u'{% include "misc/editor.part.html" %}'),
                Field('biography', id='id_text'),
                Field('site'),
                Field('avatar_url'),
                Field('mail_on_private_message'),
                Field('show_email'),
            ),
            Div(Submit('submit', 'Editer mon profil'),
                css_class='button-group'))
        super().__init__(*args, **kwargs)
コード例 #3
0
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_tag = False
        self.helper.layout = Layout('target', 'method',
                                    Div('qvlan', css_class='qvlanrow'),
                                    'justification', 'comment', 'days',
                                    Submit('submit', 'Detain'))

        super(ManualDetentionForm, self).__init__(*args, **kwargs)
        self.fields['justification'].choices = get_justifications()
        self.fields['qvlan'].choices = get_quarantine_vlans()
コード例 #4
0
ファイル: forms.py プロジェクト: progdupeupl/pdp_website
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Field('email'),
            Div(Submit('submit', u'Confirmer'),
                HTML('<a href="{% url "pdp.member.views.login_view" %}" '
                     'class="button secondary">Annuler</a>'),
                css_class='button-group'))
        super().__init__(*args, **kwargs)
コード例 #5
0
ファイル: forms.py プロジェクト: progdupeupl/pdp_website
    def __init__(self, user, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.user = user

        self.helper.layout = Layout(
            Fieldset(
                u'Changement de mot de passe', Field('password_old'),
                Field('password_new'), Field('password_confirm'),
                Div(Submit('submit', u'Changer mon mot de passe'),
                    css_class='button-group')))
        super().__init__(*args, **kwargs)
コード例 #6
0
 def __init__(self, *args, **kwargs):
     self.helper = FormHelper()
     self.helper.form_method = 'post'
     self.helper.layout = Layout(
         Fieldset(
             u'Public profile',
             Field('about'),
             Field('email'),
             Field('languages'),
             Field('show_email'),
         ),
         Div(Submit('submit', 'Edit my profile', css_class='small'),
             css_class='button-group'))
     super(ProfileForm, self).__init__(*args, **kwargs)
コード例 #7
0
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Div(
                HTML(
                    '<input type="email" name="email" placeholder="E-mail" required="required" pattern="[^@]+@[^@]+\.[a-zA-Z]{2,6}">'
                ),
                HTML(
                    '<button type="submit" title="Inscription newsletter"><span>OK</span></button>'
                ),
            ))
        super(NewsletterForm, self).__init__(*args, **kwargs)
コード例 #8
0
ファイル: forms.py プロジェクト: freshy969/keepintouch
 def __init__(self, *args, **kwargs):
     
     super(ContactSearchForm, self).__init__(*args, **kwargs)
     
     self.helper = FormHelper()        
     self.helper.form_method = 'get'
     self.helper.form_action = '.'
     self.helper.form_id = 'contact-search-form'
     self.helper.layout = Layout(
             Div(
                 'search_query',
                 HTML('<a class="input-group-button button search">Search</a>'),
                 css_class = 'input-group',
                 style = 'border: 7px solid #ffaf5b;'
                 )
     )
コード例 #9
0
    def __init__(self, user, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_class = 'form-horizontal'
        self.helper.form_method = 'post'

        self.user = user

        self.helper.layout = Layout(
            Fieldset(
                u'Password',
                Field('password_old'),
                Field('password_new'),
                Field('password_confirm'),
            ),
            Div(Submit('submit', 'Change password', css_class='small'),
                css_class='button-group'))
        super(ChangePasswordForm, self).__init__(*args, **kwargs)
コード例 #10
0
ファイル: forms.py プロジェクト: progdupeupl/pdp_website
    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'

        self.helper.layout = Layout(
            Fieldset(
                u'Identifiants',
                Field('username'),
                Field('password'),
                Field('password_confirm'),
                Field('email'),
            ), Fieldset(
                u'Captcha',
                Field('captcha'),
            ),
            Div(Submit('submit', u'Valider mon inscription'),
                HTML(u'<a href="/" class="button secondary">Annuler</a>'),
                css_class='button-group'))
        super().__init__(*args, **kwargs)
コード例 #11
0
 def __init__(self, *args, **kwargs):
     super(ReviewForm, self).__init__(*args, **kwargs)
     if 'builder' in kwargs['initial']:
         builder = kwargs['initial']['builder']
         self.instance.builder = builder
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(
             'Basic Information',
             Row(Column('costume_name', css_class='small-12')),
             Row(Column('commission_date', css_class='small-12 medium-6'),
                 Column('received_date', css_class='small-12 medium-6')),
         ), Fieldset('Details', Row(Column('text', css_class='small-12'))),
         Fieldset('Rating',
                  Div('construction', 'communication', 'timeliness')),
         ButtonHolder(
             Submit('submit', 'Save'),
             HTML('<a class="button secondary" href="' +
                  (self.instance.get_absolute_url() if self.instance.
                   pk is not None else builder.get_absolute_url()) +
                  '">Cancel</a>')))
コード例 #12
0
ファイル: forms.py プロジェクト: freshy969/keepintouch
 def __init__(self, *args, **kwargs):
     self.kuser = kwargs.pop('kituser') or None
     
     super(ContactGroupForm, self).__init__(*args, **kwargs)
     
     self.fields['contacts'].queryset = self.kuser.get_contacts()
     
     self.helper = FormHelper()
     self.helper.form_action = '.'
     self.helper.layout = Layout(
         Div(
             'title',
             'description',
             HTML('<a href="#" title="Insert All Contacts" id="sel-all-contacts" class="button tiny" style="float: right; margin-bottom: 3px;">All Contacts</a>'),
             'contacts'
         ),
         ButtonHolder(
             Submit('submit', _('Submit'), css_class="success float-right"),
             Reset('reset', _('Reset'), css_class="float-right")
         )
     )
コード例 #13
0
ファイル: forms.py プロジェクト: freshy969/keepintouch
 def __init__(self, *args, **kwargs):
     super(MessageTemplateForm, self).__init__(*args, **kwargs)
     
     #self.fields['cou_group'].label = "Group Availability"
     
     self.helper = FormHelper()
     self.helper.form_action = '.'
     self.helper.add_input(Submit('submit', _('Save'), css_class="success float-right"))
     self.helper.add_input(Reset('reset', _('Reset'), css_class="float-right"))
     
     self.helper.layout = Layout(
         Row(Column('title')),
         Row(Column('email_template'), css_class = "email-template"),
         Row(Column('sms_template')),
         HTML('''
             <div class="sms-textarea-status-bar row columns">
                 <div class="column small-4">Length: <span class="length"></span></div>
                 <div class="column small-4">Messages: <span class="messages"></span></div>
                 <div class="column small-4">Remaining: <span class="remaining"></span></div>
             </div>'''
             ),
         Row(Column('active')),                      
         Fieldset(
             ugettext('Delivery settings'),
             Row(Column('cou_group')),
             Div(
                 Row(
                     Column('send_sms', css_class="float-left small-6"),
                     Column('insert_optout', css_class="float-left small-6"),
                     ),
                 Row(Column('sms_sender')),
             ),                
             Row(
                 Column('send_email', css_class="float-left small-6")
             ),
             Row(Column('email_reply_to')),          
             Row(Column('smtp_setting')),
             css_class = "new-template-settings-fieldset"
             ),                       
         )
コード例 #14
0
    def __init__(self, *args, **kwargs):
        super(NetboxModelForm, self).__init__(*args, **kwargs)
        self.fields['organization'].choices = create_hierarchy(Organization)

        # Master and instance related queries
        masters = [n.master.pk for n in
                   Netbox.objects.filter(master__isnull=False)]
        self.fields['master'].queryset = self.create_master_query(masters)
        self.fields['virtual_instance'].queryset = self.create_instance_query(masters)

        if self.instance.pk:
            # Set instances that we are master to as initial values
            self.initial['virtual_instance'] = Netbox.objects.filter(
                master=self.instance)

            # Disable fields based on current state
            if self.instance.master:
                self.fields['virtual_instance'].widget.attrs['disabled'] = True
            if self.instance.pk in masters:
                self.fields['master'].widget.attrs['disabled'] = True

            # Set the inital value of the function field
            try:
                netboxinfo = self.instance.info_set.get(variable='function')
            except NetboxInfo.DoesNotExist:
                pass
            else:
                self.fields['function'].initial = netboxinfo.value

        css_class = 'large-4'
        self.helper = FormHelper()
        self.helper.form_action = ''
        self.helper.form_method = 'POST'
        self.helper.form_id = 'seeddb-netbox-form'
        self.helper.form_tag = False
        self.helper.layout = Layout(
            Row(
                Column(
                    Fieldset('Inventory',
                             'ip',
                             Div(id='verify-address-feedback'),
                             'room', 'category', 'organization'),
                    css_class=css_class),
                Column(
                    Fieldset('Management profiles',
                             Field('profiles', css_class='select2'),
                             NavButton('check_connectivity',
                                       'Check connectivity',
                                       css_class='check_connectivity')),
                    Fieldset('Collected info',
                             Div('sysname', 'type',
                                 css_class='hide',
                                 css_id='real_collected_fields')),
                    css_class=css_class),
                Column(
                    Fieldset(
                        'Meta information',
                        'function',
                        Field('groups', css_class='select2'),
                        'data',
                        HTML("<a class='advanced-toggle'><i class='fa fa-caret-square-o-right'>&nbsp;</i>Advanced options</a>"),
                        Div(
                            HTML('<small class="alert-box">NB: An IP Device cannot both have a master and have virtual instances</small>'),
                            'master', 'virtual_instance',
                            css_class='advanced'
                        )
                    ),
                    css_class=css_class),
            ),
        )
コード例 #15
0
def translation_helper(instance=None, prefix='', form_tag=False):
    """
    Catalog's message translations form layout helper
    """
    helper = FormHelper()
    helper.form_action = '.'
    helper.form_class = 'catalog-messages-form'
    helper.form_tag = form_tag
    helper.disable_csrf = True # Does not seems to have real effect
    helper.render_required_fields = True
    
    # Define base css classes
    row_css_classes = ['message-row', 'clearfix']
    if instance.fuzzy:
        row_css_classes.append('fuzzy')
    elif not instance.message:
        row_css_classes.append('disabled empty')
    else:
        row_css_classes.append('enabled')
        
    # Build anchor link and id
    anchor_link = ''
    if prefix:
        prefix_id = int(prefix[len('form-'):]) + 1
        anchor_link = '<a href="#item-{0}" id="item-{0}">#{0}</a>'.format(prefix_id)
    
    # Build messages, at least the singular message
    message_contents = [Div(
            Div(
                HTML(
                    source_formatter(instance.template.message)
                ),
                css_class='flex-item source',
            ),
            Field(
                'message',
                placeholder=_("Type your translation here else the original text will be used"),
                wrapper_class='flex-item edit',
            ),
            css_class='flex-container',
        ),
        # Little trick to hide the field because formset requires the same 
        # fields for all items
        HiddenField('plural_message')
    ]
            
    # If plural is enabled, build the plural message and append it
    if instance.pluralizable:
        row_css_classes.append('pluralizable')
        # Remove hidden field
        message_contents.pop()
        # Append plural field
        message_contents.append(Div(
            Div(
                HTML(
                    source_formatter(instance.template.plural_message)
                ),
                css_class='flex-item source',
            ),
            Field(
                'plural_message',
                placeholder=_("Type your translation here else the original text will be used"),
                wrapper_class='flex-item edit',
            ),
            css_class='flex-container',
        ))

    
    helper.layout = Layout(
        Div(
            Div(
                HTML(anchor_link),
                css_class='anchor',
            ),
            Div(
                Div(
                    'fuzzy',
                    css_class='fuzzy-field',
                ),
                *message_contents,
                css_class=' '.join(row_css_classes)
            ),
            Div(
                HTML('<p class="title"><i class="icon-eye"></i> '),
                HTML(_('Locations')),
                HTML('</p>'),
                HTML(
                    build_locations(instance.template.get_locations_set()),
                ),
                css_class='locations',
            ),
            css_class='row-wrapper',
        ),
    )
    
    return helper
コード例 #16
0
ファイル: forms.py プロジェクト: kranthik123/ocwc-data
    def __init__(self, *args, **kwargs):
        if kwargs.get('instance'):
            self.instance = kwargs.get('instance')
        else:
            source = kwargs.pop('source')
            self.base_fields['source'].initial = source.id
            self.base_fields['language'].initial = 'English'
            self.instance = None

        self.base_fields['source'].widget = forms.HiddenInput()

        self.base_fields[
            'merlot_categories'].widget = django_select2.widgets.Select2MultipleWidget(
            )
        self.base_fields[
            'merlot_categories'].help_text = "Press Esc key to close the selection box after you've selected all relevant categories."

        self.base_fields[
            'language'].widget = django_select2.widgets.Select2Widget(
                choices=LANGUAGE_CHOICES)
        self.base_fields['tags'].help_text = "Separate tags with commas"

        self.base_fields['audience'].widget = forms.RadioSelect(
            choices=PRIMARY_AUDIENCE_CHOICES)
        self.base_fields['creative_commons'].widget = forms.RadioSelect(
            choices=YES_NO_UNSURE_CHOICES)
        self.base_fields[
            'creative_commons_commercial'].widget = forms.RadioSelect(
                choices=YES_NO_UNSURE_CHOICES)
        self.base_fields[
            'creative_commons_derivatives'].widget = forms.RadioSelect(
                choices=CC_DERIV_CHOICES)

        self.helper = FormHelper()
        self.helper.form_action = '.'

        self.helper.layout = Layout(
            Row(
                Field('merlot_ignore'),
                Field('title'),
            ))

        if self.instance and self.instance.linkurl:
            self.helper.layout.append(
                Layout(
                    Row(
                        HTML("<a href='%s' target='_blank'>View link</a>" %
                             self.instance.linkurl),
                        Field('linkurl'),
                    )))
        else:
            self.helper.layout.append(Layout(Row(Field('linkurl'))))

        self.helper.layout.append(
            Layout(
                Row(
                    Field('description'),
                    Field('language'),
                    Field('content_medium'),
                    Field('author'),
                    Field('tags'),
                )))

        if self.instance and self.instance.categories.count():
            self.helper.layout.append(
                Layout(
                    Row(
                        HTML("<h4>Legacy categories:</h4>"),
                        HTML(""" {%load mptt_tags %}
                        <p>
                        {% for node in course.categories.all %}
                        {{ node.get_ancestors|tree_path:" > " }} > {{ node }}<br />
                        {% endfor %}
                        </p>
                    """))))

        self.helper.layout.append(
            Layout(
                Row(
                    HTML(
                        "<a href='http://www.merlot.org/merlot/categories.htm' target='_blank'>Full Merlot Categories list</a>"
                    ),
                    Field('merlot_categories'),
                )))

        self.helper.layout.append(
            Layout(
                Row(
                    Field('image_url'),
                    Div(Field('audience'), css_class="small-4 columns"),
                    Div(Field('creative_commons'),
                        css_class="small-4 columns"),
                    Div(Field('creative_commons_commercial'),
                        css_class="small-4 columns"),
                    Div(Field('creative_commons_derivatives'),
                        css_class="small-8 columns left"),
                )))

        self.helper.layout.append(
            Row(Submit('Save', 'save'), css_class="buttons"))

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