Browse Source

Fix #1791 (#1805)

pull/1811/head
Victor Fabre 7 years ago
committed by Edward
parent
commit
dd8f3b5ecd
  1. 18
      sapl/comissoes/forms.py
  2. 6
      sapl/comissoes/views.py

18
sapl/comissoes/forms.py

@ -161,6 +161,19 @@ class ComissaoForm(forms.ModelForm):
model = Comissao
fields = '__all__'
def __init__(self, user=None, **kwargs):
super(ComissaoForm, self).__init__(**kwargs)
inst = self.instance
if inst.pk:
if inst.tipo.natureza == 'P':
self.fields['apelido_temp'].widget.attrs['disabled'] = 'disabled'
self.fields['data_instalacao_temp'].widget.attrs['disabled'] = 'disabled'
self.fields['data_final_prevista_temp'].widget.attrs['disabled'] = 'disabled'
self.fields['data_prorrogada_temp'].widget.attrs['disabled'] = 'disabled'
self.fields['data_fim_comissao'].widget.attrs['disabled'] = 'disabled'
def clean(self):
super(ComissaoForm, self).clean()
@ -176,6 +189,8 @@ class ComissaoForm(forms.ModelForm):
@transaction.atomic
def save(self, commit=True):
inst = self.instance
if not inst.pk:
comissao = super(ComissaoForm, self).save(commit)
content_type = ContentType.objects.get_for_model(Comissao)
object_id = comissao.pk
@ -188,6 +203,9 @@ class ComissaoForm(forms.ModelForm):
nome=nome
)
return comissao
else:
comissao = super(ComissaoForm, self).save(commit)
return comissao
class ReuniaoForm(ModelForm):

6
sapl/comissoes/views.py

@ -131,6 +131,12 @@ class ComissaoCrud(Crud):
def form_valid(self, form):
return super(Crud.CreateView, self).form_valid(form)
class UpdateView(Crud.UpdateView):
form_class = ComissaoForm
def form_valid(self, form):
return super(Crud.UpdateView, self).form_valid(form)
class MateriasTramitacaoListView(ListView):
template_name = "comissoes/materias_em_tramitacao.html"

Loading…
Cancel
Save