Browse Source

Fix #1265 autoria filtrar tipo (#1272)

* Fixes #1265

* WIP
pull/1315/head
Eduardo Calil 8 years ago
committed by Edward
parent
commit
9374dff90c
  1. 24
      sapl/materia/forms.py
  2. 4
      sapl/materia/views.py
  3. 8
      sapl/templates/materia/layouts.yaml

24
sapl/materia/forms.py

@ -13,7 +13,7 @@ from django.core.files.base import File
from django.core.urlresolvers import reverse
from django.db import models, transaction
from django.db.models import Max
from django.forms import ModelForm, widgets
from django.forms import ModelForm, ModelChoiceField, widgets
from django.forms.forms import Form
from django.forms.widgets import Select
from django.utils import six
@ -26,7 +26,7 @@ from django_filters.filterset import STRICTNESS
import django_filters
from sapl.base.models import Autor
from sapl.base.models import Autor, TipoAutor
from sapl.comissoes.models import Comissao
from sapl.compilacao.models import (STATUS_TA_IMMUTABLE_PUBLIC,
STATUS_TA_PRIVATE)
@ -691,9 +691,27 @@ class DespachoInicialForm(ModelForm):
class AutoriaForm(ModelForm):
tipo_autor = ModelChoiceField(label=_('Tipo Autor'),
required=False,
queryset=
TipoAutor.objects.all().order_by('descricao'),
empty_label='Selecione',)
def __init__(self, *args, **kwargs):
super(AutoriaForm, self).__init__(*args, **kwargs)
row1 = to_row([('tipo_autor', 4),
('autor', 4),
('primeiro_autor', 4)])
self.helper = FormHelper()
self.helper.layout = Layout(
Fieldset(_('Autoria'),
row1, form_actions(save_label='Salvar')))
class Meta:
model = Autoria
fields = ['autor', 'primeiro_autor']
fields = ['tipo_autor', 'autor', 'primeiro_autor']
def clean(self):
super(AutoriaForm, self).clean()

4
sapl/materia/views.py

@ -1089,6 +1089,10 @@ class AutoriaCrud(MasterDetailCrud):
class CreateView(MasterDetailCrud.CreateView):
form_class = AutoriaForm
@property
def layout_key(self):
return 'AutoriaCreate'
def get_context_data(self, **kwargs):
context = super(CreateView, self).get_context_data(**kwargs)
autores_ativos = self.autores_ativos()

8
sapl/templates/materia/layouts.yaml

@ -61,6 +61,14 @@ Autoria:
{% trans 'Autoria' %}:
- autor primeiro_autor
AutoriaCreate:
{% trans 'Autoria' %}:
- tipo_autor autor primeiro_autor
AutoriaUpdate:
{% trans 'Autoria' %}:
- tipo_autor autor primeiro_autor
DocumentoAcessorio:
{% trans 'Documento Acessório' %}:
- tipo nome data

Loading…
Cancel
Save