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: class Media:
css = {"all": ["css/change_form.css"]} css = {"all": ["css/change_form.css"]}
js = [ js = [
"/admin/js/vendor/select2/select2.full.js", "admin/js/vendor/select2/select2.full.js",
"/admin/js/change_form.js", "admin/js/change_form.js",
"/admin/js/vendor/select2/i18n/pt-BR.js", "admin/js/vendor/select2/i18n/pt-BR.js",
"/material/admin/js/widgets/TimeInput.js", "material/admin/js/widgets/TimeInput.js",
"/admin/js/core.js", "admin/js/core.js",
"/admin/jsi18n/",
] ]
def get_semana(self): 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"> <table class="calendar-table" repeat="2">
<thead> <thead>
<tr> <tr>
<th rowspan="2">{% trans "Espaço" %}</th>
<th rowspan="2">{% trans "SIGAD" %}</th> <th rowspan="2">{% trans "SIGAD" %}</th>
<th rowspan="2">{% trans "Data pedido" %}</th> <th rowspan="2">{% trans "Data pedido" %}</th>
<th rowspan="2">{% trans "Virtual" %}</th> <th rowspan="2">{% trans "Virtual" %}</th>
@ -24,9 +23,6 @@
<tbody> <tbody>
{% for reserva in reservas %} {% for reserva in reservas %}
<tr> <tr>
{% ifchanged reserva.espaco %}
<th rowspan="{{ rowspans|get:reserva.espaco.id }}">{{ reserva.espaco.nome }}</th>
{% endifchanged %}
<td>{{ reserva.num_processo }}</td> <td>{{ reserva.num_processo }}</td>
<td>{{ reserva.data_pedido|default:"-" }}</td> <td>{{ reserva.data_pedido|default:"-" }}</td>
<td>{{ reserva.virtual|yesno }}</td> <td>{{ reserva.virtual|yesno }}</td>

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

@ -39,15 +39,18 @@
</form> </form>
</div> </div>
</div> </div>
<div class="row"> {% for espaco in espacos %}
<div class="col s12"> <div class="row">
<div class="card"> <div class="col s12">
<div class="card-content"> <div class="card">
{% include "espacos/snippets/uso_espaco_snippet.html" %} <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>
</div> </div>
</div> {% endfor %}
{% endblock %} {% endblock %}
{% block footer %} {% block footer %}

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

@ -11,9 +11,15 @@
{% endblock %} {% endblock %}
{% block main_content %} {% block main_content %}
<h4> {% for espaco in espacos %}
{% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %} <h4>
</h4> {% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %}
<br/> </h4>
{% include "espacos/snippets/uso_espaco_snippet.html" %} <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 %} {% endblock %}

33
sigi/apps/espacos/views.py

@ -2,7 +2,7 @@ import calendar
import locale import locale
from typing import Any from typing import Any
from django import http 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 import timezone
from django.utils.translation import ( from django.utils.translation import (
to_locale, to_locale,
@ -109,7 +109,7 @@ class Agenda(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView): class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
html_template_name = "espacos/uso_espaco.html" html_template_name = "espacos/uso_espaco.html"
pdf_template_name = "espacos/uso_espaco_pdf.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" pagesize = "A4 landscape"
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
@ -130,27 +130,34 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
if not sel_espacos: if not sel_espacos:
sel_espacos = Espaco.objects.all() sel_espacos = Espaco.objects.all()
reservas = ( reservas_qs = (
Reserva.objects.filter( Reserva.objects.filter(status=Reserva.STATUS_ATIVO)
status=Reserva.STATUS_ATIVO, espaco__in=sel_espacos
)
.filter( .filter(
Q(inicio__range=(data_inicio, data_fim)) Q(inicio__range=(data_inicio, data_fim))
| Q(termino__range=(data_inicio, data_fim)) | Q(termino__range=(data_inicio, data_fim))
) )
.order_by("espaco", "inicio", "termino") .order_by("inicio", "termino")
) )
rowspans = dict( espacos = (
reservas.order_by("espaco") sel_espacos.filter(reserva__status=Reserva.STATUS_ATIVO)
.values_list("espaco") .filter(
.annotate(Count("espaco")) 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 = super().get_context_data(**kwargs)
context.update( context.update(
{ {
"reservas": reservas, "espacos": espacos,
"rowspans": rowspans,
"form": form, "form": form,
"data_inicio": data_inicio, "data_inicio": data_inicio,
"data_termino": data_fim, "data_termino": data_fim,

Loading…
Cancel
Save