From 33a65dc11614cc825b24f9b5fc6c5961e98680ba Mon Sep 17 00:00:00 2001 From: Eduardo Calil Date: Tue, 23 May 2017 19:01:55 -0300 Subject: [PATCH] Fix #1095 --- sapl/materia/models.py | 1 - sapl/materia/views.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sapl/materia/models.py b/sapl/materia/models.py index d5447095e..2db7c38d8 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -259,7 +259,6 @@ class MateriaLegislativa(models.Model): force_update=force_update, using=using, update_fields=update_fields) - @reversion.register() diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 2cb4d54f6..fa3e66970 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -187,6 +187,18 @@ class CriarProtocoloMateriaView(CreateView): def form_valid(self, form): materia = form.save() + + try: + protocolo = Protocolo.objects.get(pk=self.kwargs['pk']) + except ObjectDoesNotExist: + raise Http404() + + if protocolo.autor: + Autoria.objects.create( + materia=materia, + autor=protocolo.autor, + primeiro_autor=True) + return redirect(self.get_success_url(materia))