예제 #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
파일: forms.py 프로젝트: cpaja/dentalcool
    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
파일: forms.py 프로젝트: cpaja/dentalcool
    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
파일: forms.py 프로젝트: cpaja/dentalcool
    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
파일: forms.py 프로젝트: cpaja/dentalcool
    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
파일: forms.py 프로젝트: cpaja/dentalcool
    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
파일: forms.py 프로젝트: cpaja/dentalcool
    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):
        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(),
                ),
            ),
        )
예제 #21
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(),
                ),
            ),
        )
예제 #22
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(),
            ), ),
        )
예제 #23
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(),
                ),
            ),
        )
예제 #24
0
파일: forms.py 프로젝트: cpaja/dentalcool
    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(),
            ), ),
        )