Browse Source

Adicona busca de autor na criação de documento acessório

pull/425/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
c25ef9ffa8
  1. 4
      materia/forms.py
  2. 24
      materia/views.py

4
materia/forms.py

@ -131,10 +131,6 @@ class DocumentoAcessorioForm(ModelForm):
if autor_field: if autor_field:
return str(Autor.objects.get(id=autor_field)) return str(Autor.objects.get(id=autor_field))
def __init__(self, *args, **kwargs):
super(DocumentoAcessorioForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
class RelatoriaForm(ModelForm): class RelatoriaForm(ModelForm):

24
materia/views.py

@ -166,14 +166,8 @@ class DocumentoAcessorioCrud(MasterDetailCrud):
class CreateView(MasterDetailCrud.CreateView): class CreateView(MasterDetailCrud.CreateView):
form_class = DocumentoAcessorioForm form_class = DocumentoAcessorioForm
<<<<<<< c9d78fc1838416100fa92533705a9f4c2985190e
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
======= super(CreateView, self).__init__(*args, **kwargs)
def get_form(self, form_class=None):
form = super(CreateView, self).get_form(form_class)
form.helper.layout = self.get_layout()
>>>>>>> Monta layout para autor
autor_row = crispy_layout_mixin.to_row( autor_row = crispy_layout_mixin.to_row(
[('autor', 0), [('autor', 0),
(Button('pesquisar', (Button('pesquisar',
@ -183,7 +177,6 @@ class DocumentoAcessorioCrud(MasterDetailCrud):
'Limpar Autor', 'Limpar Autor',
css_class='btn btn-primary btn-sm'), 10)]) css_class='btn btn-primary btn-sm'), 10)])
<<<<<<< c9d78fc1838416100fa92533705a9f4c2985190e
self.helper = FormHelper() self.helper = FormHelper()
self.helper.layout = crispy_layout_mixin.SaplFormLayout( self.helper.layout = crispy_layout_mixin.SaplFormLayout(
*self.get_layout()) *self.get_layout())
@ -202,18 +195,19 @@ class DocumentoAcessorioCrud(MasterDetailCrud):
' class="btn btn-inverse">Cancelar</a>')])) ' class="btn btn-inverse">Cancelar</a>')]))
super(CreateView, self).__init__(*args, **kwargs) super(CreateView, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
crispy_layout_mixin.to_row(self.get_layout()[0][1]),
HTML(sapl.utils.autor_label),
HTML(sapl.utils.autor_modal),
crispy_layout_mixin.to_row(self.get_layout()[0][2]),
crispy_layout_mixin.to_row(self.get_layout()[0][3]),
)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(CreateView, self).get_context_data(**kwargs) context = super(CreateView, self).get_context_data(**kwargs)
context['helper'] = self.helper context['helper'] = self.helper
return context return context
=======
form.helper.layout[0][2][0] = autor_row
form.helper.layout[0][1].append(HTML(sapl.utils.autor_label))
form.helper.layout[0][1].append(HTML(sapl.utils.autor_modal))
return form
>>>>>>> Monta layout para autor
class UpdateView(MasterDetailCrud.UpdateView): class UpdateView(MasterDetailCrud.UpdateView):
form_class = DocumentoAcessorioForm form_class = DocumentoAcessorioForm

Loading…
Cancel
Save