Browse Source

Ajustes no relatório de uso de espaços. Compl. Gertiq #160526

pull/169/head
Sesóstris Vieira 1 year ago
parent
commit
09c4860f70
  1. 11
      sigi/apps/espacos/forms.py
  2. 4
      sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html
  3. 15
      sigi/apps/espacos/templates/espacos/uso_espaco.html
  4. 16
      sigi/apps/espacos/templates/espacos/uso_espaco_pdf.html
  5. 33
      sigi/apps/espacos/views.py

11
sigi/apps/espacos/forms.py

@ -11,11 +11,12 @@ class UsoEspacoReportForm(forms.Form):
class Media:
css = {"all": ["css/change_form.css"]}
js = [
"/admin/js/vendor/select2/select2.full.js",
"/admin/js/change_form.js",
"/admin/js/vendor/select2/i18n/pt-BR.js",
"/material/admin/js/widgets/TimeInput.js",
"/admin/js/core.js",
"admin/js/vendor/select2/select2.full.js",
"admin/js/change_form.js",
"admin/js/vendor/select2/i18n/pt-BR.js",
"material/admin/js/widgets/TimeInput.js",
"admin/js/core.js",
"/admin/jsi18n/",
]
def get_semana(self):

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

@ -3,7 +3,6 @@
<table class="calendar-table" repeat="2">
<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>
@ -24,9 +23,6 @@
<tbody>
{% for reserva in reservas %}
<tr>
{% 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>

15
sigi/apps/espacos/templates/espacos/uso_espaco.html

@ -39,15 +39,18 @@
</form>
</div>
</div>
<div class="row">
<div class="col s12">
<div class="card">
<div class="card-content">
{% include "espacos/snippets/uso_espaco_snippet.html" %}
{% for espaco in espacos %}
<div class="row">
<div class="col s12">
<div class="card">
<div class="card-content">
<span class="card-title">{{ espaco.nome }}</span>
{% include "espacos/snippets/uso_espaco_snippet.html" with reservas=espaco.reservas %}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
{% endblock %}
{% block footer %}

16
sigi/apps/espacos/templates/espacos/uso_espaco_pdf.html

@ -11,9 +11,15 @@
{% endblock %}
{% block main_content %}
<h4>
{% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %}
</h4>
<br/>
{% include "espacos/snippets/uso_espaco_snippet.html" %}
{% for espaco in espacos %}
<h4>
{% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %}
</h4>
<h5>{{ espaco.nome }}</h5>
<br/>
{% include "espacos/snippets/uso_espaco_snippet.html" with reservas=espaco.reservas %}
{% if not forloop.last %}
<div class="new-page"></div>
{% endif %}
{% endfor %}
{% endblock %}

33
sigi/apps/espacos/views.py

@ -2,7 +2,7 @@ import calendar
import locale
from typing import Any
from django import http
from django.db.models import Q, Count
from django.db.models import Q, Count, Prefetch
from django.utils import timezone
from django.utils.translation import (
to_locale,
@ -109,7 +109,7 @@ class Agenda(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
html_template_name = "espacos/uso_espaco.html"
pdf_template_name = "espacos/uso_espaco_pdf.html"
report_title = _("Uso dos espaços")
report_title = _("Uso dos espaços - Auditórios e Salas")
pagesize = "A4 landscape"
def get_context_data(self, **kwargs):
@ -130,27 +130,34 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
if not sel_espacos:
sel_espacos = Espaco.objects.all()
reservas = (
Reserva.objects.filter(
status=Reserva.STATUS_ATIVO, espaco__in=sel_espacos
)
reservas_qs = (
Reserva.objects.filter(status=Reserva.STATUS_ATIVO)
.filter(
Q(inicio__range=(data_inicio, data_fim))
| Q(termino__range=(data_inicio, data_fim))
)
.order_by("espaco", "inicio", "termino")
.order_by("inicio", "termino")
)
rowspans = dict(
reservas.order_by("espaco")
.values_list("espaco")
.annotate(Count("espaco"))
espacos = (
sel_espacos.filter(reserva__status=Reserva.STATUS_ATIVO)
.filter(
Q(reserva__inicio__range=(data_inicio, data_fim))
| Q(reserva__termino__range=(data_inicio, data_fim))
)
.distinct()
.prefetch_related(
Prefetch(
"reserva_set",
queryset=reservas_qs,
to_attr="reservas",
)
)
)
context = super().get_context_data(**kwargs)
context.update(
{
"reservas": reservas,
"rowspans": rowspans,
"espacos": espacos,
"form": form,
"data_inicio": data_inicio,
"data_termino": data_fim,

Loading…
Cancel
Save