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.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

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.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:<em>XXXXX.XXXXXX/XXXX-XX</em>"),
)
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(
"(?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):
reserva = models.ForeignKey(

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

@ -4,10 +4,14 @@
<thead>
<tr>
<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 término" %}</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 rowspan="2">{% trans "Informações adicionais" %}</th>
<th rowspan="2">{% trans "Recursos solicitados" %}</th>
@ -23,9 +27,13 @@
{% ifchanged reserva.espaco %}
<th rowspan="{{ rowspans|get:reserva.espaco.id }}">{{ reserva.espaco.nome }}</th>
{% endifchanged %}
<td>{{ reserva.num_processo }}</td>
<td>{{ reserva.data_pedido|default:"-" }}</td>
<td>{{ reserva.virtual|yesno }}</td>
<td>{{ reserva.inicio }}</td>
<td>{{ reserva.termino }}</td>
<td>{{ reserva.proposito }}</td>
<td>{{ reserva.total_participantes|default:"-" }}</td>
<td>{{ reserva.solicitante }}</td>
<td>{{ reserva.contato }}</td>
<td>{{ reserva.telefone_contato }}</td>

Loading…
Cancel
Save