diff --git a/sapl/parlamentares/forms.py b/sapl/parlamentares/forms.py index fe21aeb2c..f618c4421 100644 --- a/sapl/parlamentares/forms.py +++ b/sapl/parlamentares/forms.py @@ -8,8 +8,8 @@ from django.forms import ModelForm from django.utils.translation import ugettext_lazy as _ from floppyforms.widgets import ClearableFileInput -from .models import (ComposicaoColigacao, Filiacao, Legislatura, Mandato, - Parlamentar) +from .models import (ComposicaoColigacao, Filiacao, Frente, Legislatura, + Mandato, Parlamentar) class ImageThumbnailFileInput(ClearableFileInput): @@ -175,3 +175,15 @@ class ComposicaoColigacaoForm(ModelForm): if self.errors: return self.errors return self.cleaned_data + + +class FrenteForm(ModelForm): + + def __init__(self, *args, **kwargs): + super(FrenteForm, self).__init__(*args, **kwargs) + self.fields['parlamentares'].queryset = Parlamentar.objects.filter( + ativo=True).order_by('nome_completo') + + class Meta: + model = Frente + fields = '__all__' diff --git a/sapl/parlamentares/migrations/0027_merge.py b/sapl/parlamentares/migrations/0027_merge.py new file mode 100644 index 000000000..f71a6160b --- /dev/null +++ b/sapl/parlamentares/migrations/0027_merge.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-09-16 14:44 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('parlamentares', '0026_auto_20160916_1034'), + ('parlamentares', '0025_auto_20160916_1030'), + ] + + operations = [ + ] diff --git a/sapl/parlamentares/views.py b/sapl/parlamentares/views.py index 93f95e46c..11e0bb481 100644 --- a/sapl/parlamentares/views.py +++ b/sapl/parlamentares/views.py @@ -17,8 +17,8 @@ from sapl.crud.masterdetail import MasterDetailCrud from sapl.materia.models import Proposicao, Relatoria from sapl.utils import permissao_tb_aux, permissoes_parlamentares -from .forms import (ComposicaoColigacaoForm, FiliacaoForm, LegislaturaForm, - ParlamentarCreateForm, ParlamentarForm) +from .forms import (ComposicaoColigacaoForm, FiliacaoForm, FrenteForm, + LegislaturaForm, ParlamentarCreateForm, ParlamentarForm) from .models import (CargoMesa, Coligacao, ComposicaoColigacao, ComposicaoMesa, Dependente, Filiacao, Frente, Legislatura, Mandato, NivelInstrucao, Parlamentar, Partido, SessaoLegislativa, @@ -29,21 +29,17 @@ class FrenteCrud(Crud): model = Frente help_path = '' + class BaseMixin(CrudBaseMixin): + permission_required = permissoes_parlamentares() + list_field_names = ['nome', 'data_criacao', 'parlamentares'] + class CreateView(PermissionRequiredMixin, CrudCreateView): permission_required = permissoes_parlamentares() + form_class = FrenteForm - # def get_initial(self): - # return {'parlamentares': Parlamentar.objects.filter(ativo=True)} - - # class UpdateView(PermissionRequiredMixin, CrudUpdateView): - # permission_required = permissoes_parlamentares() - # - # def get_initial(self): - # initial = self.initial.copy() - # if self.object.materia: - # initial['parlamentares'] = Parlamentar.object.filter( - # ativo=True) - # return initial + class UpdateView(PermissionRequiredMixin, CrudUpdateView): + permission_required = permissoes_parlamentares() + form_class = FrenteForm class RelatoriaParlamentarCrud(MasterDetailCrud): diff --git a/sapl/templates/sistema.html b/sapl/templates/sistema.html index cc28d831d..3ea597111 100644 --- a/sapl/templates/sistema.html +++ b/sapl/templates/sistema.html @@ -7,6 +7,7 @@
+