Browse Source

HOT-FIX: Adiciona Autor como PrimeiroAutor ao criar Materia Legislativa

pull/2847/head
Cesar Carvalho 6 years ago
parent
commit
28139f6a78
  1. 2
      sapl/materia/forms.py
  2. 11
      sapl/materia/views.py

2
sapl/materia/forms.py

@ -285,7 +285,7 @@ class MateriaLegislativaForm(FileFieldCheckMixin, ModelForm):
materia = super(MateriaLegislativaForm, self).save(commit)
materia.save()
if self.cleaned_data['autor']:
autoria = Autoria()
autoria.primeiro_autor = primeiro_autor

11
sapl/materia/views.py

@ -1619,14 +1619,13 @@ class MateriaLegislativaCrud(Crud):
form_class = MateriaLegislativaForm
def form_valid(self, form):
self.object = form.instance
def get_initial(self):
initial = super(CreateView, self).get_initial()
self.object.user = self.request.user
self.object.ip = get_client_ip(self.request)
self.object.save()
initial['user'] = self.request.user
initial['ip'] = get_client_ip(self.request)
return super().form_valid(form)
return initial
@property
def cancel_url(self):

Loading…
Cancel
Save