Browse Source

Pré-preenche campo casa do usuário e torna readonly

pull/6/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
committed by Luciano Almeida
parent
commit
4b9b4739eb
  1. 9
      sigi/apps/solicitacoes/forms.py
  2. 1
      sigi/apps/solicitacoes/views.py

9
sigi/apps/solicitacoes/forms.py

@ -42,8 +42,13 @@ class SolicitacaoForm(ModelForm):
fields = [u'codigo', u'usuario', u'sistema', fields = [u'codigo', u'usuario', u'sistema',
u'email_contato', u'telefone_contato', u'email_contato', u'telefone_contato',
u'casa_legislativa', u'titulo', u'resumo'] u'casa_legislativa', u'titulo', u'resumo']
widgets = {u'codigo': forms.HiddenInput(), widgets = {
u'usuario': forms.HiddenInput()} u'codigo': forms.HiddenInput(),
u'usuario': forms.HiddenInput(),
u'casa_legislativa': forms.TextInput(attrs={'readonly':'readonly'}),
u'email_contato': forms.TextInput(attrs={'readonly':'readonly'}),
u'telefone_contato': forms.TextInput(attrs={'readonly':'readonly'})
}
@transaction.atomic @transaction.atomic
def save(self, commit=False): def save(self, commit=False):

1
sigi/apps/solicitacoes/views.py

@ -26,6 +26,7 @@ class SolicitacaoCrud(LoginRequiredMixin, Crud):
self.initial[u'codigo'] = random.randint(0, 65500) self.initial[u'codigo'] = random.randint(0, 65500)
self.initial[u'email_contato'] = usuario.email self.initial[u'email_contato'] = usuario.email
self.initial[u'telefone_contato'] = usuario.primeiro_telefone self.initial[u'telefone_contato'] = usuario.primeiro_telefone
self.initial[u'casa_legislativa'] = usuario.casa_legislativa
except Usuario.DoesNotExist: except Usuario.DoesNotExist:
pass pass
return self.initial.copy() return self.initial.copy()

Loading…
Cancel
Save