Browse Source

Revisão de campos na reserva de espaços. Gertiq #169979

pull/169/head
Sesóstris Vieira 1 year ago
parent
commit
602fede9dd
  1. 29
      sigi/apps/espacos/admin.py
  2. 71
      sigi/apps/espacos/migrations/0003_reserva_data_pedido_reserva_num_processo_and_more.py
  3. 40
      sigi/apps/espacos/models.py
  4. 10
      sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html

29
sigi/apps/espacos/admin.py

@ -1,5 +1,6 @@
from django.contrib import admin, messages from django.contrib import admin, messages
from django.urls import path, reverse from django.urls import path, reverse
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _, ngettext from django.utils.translation import gettext as _, ngettext
from django.shortcuts import get_object_or_404, redirect from django.shortcuts import get_object_or_404, redirect
from import_export.fields import Field from import_export.fields import Field
@ -68,16 +69,23 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin):
list_display = [ list_display = [
"get_status", "get_status",
"proposito", "proposito",
"get_link_sigad",
"get_espaco", "get_espaco",
"inicio", "inicio",
"termino", "termino",
"virtual",
"solicitante", "solicitante",
"contato", "contato",
"telefone_contato", "telefone_contato",
] ]
list_display_links = ["get_status", "proposito"] list_display_links = ["get_status", "proposito"]
list_filter = ["status", "espaco"] list_filter = ["status", "espaco", "virtual"]
search_fields = ["proposito", "espaco__nome", "espaco__sigla"] search_fields = [
"proposito",
"espaco__nome",
"espaco__sigla",
"num_processo",
]
date_hierarchy = "inicio" date_hierarchy = "inicio"
actions = ["cancelar_action", "reativar_action"] actions = ["cancelar_action", "reativar_action"]
fieldsets = [ fieldsets = [
@ -88,6 +96,17 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin):
"fields": ( "fields": (
"espaco", "espaco",
"proposito", "proposito",
"num_processo",
"virtual",
"data_pedido",
"total_participantes",
)
},
),
(
_("Detalhes"),
{
"fields": (
"inicio", "inicio",
"termino", "termino",
"informacoes", "informacoes",
@ -123,6 +142,12 @@ class ReservaAdmin(CartExportMixin, admin.ModelAdmin):
def get_espaco(self, obj): def get_espaco(self, obj):
return obj.espaco.sigla 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): def cancelar_reserva(self, request, object_id):
reserva = get_object_or_404(Reserva, id=object_id) reserva = get_object_or_404(Reserva, id=object_id)
reserva.status = Reserva.STATUS_CANCELADO reserva.status = Reserva.STATUS_CANCELADO

71
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:<em>XXXXX.XXXXXX/XXXX-XX</em>",
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"),
),
]

40
sigi/apps/espacos/models.py

@ -1,3 +1,4 @@
import re
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import models from django.db import models
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
@ -48,7 +49,7 @@ class Reserva(models.Model):
) )
status = models.CharField( status = models.CharField(
_("Status"), _("status"),
max_length=1, max_length=1,
choices=STATUS_CHOICES, choices=STATUS_CHOICES,
default=STATUS_ATIVO, default=STATUS_ATIVO,
@ -65,8 +66,19 @@ class Reserva(models.Model):
"reunião, aula, apresentação, etc.)" "reunião, aula, apresentação, etc.)"
), ),
) )
inicio = models.DateTimeField(_("Data/hora de início")) virtual = models.BooleanField(_("virtual"), default=False)
termino = models.DateTimeField(_("Data/hora de término")) 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:<em>XXXXX.XXXXXX/XXXX-XX</em>"),
)
informacoes = models.TextField( informacoes = models.TextField(
_("informações adicionais"), _("informações adicionais"),
blank=True, blank=True,
@ -76,10 +88,11 @@ class Reserva(models.Model):
), ),
) )
solicitante = models.CharField( solicitante = models.CharField(
_("solicitante"), _("senador/autoridade solicitante"),
max_length=100, max_length=100,
help_text=_( 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( contato = models.CharField(
@ -130,6 +143,23 @@ class Reserva(models.Model):
) )
return super().clean() return super().clean()
def get_sigad_url(self):
m = re.match(
"(?P<orgao>00100|00200)\.(?P<sequencial>\d{6})/(?P<ano>"
"\d{4})-\d{2}",
self.num_processo,
)
if m:
return (
'<a href="https://intra.senado.leg.br/'
"sigad/novo/protocolo/impressao.asp?area=processo"
"&txt_numero_orgao={orgao}"
"&txt_numero_sequencial={sequencial}"
'&txt_numero_ano={ano}"'
' target="_blank">{processo}</a>'
).format(processo=self.num_processo, **m.groupdict())
return self.num_processo
class RecursoSolicitado(models.Model): class RecursoSolicitado(models.Model):
reserva = models.ForeignKey( reserva = models.ForeignKey(

10
sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html

@ -4,10 +4,14 @@
<thead> <thead>
<tr> <tr>
<th rowspan="2">{% trans "Espaço" %}</th> <th rowspan="2">{% trans "Espaço" %}</th>
<th rowspan="2">{% trans "SIGAD" %}</th>
<th rowspan="2">{% trans "Data pedido" %}</th>
<th rowspan="2">{% trans "Virtual" %}</th>
<th rowspan="2">{% trans "Data início" %}</th> <th rowspan="2">{% trans "Data início" %}</th>
<th rowspan="2">{% trans "Data término" %}</th> <th rowspan="2">{% trans "Data término" %}</th>
<th rowspan="2">{% trans "Propósito" %}</th> <th rowspan="2">{% trans "Propósito" %}</th>
<th rowspan="2">{% trans "Solicitante" %}</th> <th rowspan="2">{% trans "Total participantes" %}</th>
<th rowspan="2">{% trans "Autoridade solicitante" %}</th>
<th colspan="2">{% trans "Contato" %}</th> <th colspan="2">{% trans "Contato" %}</th>
<th rowspan="2">{% trans "Informações adicionais" %}</th> <th rowspan="2">{% trans "Informações adicionais" %}</th>
<th rowspan="2">{% trans "Recursos solicitados" %}</th> <th rowspan="2">{% trans "Recursos solicitados" %}</th>
@ -23,9 +27,13 @@
{% ifchanged reserva.espaco %} {% ifchanged reserva.espaco %}
<th rowspan="{{ rowspans|get:reserva.espaco.id }}">{{ reserva.espaco.nome }}</th> <th rowspan="{{ rowspans|get:reserva.espaco.id }}">{{ reserva.espaco.nome }}</th>
{% endifchanged %} {% endifchanged %}
<td>{{ reserva.num_processo }}</td>
<td>{{ reserva.data_pedido|default:"-" }}</td>
<td>{{ reserva.virtual|yesno }}</td>
<td>{{ reserva.inicio }}</td> <td>{{ reserva.inicio }}</td>
<td>{{ reserva.termino }}</td> <td>{{ reserva.termino }}</td>
<td>{{ reserva.proposito }}</td> <td>{{ reserva.proposito }}</td>
<td>{{ reserva.total_participantes|default:"-" }}</td>
<td>{{ reserva.solicitante }}</td> <td>{{ reserva.solicitante }}</td>
<td>{{ reserva.contato }}</td> <td>{{ reserva.contato }}</td>
<td>{{ reserva.telefone_contato }}</td> <td>{{ reserva.telefone_contato }}</td>

Loading…
Cancel
Save