Browse Source

Fix #1856 (#1866)

pull/1894/head
Talitha Pumar 7 years ago
committed by Edward
parent
commit
94c0a7190f
  1. 8
      sapl/comissoes/forms.py
  2. 4
      sapl/comissoes/views.py

8
sapl/comissoes/forms.py

@ -13,10 +13,16 @@ from sapl.parlamentares.models import Legislatura, Mandato, Parlamentar
class ComposicaoForm(forms.ModelForm):
comissao = forms.CharField(required=False, label='Comissao', widget=forms.HiddenInput())
class Meta:
model = Composicao
exclude = []
def __init__(self, user=None, **kwargs):
super(ComposicaoForm, self).__init__(**kwargs)
self.fields['comissao'].widget.attrs['disabled'] = 'disabled'
def clean(self):
cleaned_data = super(ComposicaoForm, self).clean()
@ -24,7 +30,7 @@ class ComposicaoForm(forms.ModelForm):
return cleaned_data
periodo = cleaned_data['periodo']
comissao_pk = cleaned_data['comissao'].id
comissao_pk = self.initial['comissao'].id
intersecao_periodo = Composicao.objects.filter(
Q(periodo__data_inicio__lte=periodo.data_fim,
periodo__data_fim__gte=periodo.data_fim) |

4
sapl/comissoes/views.py

@ -90,6 +90,10 @@ class ComposicaoCrud(MasterDetailCrud):
class CreateView(MasterDetailCrud.CreateView):
form_class = ComposicaoForm
def get_initial(self):
comissao = Comissao.objects.get(id=self.kwargs['pk'])
return {'comissao': comissao}
class ListView(MasterDetailCrud.ListView):

Loading…
Cancel
Save