Пример #1
0
    def __init__(self, *args, **kwargs):
        super(HeadquarAssociationForm, self).__init__(*args, **kwargs)
        self.fields['association_name'] = forms.CharField(
            label=capfirst(_(u'Association')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(

            Row(
                Div(Field('association_name', css_class='input-required',
                    autocomplete='off'),
                    css_class='col-md-6'),

            ),
            # Row(
            #    Div(Field('association',),
            #        css_class='col-md-6'),
            #),

            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #2
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        self.object = kwargs.pop('object', None)

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

        self.fields['description'] = forms.CharField(
            label=capfirst(_(u'Description')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )

        self.helper = FormHelper()
        self. helper.layout = Layout(

            Row(
                Div(Field('username', readonly=True),
                    css_class='col-md-6'),
                Div(Field('is_active'),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('description',),
                    css_class='col-md-6'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #3
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        self.object = kwargs.pop('object', None)

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

        self.fields['description'] = forms.CharField(
            label=capfirst(_(u'Description')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )

        self.helper = FormHelper()
        self.helper.layout = Layout(
            Row(
                Div(Field('username', readonly=True), css_class='col-md-6'),
                Div(Field('is_active'), css_class='col-md-6'),
            ),
            Row(Div(Field('description', ), css_class='col-md-6'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #4
0
    def __init__(self, *args, **kwargs):
        super(HeadquarForm, self).__init__(*args, **kwargs)
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'phone'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['address'].widget.attrs = {
            'rows': 3,
        }

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('phone', css_class='input-integer'),
                    css_class='col-md-6'),
            ),
            Row(Div(Field('address', ), css_class='col-md-6'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #5
0
 def __init__(self, *args, **kwargs):
     super(HeadquarAssociationForm, self).__init__(*args, **kwargs)
     self.fields['association_name'] = forms.CharField(
         label=capfirst(_(u'Association')),
         required=True,
         help_text=u'<small class="help-error"></small> %s' % _(u' '),
     )
     self.helper = FormHelper()
     self.helper.form_id = 'form'
     self.helper.form_class = 'js-validate form-vertical'
     self.helper.layout = Layout(
         Row(
             Div(Field('association_name',
                       css_class='input-required',
                       autocomplete='off'),
                 css_class='col-md-6'), ),
         # Row(
         #    Div(Field('association',),
         #        css_class='col-md-6'),
         #),
         Row(FormActions(
             smtSave(),
             btnCancel(),
             btnReset(),
         ), ),
     )
Пример #6
0
    def __init__(self, *args, **kwargs):
        super(HeadquarForm, self).__init__(*args, **kwargs)
        self.fields['name'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['phone'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['address'].widget.attrs = {'rows': 3, }

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(

            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('phone', css_class='input-integer' ),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('address',),
                    css_class='col-md-6'),
            ),

            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #7
0
    def __init__(self, *args, **kwargs):
        super(MenuForm, self).__init__(*args, **kwargs)
        self.fields[
            'title'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'pos'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'url'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        '''
        self.fields['permission'] = MyModelChoiceField(
            label=capfirst(_(u'permission')), required=False,

            queryset=Permission.objects.all(),

            # queryset=list(
            #    c['content_type__app_label'] for c in Permission.objects.all()
            #),
            # widget=forms.CheckboxSelectMultiple(),
            # widget=forms.SelectMultiple(attrs={'class':'form-control'}),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        '''
        self.fields['parent'].queryset = Menu.objects.filter(parent=None)

        self.fields['parent'].label_from_instance = lambda obj: "%s:%s" % (
            dict((x, y) for x, y in MODULE_CHOICES)[obj.module], obj.title)

        self.fields['permission'].label_from_instance = lambda obj: "%s/%s" % (
            obj.content_type.app_label, obj.codename)

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(Div(Field('module', css_class=''), css_class='col-md-8'), ),
            Row(
                Div(Field('title', css_class='input-required'),
                    css_class='col-md-4'),
                Div(Field('parent', ), css_class='col-md-4'),
                Div(Field('permission', ), css_class='col-md-4'),
            ),
            Row(
                Div(Field('pos',
                          css_class='input-required input-integer mask-pint'),
                    css_class='col-md-4'),
                Div(Field('icon', ), css_class='col-md-4'),
                Div(Field('url', css_class='input-required'),
                    css_class='col-md-4'),
            ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #8
0
    def __init__(self, *args, **kwargs):
        super(PermissionForm, self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'name')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Can CRUD to Model'),
        )
        self.fields['app_label'] = forms.CharField(
            label=_(u'App'),
            required=True,
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Ingrese palabra de la forma [A-Z0-9_]'),
        )

        self.fields['controller_view'] = forms.CharField(
            label=_(u'Controller'),
            required=False,
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Ingrese palabra de la forma [A-Z0-9]'),
        )
        self.fields['action_view'] = forms.CharField(
            label=_(u'Action'),
            required=False,
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Ingrese palabra de la forma [A-Z0-9_]'),
        )

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('app_label', css_class='input-required input-word_'),
                    css_class='col-md-4'),
                Div(Field('controller_view', css_class='input-word'),
                    css_class='col-md-4'),
                Div(Field('action_view', css_class='input-word_'),
                    css_class='col-md-4'),
            ),
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-8'),  # input-alphanum
            ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #9
0
    def __init__(self, *args, **kwargs):
        super(PermissionForm, self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'name')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Can CRUD to Model'),
        )
        self.fields['app_label'] = forms.CharField(
            label=_(u'App'), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Ingrese palabra de la forma [A-Z0-9_]'),
        )

        self.fields['controller_view'] = forms.CharField(
            label=_(u'Controller'), required=False,
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Ingrese palabra de la forma [A-Z0-9]'),
        )
        self.fields['action_view'] = forms.CharField(
            label=_(u'Action'), required=False,
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Ingrese palabra de la forma [A-Z0-9_]'),
        )

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('app_label', css_class='input-required input-word_'),
                    css_class='col-md-4'),
                Div(Field('controller_view', css_class='input-word'),
                    css_class='col-md-4'),
                Div(Field('action_view', css_class='input-word_'),
                    css_class='col-md-4'),
            ),
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-8'),  # input-alphanum
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #10
0
    def __init__(self, *args, **kwargs):
        super(ModuleForm, self).__init__(*args, **kwargs)
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'description'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['description'].widget.attrs = {
            'rows': 3,
        }
        '''
        self.fields['groups'] = forms.ModelMultipleChoiceField(
            label=capfirst(_(u'groups')), required=False,
            queryset=Group.objects.all(),
            #widget=forms.CheckboxSelectMultiple(),
            widget=forms.SelectMultiple(attrs={'class':'form-control'}),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        '''

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('module', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('groups', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('initial_groups', css_class='input-required'),
                    css_class='col-md-6'),
            ),
            Row(Div(Field('description', css_class=''),
                    css_class='col-md-6'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #11
0
    def __init__(self, *args, **kwargs):
        super(ModuleForm, self).__init__(*args, **kwargs)
        self.fields['name'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['description'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['description'].widget.attrs={'rows': 3, }
        '''
        self.fields['groups'] = forms.ModelMultipleChoiceField(
            label=capfirst(_(u'groups')), required=False,
            queryset=Group.objects.all(),
            #widget=forms.CheckboxSelectMultiple(),
            widget=forms.SelectMultiple(attrs={'class':'form-control'}),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        '''

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('module', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('groups', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('initial_groups', css_class='input-required'),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('description', css_class=''),
                    css_class='col-md-6'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #12
0
    def __init__(self, *args, **kwargs):
        super(AssociationForm, self).__init__(*args, **kwargs)
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['solution'].required = True
        self.fields[
            'solution'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'logo'].help_text = u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.')

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    _('Association'),
                    Row(
                        Div(Field('name', css_class='input-required'),
                            css_class='col-md-6'),
                        Div(Field('type_a', css_class='input-required'),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('solution', css_class='input-required'),
                            css_class='col-md-6'), ),
                ),
                Tab(
                    _('Image'),
                    Row(Div(Field('logo', css_class=''),
                            css_class='col-md-6'), ),
                ),
            ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #13
0
    def __init__(self, *args, **kwargs):
        super(AssociationForm, self).__init__(*args, **kwargs)
        self.fields['name'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['solution'].required = True
        self.fields['solution'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['logo'].help_text = u'<small class="help-error"></small> %s' % _(
            u'Available formats are JPG, GIF, and PNG.')

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            TabHolder(
                Tab(_('Association'),
                    Row(
                    Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                    Div(Field('type_a', css_class='input-required'),
                    css_class='col-md-6'),
                    ),
                    Row(
                    Div(Field('solution', css_class='input-required'),
                    css_class='col-md-6'),
                    ),
                    ),
                Tab(_('Image'),
                    Row(
                    Div(Field('logo', css_class=''),
                        css_class='col-md-6'),
                    ),
                    ),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #14
0
    def __init__(self, *args, **kwargs):
        super(GroupForm, self).__init__(*args, **kwargs)
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u'Name of group the user or profile user.')
        #self.fields['name'].validators = [validate_unique_group_name]

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-8'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #15
0
    def __init__(self, *args, **kwargs):
        super(GroupForm, self).__init__(*args, **kwargs)
        self.fields['name'].help_text=u'<small class="help-error"></small> %s' % _(
                u'Name of group the user or profile user.')
        #self.fields['name'].validators = [validate_unique_group_name]

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-8'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #16
0
    def __init__(self, *args, **kwargs):
        self.create = kwargs.pop('create', None)

        super(EnterpriseForm, self).__init__(*args, **kwargs)
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'tax_id'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')

        if self.create:
            self.fields['sede'] = forms.CharField(
                label=capfirst(_(u'Sede')),
                required=True,
                initial='Principal',
                help_text=u'<small class="help-error"></small> %s' % _(u' '),
                widget=forms.TextInput(attrs={
                    'class': 'input-required',
                }),
            )
        else:
            self.fields['sede'] = forms.CharField(widget=forms.HiddenInput(),
                                                  required=False)

        self.fields[
            'logo'].help_text = u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.')
        self.fields['solution'].required = True
        self.fields[
            'solution'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    _('Enterprise'),
                    Row(
                        Div(Field('tax_id',
                                  css_class='input-required',
                                  autofocus=True),
                            css_class='col-md-6'), ),
                    Row(
                        Div(Field('name', css_class='input-required'),
                            css_class='col-md-6'),
                        Div(Field('type_e', css_class='input-required'),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field(
                            'solution',
                            css_class='input-required',
                        ),
                            css_class='col-md-6'),
                        Div(Field('sede', ), css_class='col-md-6'),
                    ),
                ),
                Tab(_('Image'), Field('logo', css_class="")),
            ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #17
0
    def __init__(self, *args, **kwargs):
        super(SolutionForm, self).__init__(*args, **kwargs)
        '''
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'name')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['description'] = forms.CharField(
            label=_(u'Description'), required=False,
            widget=forms.Textarea(attrs={'rows': 3, }),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['test_image'] = forms.ImageField(
            label=capfirst(_(u'Test image')), required=False,
            initial='test_images/default.png',
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.'),
        )
        '''
        self.fields['name'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['description'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['description'].widget.attrs = {'rows': 3, }
        self.fields['test_image'].help_text = u'<small class="help-error"></small> %s' % _(
            u'Available formats are JPG, GIF, and PNG.')
        self.fields['price'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')

        self.fields['test_date'] = forms.DateTimeField(
            label=_(u'Test date'), required=False,
            initial=datetime.now().replace(tzinfo=get_current_timezone()),
            widget=forms.DateTimeInput(format='%Y-%m-%d %H:%M:%S',),
            input_formats=(
                '%d/%m/%Y', '%d/%m/%y', '%d-%m-%Y', '%d-%m-%y', '%Y-%m-%d',
                '%Y-%m-%d %H:%M:%S'),
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Some useful help text.'),
        )
        self.helper = FormHelper()
        #self.helper.form_tag = False
        # http://bixly.com/blog/awesome-forms-django-crispy-forms/
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        #self.helper.form_show_labels = False
        #self.fields['name'].label = False
        self.helper.layout = Layout(
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('description', css_class=''),
                    css_class='col-md-6'),
            ),
            Row(
                Div(Field('price', css_class='input-numeric mask-num'),
                    css_class='col-md-6'),
                Div(Field('test_date', css_class='input-datex'),
                    css_class='col-md-6'),  # falta validar un input-datetime
            ),
            Row(
                Div(Field('test_image', css_class=''),
                    css_class='col-md-6'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #18
0
    def __init__(self, *args, **kwargs):
        self.create = kwargs.pop('create', None)

        super(EnterpriseForm, self).__init__(*args, **kwargs)
        self.fields['name'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['tax_id'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')

        if self.create:
            self.fields['sede'] = forms.CharField(
                label=capfirst(_(u'Sede')), required=True,
                initial='Principal',
                help_text=u'<small class="help-error"></small> %s' % _(
                    u' '),
                 widget=forms.TextInput(attrs={'class': 'input-required', }),
            )
        else:
            self.fields['sede'] = forms.CharField(
                widget=forms.HiddenInput(), required=False)

        self.fields['logo'].help_text = u'<small class="help-error"></small> %s' % _(
            u'Available formats are JPG, GIF, and PNG.')
        self.fields['solution'].required = True
        self.fields['solution'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(

            TabHolder(
                Tab(_('Enterprise'),
                    Row(

                        Div(Field('tax_id', css_class='input-required',
                            autofocus=True),
                    css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                        Div(Field('type_e', css_class='input-required'),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('solution', css_class='input-required',),
                            css_class='col-md-6'),
                        Div(Field('sede', ),
                            css_class='col-md-6'),
                    ),


                    ),
                Tab(_('Image'),
                    Field('logo', css_class="")
                    ),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #19
0
    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

        headquar = Headquar.objects.get(
            id=UserToken.get_headquar_id(self.request.session))
        solution_enterprise = Solution.objects.get(
            id=headquar.enterprise.solution.id)
        solution_association = Solution.objects.get(
            id=headquar.association.solution.id)
        module_list = Module.objects.filter(
            Q(solutions=solution_enterprise)
            | Q(solutions=solution_association),
            is_active=True).distinct()
        # trae los objetos relacionados sad.Module
        group_perm_list = Group.objects.filter(
            module_set__in=module_list).order_by("-id").distinct()
        # print group_perm_list
        # print "====================="
        # pero hay que adornarlo de la forma Module>Group
        group_list_by_module = []
        # solo para verificar que el Group no se repita si este está en dos o
        # más módulos
        group_list_by_module_unique_temp = []
        for module in module_list:
            for group in Group.objects.filter(module_set=module).distinct():
                if len(group_list_by_module) == 0:
                    group_list_by_module.append({
                        "group": group,
                        "module": module,
                    })
                    group_list_by_module_unique_temp.append(group)
                else:
                    if group not in group_list_by_module_unique_temp:
                        group_list_by_module.append({
                            "group": group,
                            "module": module,
                        })
                        group_list_by_module_unique_temp.append(group)
        groups_final = {}
        for perm in group_list_by_module:
            groups_final[perm['group'].id] = '%s> %s' % (perm['module'].name,
                                                         perm['group'].name)

        # print groups_final.items()
        '''
        self.fields['hgroups'] = forms.ModelMultipleChoiceField(
            queryset=Group.objects.filter(module_set__in=module_list).order_by("-id").distinct()

            )
        self.fields['hgroups'].initial=Group.objects.filter(userheadquar__headquar__id=headquar.id, userheadquar__user__id=2).distinct() 
        
        '''
        self.fields['hgroups'] = forms.MultipleChoiceField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Headquar'))),
            required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        if self.object:
            self.fields['hgroups'].initial = [
                (e.id) for e in Group.objects.filter(
                    userheadquar__headquar__id=headquar.id,
                    userheadquar__user__id=self.object.id).distinct()
            ]

        self.fields['egroups'] = forms.MultipleChoiceField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Enterprise'))),
            required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        if self.object:
            self.fields['egroups'].initial = [
                (e.id) for e in Group.objects.filter(
                    userenterprise__enterprise__id=headquar.enterprise.id,
                    userenterprise__user__id=self.object.id).distinct()
            ]

        self.fields['agroups'] = forms.MultipleChoiceField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Association'))),
            required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        if self.object:
            self.fields['agroups'].initial = [
                (e.id) for e in Group.objects.filter(
                    userassociation__association__id=headquar.association.id,
                    userassociation__user__id=self.object.id).distinct()
            ]

        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.'),
        )

        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', ),
            TabHolder(
                Tab(
                    _('Personal Info'),
                    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'),
                    ),
                ),
                Tab(
                    _('Account Info'),
                    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('hgroups'), css_class='col-md-6'), ),
                    Row(
                        Div(Field('egroups'), css_class='col-md-6'),
                        Div(Field('agroups'), css_class='col-md-6'),
                    ),
                ),
                Tab(
                    _('Image'),
                    Row(Div(Field('photo'), css_class='col-md-6'), ),
                ),
            ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #20
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        self.object = kwargs.pop('object', None)

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

        self.fields['username'] = forms.CharField(
            label=capfirst(_(u'username')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['email'] = forms.CharField(
            label=capfirst(_(u'email')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        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.fields['hgroups'] = forms.CharField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Headquar'))), )
        self.fields['egroups'] = forms.CharField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Enterprise'))), )
        self.fields['agroups'] = forms.CharField(
            label=u'%s %s' %
            (capfirst(_(u'groups')), capfirst(_(u'Association'))), )
        self.fields['status'] = forms.CharField(
            label=u'%s %s' % (capfirst(_(u'status')), capfirst(_(u'user'))), )

        self.helper = FormHelper()
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    _('Account Info'),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.first_name.label }} </label>
                                <div class="controls ">{{ form.first_name.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.last_name.label }} </label>
                                <div class="controls ">{{ form.last_name.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.identity_type.label }} </label>
                                <div class="controls ">{{ form.identity_type.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.identity_num.label }} </label>
                                <div class="controls ">{{ form.identity_num.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.username.label }} </label>
                                <div class="controls ">{{ form.username.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.email.label }} </label>
                                <div class="controls ">{{ form.email.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_superuser.label }} </label>
                                <div class="controls ">{{ form.is_superuser.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_staff.label }} </label>
                                <div class="controls ">{{ form.is_staff.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_active.label }} </label>
                                <div class="controls ">{{ form.is_active.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'), ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.hgroups.label }} </label>
                                <div class="controls ">{% for x in form.hgroups.value %} 
                                {{ x.headquar.enterprise.name }}-{{ x.headquar.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                            css_class='col-md-6'), ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.egroups.label }} </label>
                                <div class="controls ">{% for x in form.egroups.value %} 
                                {{ x.enterprise.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.agroups.label }} </label>
                                <div class="controls ">{% for x in form.agroups.value %} 
                                {{ x.association.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                ),
                Tab(
                    _('Tracking'),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_active.label }} </label>
                                <div class="controls ">{{ form.is_active.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'), ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.status.label }} </label>
                                <div class="controls ">{% for x in form.status.value %} 
                                {{ x.created_at }} | {{ x.description }} | {{ x.status }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                            css_class='col-md-6'), ),
                ),
                Tab(
                    _('Image'),
                    HTML("""
                        {% if form.photo.value %}<img class="img-responsive" src="{{ MEDIA_URL }}{{ form.photo.value }}">{% endif %}
                        """),
                ),
            ),
            Row(FormActions(btnCancel(), ), ),
        )
Пример #21
0
    def __init__(self, *args, **kwargs):
        super(MenuForm, self).__init__(*args, **kwargs)
        self.fields['title'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['pos'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['url'].help_text=u'<small class="help-error"></small> %s' % _(
                u' ')
        '''
        self.fields['permission'] = MyModelChoiceField(
            label=capfirst(_(u'permission')), required=False,

            queryset=Permission.objects.all(),

            # queryset=list(
            #    c['content_type__app_label'] for c in Permission.objects.all()
            #),
            # widget=forms.CheckboxSelectMultiple(),
            # widget=forms.SelectMultiple(attrs={'class':'form-control'}),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        '''
        self.fields['parent'].queryset = Menu.objects.filter(parent=None)

        self.fields['parent'].label_from_instance = lambda obj: "%s:%s" % (
            dict((x, y)
                 for x, y in MODULE_CHOICES)[obj.module], obj.title)

        self.fields['permission'].label_from_instance = lambda obj: "%s/%s" % (
            obj.content_type.app_label, obj.codename)

        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            Row(
                Div(Field('module', css_class=''),
                    css_class='col-md-8'),
            ),
            Row(
                Div(Field('title', css_class='input-required'),
                    css_class='col-md-4'),
                Div(Field('parent', ),
                    css_class='col-md-4'),
                Div(Field('permission', ),
                    css_class='col-md-4'),
            ),
            Row(
                Div(Field('pos', css_class='input-required input-integer mask-pint'),
                    css_class='col-md-4'),
                Div(Field('icon', ),
                    css_class='col-md-4'),
                Div(Field('url', css_class='input-required'),
                    css_class='col-md-4'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #22
0
    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

        headquar = Headquar.objects.get(
            id=UserToken.get_headquar_id(self.request.session))
        solution_enterprise = Solution.objects.get(
            id=headquar.enterprise.solution.id)
        solution_association = Solution.objects.get(
            id=headquar.association.solution.id)
        module_list = Module.objects.filter(Q(solutions=solution_enterprise) | Q(
            solutions=solution_association), is_active=True).distinct()
        # trae los objetos relacionados sad.Module
        group_perm_list = Group.objects.filter(
            module_set__in=module_list).order_by("-id").distinct()
        # print group_perm_list
        # print "====================="
        # pero hay que adornarlo de la forma Module>Group
        group_list_by_module = []
        # solo para verificar que el Group no se repita si este está en dos o
        # más módulos
        group_list_by_module_unique_temp = []
        for module in module_list:
            for group in Group.objects.filter(module_set=module).distinct():
                if len(group_list_by_module) == 0:
                    group_list_by_module.append({
                                                "group": group,
                                                "module": module,
                                                })
                    group_list_by_module_unique_temp.append(group)
                else:
                    if group not in group_list_by_module_unique_temp:
                        group_list_by_module.append({
                                                    "group": group,
                                                    "module": module,
                                                    })
                        group_list_by_module_unique_temp.append(group)
        groups_final = {}
        for perm in group_list_by_module:
            groups_final[perm['group'].id] = '%s> %s' % (
                perm['module'].name,  perm['group'].name)

        # print groups_final.items()
        '''
        self.fields['hgroups'] = forms.ModelMultipleChoiceField(
            queryset=Group.objects.filter(module_set__in=module_list).order_by("-id").distinct()

            )
        self.fields['hgroups'].initial=Group.objects.filter(userheadquar__headquar__id=headquar.id, userheadquar__user__id=2).distinct() 
        
        '''
        self.fields['hgroups'] = forms.MultipleChoiceField(
            label=u'%s %s' % (capfirst(_(u'groups')), capfirst(_(u'Headquar'))), required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        if self.object:
            self.fields['hgroups'].initial = [(e.id) for e in Group.objects.filter(
                userheadquar__headquar__id=headquar.id, userheadquar__user__id=self.object.id).distinct()]

        self.fields['egroups'] = forms.MultipleChoiceField(
            label=u'%s %s' % (capfirst(_(u'groups')), capfirst(_(u'Enterprise'))), required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        if self.object:
            self.fields['egroups'].initial = [(e.id) for e in Group.objects.filter(
                userenterprise__enterprise__id=headquar.enterprise.id, userenterprise__user__id=self.object.id).distinct()]

        self.fields['agroups'] = forms.MultipleChoiceField(
            label=u'%s %s' % (capfirst(_(u'groups')), capfirst(_(u'Association'))), required=False,
            choices=groups_final.items(),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        if self.object:
            self.fields['agroups'].initial = [(e.id) for e in Group.objects.filter(
                userassociation__association__id=headquar.association.id, userassociation__user__id=self.object.id).distinct()]

        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.'),
        )

        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',),
            TabHolder(
                Tab(_('Personal Info'),
                    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'),
                    ),
                    ),
                Tab(_('Account Info'),
                    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('hgroups'),
                                    css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('egroups'),
                                    css_class='col-md-6'),
                        Div(Field('agroups'),
                                    css_class='col-md-6'),
                    ),

                    ),

                Tab(_('Image'),
                    Row(
                        Div(Field('photo'),
                                    css_class='col-md-6'),
                    ),
                    ),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #23
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop('request', None)
        self.object = kwargs.pop('object', None)

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

        self.fields['username'] = forms.CharField(
            label=capfirst(_(u'username')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['email'] = forms.CharField(
            label=capfirst(_(u'email')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        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.fields['hgroups'] = forms.CharField(
            label=u'%s %s' % (capfirst(_(u'groups')), capfirst(_(u'Headquar'))),
        )
        self.fields['egroups'] = forms.CharField(
            label=u'%s %s' % (
                capfirst(_(u'groups')), capfirst(_(u'Enterprise'))),
        )
        self.fields['agroups'] = forms.CharField(
            label=u'%s %s' % (
                capfirst(_(u'groups')), capfirst(_(u'Association'))),
        )
        self.fields['status'] = forms.CharField(
            label=u'%s %s' % (capfirst(_(u'status')), capfirst(_(u'user'))),
        )

        self.helper = FormHelper()
        self. helper.layout = Layout(

            TabHolder(
                Tab(
                    _('Account Info'),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.first_name.label }} </label>
                                <div class="controls ">{{ form.first_name.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.last_name.label }} </label>
                                <div class="controls ">{{ form.last_name.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.identity_type.label }} </label>
                                <div class="controls ">{{ form.identity_type.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.identity_num.label }} </label>
                                <div class="controls ">{{ form.identity_num.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.username.label }} </label>
                                <div class="controls ">{{ form.username.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.email.label }} </label>
                                <div class="controls ">{{ form.email.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_superuser.label }} </label>
                                <div class="controls ">{{ form.is_superuser.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_staff.label }} </label>
                                <div class="controls ">{{ form.is_staff.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_active.label }} </label>
                                <div class="controls ">{{ form.is_active.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),

                    ),

                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.hgroups.label }} </label>
                                <div class="controls ">{% for x in form.hgroups.value %} 
                                {{ x.headquar.enterprise.name }}-{{ x.headquar.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                                    css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.egroups.label }} </label>
                                <div class="controls ">{% for x in form.egroups.value %} 
                                {{ x.enterprise.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                                    css_class='col-md-6'),
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.agroups.label }} </label>
                                <div class="controls ">{% for x in form.agroups.value %} 
                                {{ x.association.name }}>{{ x.group.name }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                                    css_class='col-md-6'),
                    ),

                ),
                Tab(
                    _('Tracking'),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.is_active.label }} </label>
                                <div class="controls ">{{ form.is_active.value }}</div>
                                </div>
                                '''),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(HTML('''
                                <div class="form-group">
                                <label class="control-label"> {{ form.status.label }} </label>
                                <div class="controls ">{% for x in form.status.value %} 
                                {{ x.created_at }} | {{ x.description }} | {{ x.status }}<br>
                                {% endfor %}</div>
                                </div>
                                '''),
                                    css_class='col-md-6'),
                    ),

                ),

                Tab(_('Image'),
                    HTML("""
                        {% if form.photo.value %}<img class="img-responsive" src="{{ MEDIA_URL }}{{ form.photo.value }}">{% endif %}
                        """),
                    ),
            ),
            Row(
                FormActions(

                    btnCancel(),

                ),
            ),
        )
Пример #24
0
    def __init__(self, *args, **kwargs):
        super(SolutionForm, self).__init__(*args, **kwargs)
        '''
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'name')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['description'] = forms.CharField(
            label=_(u'Description'), required=False,
            widget=forms.Textarea(attrs={'rows': 3, }),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['test_image'] = forms.ImageField(
            label=capfirst(_(u'Test image')), required=False,
            initial='test_images/default.png',
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.'),
        )
        '''
        self.fields[
            'name'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'description'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields['description'].widget.attrs = {
            'rows': 3,
        }
        self.fields[
            'test_image'].help_text = u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.')
        self.fields[
            'price'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')

        self.fields['test_date'] = forms.DateTimeField(
            label=_(u'Test date'),
            required=False,
            initial=datetime.now().replace(tzinfo=get_current_timezone()),
            widget=forms.DateTimeInput(format='%Y-%m-%d %H:%M:%S', ),
            input_formats=('%d/%m/%Y', '%d/%m/%y', '%d-%m-%Y', '%d-%m-%y',
                           '%Y-%m-%d', '%Y-%m-%d %H:%M:%S'),
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Some useful help text.'),
        )
        self.helper = FormHelper()
        #self.helper.form_tag = False
        # http://bixly.com/blog/awesome-forms-django-crispy-forms/
        self.helper.form_method = 'post'
        self.helper.form_class = 'js-validate form-vertical'
        #self.helper.form_show_labels = False
        #self.fields['name'].label = False
        self.helper.layout = Layout(
            Row(
                Div(Field('name', css_class='input-required'),
                    css_class='col-md-6'),
                Div(Field('description', css_class=''), css_class='col-md-6'),
            ),
            Row(
                Div(Field('price', css_class='input-numeric mask-num'),
                    css_class='col-md-6'),
                Div(Field('test_date', css_class='input-datex'),
                    css_class='col-md-6'),  # falta validar un input-datetime
            ),
            Row(Div(Field('test_image', css_class=''),
                    css_class='col-md-6'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )
Пример #25
0
    def __init__(self, *args, **kwargs):
        super(RegistrationEnterpriseAssociationForm,
              self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'Enterprise')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['association_name'] = forms.CharField(
            label=capfirst(_(u'Association')), required=True,
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )

        self.fields['acept'] = forms.BooleanField(
            label=capfirst(_(u'I accept the Terms of Service and Privacy Policy.')), required=True,
            # widget=forms.CheckboxInput(),
            help_text=u'<small class="help-error"></small> %s' % _(
                u' '),
        )
        self.fields['logo'] = forms.ImageField(
            label=capfirst(_(u'logo')), required=False,
            initial='enterprises/default.png',
            help_text=u'<small class="help-error"></small> %s' % _(
                u'Available formats are JPG, GIF, and PNG.'),
        )
        self.fields['solution'].required = True
        self.fields['solution'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['type_e'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')
        self.fields['tax_id'].help_text = u'<small class="help-error"></small> %s' % _(
            u' ')

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(

            TabHolder(
                Tab(_('Enterprise'),
                    Row(
                        Div(Field('name', autofocus=True, css_class='input-required'),
                    css_class='col-md-6'),
                        Div(Field('tax_id', css_class='input-required', ),
                    css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('association_name', css_class='input-required',),
                            css_class='col-md-6'),
                        Div(Field('type_e', css_class='input-required', ),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field('solution', css_class='input-required',),
                            css_class='col-md-6'),
                    ),


                    ),
                Tab(_('Image'),
                    Field('logo', css_class="")
                    ),
            ),
            Row(
                Div(Field('acept', css_class='input-required',),
                    css_class='col-md-12'),
            ),
            Row(
                FormActions(
                    smtSave(),
                    btnCancel(),
                    btnReset(),
                ),
            ),
        )
Пример #26
0
    def __init__(self, *args, **kwargs):
        super(RegistrationEnterpriseAssociationForm,
              self).__init__(*args, **kwargs)
        self.fields['name'] = forms.CharField(
            label=capfirst(_(u'Enterprise')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['association_name'] = forms.CharField(
            label=capfirst(_(u'Association')),
            required=True,
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )

        self.fields['acept'] = forms.BooleanField(
            label=capfirst(
                _(u'I accept the Terms of Service and Privacy Policy.')),
            required=True,
            # widget=forms.CheckboxInput(),
            help_text=u'<small class="help-error"></small> %s' % _(u' '),
        )
        self.fields['logo'] = forms.ImageField(
            label=capfirst(_(u'logo')),
            required=False,
            initial='enterprises/default.png',
            help_text=u'<small class="help-error"></small> %s' %
            _(u'Available formats are JPG, GIF, and PNG.'),
        )
        self.fields['solution'].required = True
        self.fields[
            'solution'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'type_e'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')
        self.fields[
            'tax_id'].help_text = u'<small class="help-error"></small> %s' % _(
                u' ')

        self.helper = FormHelper()
        self.helper.form_id = 'form'
        self.helper.form_class = 'js-validate form-vertical'
        self.helper.layout = Layout(
            TabHolder(
                Tab(
                    _('Enterprise'),
                    Row(
                        Div(Field('name',
                                  autofocus=True,
                                  css_class='input-required'),
                            css_class='col-md-6'),
                        Div(Field(
                            'tax_id',
                            css_class='input-required',
                        ),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field(
                            'association_name',
                            css_class='input-required',
                        ),
                            css_class='col-md-6'),
                        Div(Field(
                            'type_e',
                            css_class='input-required',
                        ),
                            css_class='col-md-6'),
                    ),
                    Row(
                        Div(Field(
                            'solution',
                            css_class='input-required',
                        ),
                            css_class='col-md-6'), ),
                ),
                Tab(_('Image'), Field('logo', css_class="")),
            ),
            Row(
                Div(Field(
                    'acept',
                    css_class='input-required',
                ),
                    css_class='col-md-12'), ),
            Row(FormActions(
                smtSave(),
                btnCancel(),
                btnReset(),
            ), ),
        )