Browse Source

Fix 1104 (#1110)

pull/1113/head
Rogério Frá 8 years ago
committed by Edward
parent
commit
32ee9220c9
  1. 12
      sapl/materia/forms.py
  2. 4
      sapl/materia/views.py
  3. 2
      sapl/templates/materia/documentoacessorio_form.html

12
sapl/materia/forms.py

@ -164,18 +164,6 @@ class DocumentoAcessorioForm(ModelForm):
class Meta: class Meta:
model = DocumentoAcessorio model = DocumentoAcessorio
fields = ['tipo', 'nome', 'data', 'autor', 'ementa', 'arquivo'] fields = ['tipo', 'nome', 'data', 'autor', 'ementa', 'arquivo']
widgets = {'autor': forms.HiddenInput()}
def clean_autor(self):
autor_field = self.cleaned_data['autor']
try:
int(autor_field)
except ValueError:
return autor_field
else:
if autor_field:
return str(Autor.objects.get(id=autor_field))
class RelatoriaForm(ModelForm): class RelatoriaForm(ModelForm):

4
sapl/materia/views.py

@ -963,25 +963,21 @@ class DocumentoAcessorioCrud(MasterDetailCrud):
form_class = DocumentoAcessorioForm form_class = DocumentoAcessorioForm
def __init__(self, **kwargs): def __init__(self, **kwargs):
montar_helper_documento_acessorio(self)
super(MasterDetailCrud.CreateView, self).__init__(**kwargs) super(MasterDetailCrud.CreateView, self).__init__(**kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super( context = super(
MasterDetailCrud.CreateView, self).get_context_data(**kwargs) MasterDetailCrud.CreateView, self).get_context_data(**kwargs)
context['helper'] = self.helper
return context return context
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
form_class = DocumentoAcessorioForm form_class = DocumentoAcessorioForm
def __init__(self, **kwargs): def __init__(self, **kwargs):
montar_helper_documento_acessorio(self)
super(MasterDetailCrud.UpdateView, self).__init__(**kwargs) super(MasterDetailCrud.UpdateView, self).__init__(**kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(UpdateView, self).get_context_data(**kwargs) context = super(UpdateView, self).get_context_data(**kwargs)
context['helper'] = self.helper
return context return context

2
sapl/templates/materia/documentoacessorio_form.html

@ -2,5 +2,5 @@
{% load i18n crispy_forms_tags %} {% load i18n crispy_forms_tags %}
{% block base_content %} {% block base_content %}
{% crispy form helper %} {% crispy form %}
{% endblock %} {% endblock %}

Loading…
Cancel
Save