From 602fede9dd3783c6a83ffc67e2e40593553166d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Tue, 28 Nov 2023 16:17:09 -0300 Subject: [PATCH] =?UTF-8?q?Revis=C3=A3o=20de=20campos=20na=20reserva=20de?= =?UTF-8?q?=20espa=C3=A7os.=20Gertiq=20#169979?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/apps/espacos/admin.py | 29 +++++++- ...ta_pedido_reserva_num_processo_and_more.py | 71 +++++++++++++++++++ sigi/apps/espacos/models.py | 40 +++++++++-- .../espacos/snippets/uso_espaco_snippet.html | 10 ++- 4 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 sigi/apps/espacos/migrations/0003_reserva_data_pedido_reserva_num_processo_and_more.py diff --git a/sigi/apps/espacos/admin.py b/sigi/apps/espacos/admin.py index 9f0844b..aea8763 100644 --- a/sigi/apps/espacos/admin.py +++ b/sigi/apps/espacos/admin.py @@ -1,5 +1,6 @@ from django.contrib import admin, messages from django.urls import path, reverse +from django.utils.safestring import mark_safe from django.utils.translation import gettext as _, ngettext from django.shortcuts import get_object_or_404, redirect from import_export.fields import Field @@ -68,16 +69,23 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin): list_display = [ "get_status", "proposito", + "get_link_sigad", "get_espaco", "inicio", "termino", + "virtual", "solicitante", "contato", "telefone_contato", ] list_display_links = ["get_status", "proposito"] - list_filter = ["status", "espaco"] - search_fields = ["proposito", "espaco__nome", "espaco__sigla"] + list_filter = ["status", "espaco", "virtual"] + search_fields = [ + "proposito", + "espaco__nome", + "espaco__sigla", + "num_processo", + ] date_hierarchy = "inicio" actions = ["cancelar_action", "reativar_action"] fieldsets = [ @@ -88,6 +96,17 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin): "fields": ( "espaco", "proposito", + "num_processo", + "virtual", + "data_pedido", + "total_participantes", + ) + }, + ), + ( + _("Detalhes"), + { + "fields": ( "inicio", "termino", "informacoes", @@ -123,6 +142,12 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin): def get_espaco(self, obj): return obj.espaco.sigla + @admin.display(description=_("SIGAD"), ordering="num_processo") + def get_link_sigad(self, obj): + if obj.pk is None: + return "" + return mark_safe(obj.get_sigad_url()) + def cancelar_reserva(self, request, object_id): reserva = get_object_or_404(Reserva, id=object_id) reserva.status = Reserva.STATUS_CANCELADO diff --git a/sigi/apps/espacos/migrations/0003_reserva_data_pedido_reserva_num_processo_and_more.py b/sigi/apps/espacos/migrations/0003_reserva_data_pedido_reserva_num_processo_and_more.py new file mode 100644 index 0000000..6fd2a7c --- /dev/null +++ b/sigi/apps/espacos/migrations/0003_reserva_data_pedido_reserva_num_processo_and_more.py @@ -0,0 +1,71 @@ +# Generated by Django 4.2.4 on 2023-11-28 18:45 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("espacos", "0002_converte_eventos"), + ] + + operations = [ + migrations.AddField( + model_name="reserva", + name="data_pedido", + field=models.DateField( + blank=True, null=True, verbose_name="data do pedido" + ), + ), + migrations.AddField( + model_name="reserva", + name="num_processo", + field=models.CharField( + blank=True, + help_text="Formato:XXXXX.XXXXXX/XXXX-XX", + max_length=20, + verbose_name="número do processo SIGAD", + ), + ), + migrations.AddField( + model_name="reserva", + name="total_participantes", + field=models.PositiveIntegerField( + default=0, verbose_name="total de participantes" + ), + ), + migrations.AddField( + model_name="reserva", + name="virtual", + field=models.BooleanField(default=False, verbose_name="virtual"), + ), + migrations.AlterField( + model_name="reserva", + name="inicio", + field=models.DateTimeField(verbose_name="data/hora de início"), + ), + migrations.AlterField( + model_name="reserva", + name="solicitante", + field=models.CharField( + help_text="indique o nome do Senador, autoridade, pessoa ou setor solicitante da reserva", + max_length=100, + verbose_name="senador/autoridade solicitante", + ), + ), + migrations.AlterField( + model_name="reserva", + name="status", + field=models.CharField( + choices=[("A", "Ativo"), ("C", "Cancelado")], + default="A", + editable=False, + max_length=1, + verbose_name="status", + ), + ), + migrations.AlterField( + model_name="reserva", + name="termino", + field=models.DateTimeField(verbose_name="data/hora de término"), + ), + ] diff --git a/sigi/apps/espacos/models.py b/sigi/apps/espacos/models.py index 9249205..36600f5 100644 --- a/sigi/apps/espacos/models.py +++ b/sigi/apps/espacos/models.py @@ -1,3 +1,4 @@ +import re from django.core.exceptions import ValidationError from django.db import models from django.utils.translation import gettext as _ @@ -48,7 +49,7 @@ class Reserva(models.Model): ) status = models.CharField( - _("Status"), + _("status"), max_length=1, choices=STATUS_CHOICES, default=STATUS_ATIVO, @@ -65,8 +66,19 @@ class Reserva(models.Model): "reunião, aula, apresentação, etc.)" ), ) - inicio = models.DateTimeField(_("Data/hora de início")) - termino = models.DateTimeField(_("Data/hora de término")) + virtual = models.BooleanField(_("virtual"), default=False) + total_participantes = models.PositiveIntegerField( + _("total de participantes"), default=0 + ) + data_pedido = models.DateField(_("data do pedido"), blank=True, null=True) + inicio = models.DateTimeField(_("data/hora de início")) + termino = models.DateTimeField(_("data/hora de término")) + num_processo = models.CharField( + _("número do processo SIGAD"), + max_length=20, + blank=True, + help_text=_("Formato:XXXXX.XXXXXX/XXXX-XX"), + ) informacoes = models.TextField( _("informações adicionais"), blank=True, @@ -76,10 +88,11 @@ class Reserva(models.Model): ), ) solicitante = models.CharField( - _("solicitante"), + _("senador/autoridade solicitante"), max_length=100, help_text=_( - "indique o nome da pessoa ou setor solicitante da reserva" + "indique o nome do Senador, autoridade, pessoa ou setor " + "solicitante da reserva" ), ) contato = models.CharField( @@ -130,6 +143,23 @@ class Reserva(models.Model): ) return super().clean() + def get_sigad_url(self): + m = re.match( + "(?P00100|00200)\.(?P\d{6})/(?P" + "\d{4})-\d{2}", + self.num_processo, + ) + if m: + return ( + '{processo}' + ).format(processo=self.num_processo, **m.groupdict()) + return self.num_processo + class RecursoSolicitado(models.Model): reserva = models.ForeignKey( diff --git a/sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html b/sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html index 3f21eb3..55f4d68 100644 --- a/sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html +++ b/sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html @@ -4,10 +4,14 @@ {% trans "Espaço" %} + {% trans "SIGAD" %} + {% trans "Data pedido" %} + {% trans "Virtual" %} {% trans "Data início" %} {% trans "Data término" %} {% trans "Propósito" %} - {% trans "Solicitante" %} + {% trans "Total participantes" %} + {% trans "Autoridade solicitante" %} {% trans "Contato" %} {% trans "Informações adicionais" %} {% trans "Recursos solicitados" %} @@ -23,9 +27,13 @@ {% ifchanged reserva.espaco %} {{ reserva.espaco.nome }} {% endifchanged %} + {{ reserva.num_processo }} + {{ reserva.data_pedido|default:"-" }} + {{ reserva.virtual|yesno }} {{ reserva.inicio }} {{ reserva.termino }} {{ reserva.proposito }} + {{ reserva.total_participantes|default:"-" }} {{ reserva.solicitante }} {{ reserva.contato }} {{ reserva.telefone_contato }}