diff --git a/sapl/materia/migrations/0083_auto_20230731_1845.py b/sapl/materia/migrations/0083_auto_20230731_1845.py new file mode 100644 index 000000000..d286e0be1 --- /dev/null +++ b/sapl/materia/migrations/0083_auto_20230731_1845.py @@ -0,0 +1,31 @@ +# Generated by Django 2.2.28 on 2023-07-31 21:45 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('materia', '0082_auto_20230529_1641'), + ] + + operations = [ + migrations.AddField( + model_name='proposicao', + name='usuario_devolucao', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='proposicoes_devolvidas', to=settings.AUTH_USER_MODEL, verbose_name='Usuário Responsável pela Devolução'), + ), + migrations.AddField( + model_name='proposicao', + name='usuario_envio', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='proposicoes_enviadas', to=settings.AUTH_USER_MODEL, verbose_name='Usuário Responsável pelo Envio'), + ), + migrations.AddField( + model_name='proposicao', + name='usuario_recebimento', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='proposicoes_recebidas', to=settings.AUTH_USER_MODEL, verbose_name='Usuário Responsável pelo Recebimento'), + ), + ] diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 24ee55d16..14b62196b 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -780,6 +780,33 @@ class Proposicao(models.Model): verbose_name=_('Data de Devolução') ) + usuario_envio = models.ForeignKey( + get_settings_auth_user_model(), + verbose_name=_('Usuário Responsável pelo Envio'), + on_delete=models.PROTECT, + related_name='proposicoes_enviadas', + blank=True, + null=True + ) + + usuario_recebimento = models.ForeignKey( + get_settings_auth_user_model(), + verbose_name=_('Usuário Responsável pelo Recebimento'), + on_delete=models.PROTECT, + related_name='proposicoes_recebidas', + blank=True, + null=True + ) + + usuario_devolucao = models.ForeignKey( + get_settings_auth_user_model(), + verbose_name=_('Usuário Responsável pela Devolução'), + on_delete=models.PROTECT, + related_name='proposicoes_devolvidas', + blank=True, + null=True + ) + descricao = models.TextField(verbose_name=_('Ementa')) justificativa_devolucao = models.CharField( @@ -993,6 +1020,13 @@ class Proposicao(models.Model): def save(self, force_insert=False, force_update=False, using=None, update_fields=None): + # atualiza o usuario baseado no status da proposição (que esta sendo calculado pela data) + if self.data_envio is not None and not self.usuario_envio: + self.usuario_envio = self.user + elif self.data_recebimento is not None and not self.usuario_recebimento: + self.usuario_recebimento = self.user + elif self.data_devolucao is not None and not self.usuario_devolucao: + self.usuario_devolucao = self.user if not self.pk and self.texto_original: texto_original = self.texto_original diff --git a/sapl/templates/materia/proposicao_detail.html b/sapl/templates/materia/proposicao_detail.html index ea1ab76fb..6eba44b14 100644 --- a/sapl/templates/materia/proposicao_detail.html +++ b/sapl/templates/materia/proposicao_detail.html @@ -114,7 +114,14 @@
Enviada por