Browse Source

Arruma bug no layout

pull/6/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Luciano Almeida
parent
commit
5fef523351
  1. 5
      sigi/apps/crispy_layout_mixin.py
  2. 26
      sigi/apps/usuarios/forms.py
  3. 9
      sigi/apps/usuarios/layouts.yaml
  4. 3
      sigi/apps/usuarios/views.py

5
sigi/apps/crispy_layout_mixin.py

@ -42,10 +42,11 @@ def form_actions(more=[], save_label=_('Salvar')):
class FormLayout(Layout): class FormLayout(Layout):
def __init__(self, label_cancel=_("Cancelar"), *fields): def __init__(self, *fields):
buttons = form_actions(more=[ buttons = form_actions(more=[
HTML('<a href="{{ view.cancel_url }}"' HTML('<a href="{{ view.cancel_url }}"'
' class="btn btn-inverse">%s</a>' % label_cancel)]) ' class="btn btn-primary" style="background-color:black;">'
' Cancelar</a>')])
_fields = list(to_fieldsets(fields)) + [to_row([(buttons, 12)])] _fields = list(to_fieldsets(fields)) + [to_row([(buttons, 12)])]
super(FormLayout, self).__init__(*_fields) super(FormLayout, self).__init__(*_fields)

26
sigi/apps/usuarios/forms.py

@ -57,7 +57,10 @@ class UsuarioForm(ModelForm):
widget=forms.Select(), widget=forms.Select(),
choices=TIPO_TELEFONE, choices=TIPO_TELEFONE,
label=_(u'Tipo Telefone')) label=_(u'Tipo Telefone'))
segundo_ddd = forms.CharField(required=False, max_length=2, label=_(u'DDD')) segundo_ddd = forms.CharField(
required=False,
max_length=2,
label=_(u'DDD'))
segundo_numero = forms.CharField( segundo_numero = forms.CharField(
required=False, max_length=10, label=_(u'Número')) required=False, max_length=10, label=_(u'Número'))
segundo_principal = forms.ChoiceField( segundo_principal = forms.ChoiceField(
@ -86,12 +89,12 @@ class UsuarioForm(ModelForm):
class Meta(object): class Meta(object):
model = Usuario model = Usuario
fields = [u'username', u'email', u'nome_completo', u'password', u'vinculo', fields = [u'username', u'email', u'nome_completo', u'password',
u'password_confirm', u'email_confirm', u'captcha', u'cpf', u'rg', u'vinculo', u'password_confirm', u'email_confirm',
u'cargo', u'casa_legislativa'] u'captcha', u'cpf', u'rg', u'cargo', u'casa_legislativa']
widgets = {u'email': forms.TextInput( widgets = {u'email': forms.TextInput(
attrs={u'style': u'text-transform:lowercase;'}),} attrs={u'style': u'text-transform:lowercase;'}), }
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(UsuarioForm, self).__init__(*args, **kwargs) super(UsuarioForm, self).__init__(*args, **kwargs)
@ -210,10 +213,12 @@ class UsuarioEditForm(UsuarioForm):
fields = [u'username', u'email', u'nome_completo', u'vinculo', fields = [u'username', u'email', u'nome_completo', u'vinculo',
u'email_confirm', u'captcha', u'cpf', u'rg', u'email_confirm', u'captcha', u'cpf', u'rg',
u'cargo', u'casa_legislativa'] u'cargo', u'casa_legislativa']
widgets = {u'username': forms.TextInput(attrs={u'readonly': u'readonly'}), widgets = {u'username': forms.TextInput(
u'email': forms.TextInput( attrs={u'readonly': u'readonly'}),
attrs={u'style': u'text-transform:lowercase;'}), u'email': forms.TextInput(
} attrs={u'style': u'text-transform:lowercase;'}
),
}
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(UsuarioEditForm, self).__init__(*args, **kwargs) super(UsuarioEditForm, self).__init__(*args, **kwargs)
@ -307,7 +312,8 @@ class HabilitarEditForm(ModelForm):
fields = [u'cpf', u'nome_completo', u'email', u'habilitado'] fields = [u'cpf', u'nome_completo', u'email', u'habilitado']
widgets = { widgets = {
u'cpf': forms.TextInput(attrs={u'readonly': u'readonly'}), u'cpf': forms.TextInput(attrs={u'readonly': u'readonly'}),
u'nome_completo': forms.TextInput(attrs={u'readonly': u'readonly'}), u'nome_completo': forms.TextInput(attrs={u'readonly': u'readonly'}
),
u'email': forms.TextInput(attrs={u'readonly': u'readonly'}) u'email': forms.TextInput(attrs={u'readonly': u'readonly'})
} }

9
sigi/apps/usuarios/layouts.yaml

@ -1,4 +1,3 @@
CasaLegislativa: CasaLegislativa:
Casa Legislativa: Casa Legislativa:
- sigla:4 nome - sigla:4 nome
@ -13,18 +12,18 @@ Subsecretaria:
- nome:8 sigla - nome:8 sigla
Usuario: Usuario:
Usuário: Dados do Usuário:
- username nome_completo:9 - username nome_completo:9
- password password_confirm - password password_confirm
- email email_confirm - email email_confirm
- cpf rg casa_legislativa - cpf rg casa_legislativa
- cargo vinculo - cargo vinculo
Primeiro Telefone: Primeiro Telefone:
- primeiro_tipo primeiro_ddd:2 primeiro_numero:6 primeiro_principal - primeiro_tipo primeiro_ddd:2 primeiro_numero:6 primeiro_principal
Segundo Telefone: Segundo Telefone:
- segundo_tipo segundo_ddd:2 segundo_numero:6 segundo_principal - segundo_tipo segundo_ddd:2 segundo_numero:6 segundo_principal
Prove que você é um humano: Prove que você é um humano:
- captcha - captcha
UsuarioEdit: UsuarioEdit:
Usuário: Usuário:

3
sigi/apps/usuarios/views.py

@ -12,7 +12,8 @@ from sigi.apps.crud.utils import str2bool
from django.contrib.auth.tokens import default_token_generator from django.contrib.auth.tokens import default_token_generator
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.utils.encoding import force_bytes from django.utils.encoding import force_bytes
from sigi.apps.crud.base import Crud, CrudBaseMixin, CrudCreateView, CrudListView, CrudUpdateView, CrudDetailView from sigi.apps.crud.base import (Crud, CrudBaseMixin, CrudCreateView,
CrudListView, CrudUpdateView, CrudDetailView)
from .forms import (HabilitarEditForm, MudarSenhaForm, UsuarioEditForm, from .forms import (HabilitarEditForm, MudarSenhaForm, UsuarioEditForm,
UsuarioForm) UsuarioForm)

Loading…
Cancel
Save