Browse Source

Ajustes no relatório. Compl. Gertiq #160526

pull/169/head 3.0.62
Sesóstris Vieira 1 year ago
parent
commit
a72017e1ec
  1. 20
      sigi/apps/espacos/forms.py
  2. 8
      sigi/apps/espacos/templates/espacos/snippets/uso_espaco_snippet.html
  3. 13
      sigi/apps/espacos/templates/espacos/uso_espaco.html
  4. 8
      sigi/apps/espacos/templates/espacos/uso_espaco_pdf.html
  5. 21
      sigi/apps/espacos/views.py

20
sigi/apps/espacos/forms.py

@ -8,6 +8,15 @@ from sigi.apps.espacos.models import Espaco
class UsoEspacoReportForm(forms.Form): class UsoEspacoReportForm(forms.Form):
VIRTUAL_ALL = "A"
VIRTUAL_VIRTUAL = "V"
VIRTUAL_PRESENCIAL = "P"
VIRTUAL_CHOICES = (
(VIRTUAL_ALL, _("All")),
(VIRTUAL_VIRTUAL, _("Apenas virtual")),
(VIRTUAL_PRESENCIAL, _("Apenas presencial")),
)
class Media: class Media:
css = {"all": ["css/change_form.css"]} css = {"all": ["css/change_form.css"]}
js = [ js = [
@ -34,8 +43,17 @@ class UsoEspacoReportForm(forms.Form):
data_fim = forms.DateField( data_fim = forms.DateField(
label=_("Data fim"), required=True, widget=MaterialAdminDateWidget label=_("Data fim"), required=True, widget=MaterialAdminDateWidget
) )
virtual = forms.ChoiceField(
label=_("Tipo de uso"), choices=VIRTUAL_CHOICES, initial=VIRTUAL_ALL
)
agrupar_espacos = forms.BooleanField(
label=_("Agrupar por espaço"), required=False, initial=False
)
espaco = forms.ModelMultipleChoiceField( espaco = forms.ModelMultipleChoiceField(
label=_("Espaços"), required=True, queryset=Espaco.objects.all(), widget=CheckboxSelectMultiple label=_("Espaços"),
required=True,
queryset=Espaco.objects.all(),
widget=CheckboxSelectMultiple,
) )
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):

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

@ -3,8 +3,10 @@
<table class="calendar-table" repeat="2"> <table class="calendar-table" repeat="2">
<thead> <thead>
<tr> <tr>
{% if not espacos %}
<th rowspan="2">{% trans "Espaço" %}</th>
{% endif %}
<th rowspan="2">{% trans "SIGAD" %}</th> <th rowspan="2">{% trans "SIGAD" %}</th>
<th rowspan="2">{% trans "Data pedido" %}</th>
<th rowspan="2">{% trans "Virtual" %}</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>
@ -23,8 +25,10 @@
<tbody> <tbody>
{% for reserva in reservas %} {% for reserva in reservas %}
<tr> <tr>
{% if not espacos %}
<th>{{ reserva.espaco.nome }}</th>
{% endif %}
<td>{{ reserva.num_processo }}</td> <td>{{ reserva.num_processo }}</td>
<td>{{ reserva.data_pedido|default:"-" }}</td>
<td>{{ reserva.virtual|yesno }}</td> <td>{{ reserva.virtual|yesno }}</td>
<td>{{ reserva.inicio }}</td> <td>{{ reserva.inicio }}</td>
<td>{{ reserva.termino }}</td> <td>{{ reserva.termino }}</td>

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

@ -39,6 +39,8 @@
</form> </form>
</div> </div>
</div> </div>
{% if espacos %}
{% for espaco in espacos %} {% for espaco in espacos %}
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
@ -51,6 +53,17 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
{% else %}
<div class="row">
<div class="col s12">
<div class="card">
<div class="card-content">
{% include "espacos/snippets/uso_espaco_snippet.html" %}
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %} {% endblock %}
{% block footer %} {% block footer %}

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

@ -11,6 +11,7 @@
{% endblock %} {% endblock %}
{% block main_content %} {% block main_content %}
{% if espacos %}
{% for espaco in espacos %} {% for espaco in espacos %}
<h4> <h4>
{% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %} {% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %}
@ -22,4 +23,11 @@
<div class="new-page"></div> <div class="new-page"></div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% else %}
<h4>
{% blocktranslate%}Semana de {{ data_inicio }} a {{ data_termino }}{% endblocktranslate %}
</h4>
<br/>
{% include "espacos/snippets/uso_espaco_snippet.html" %}
{% endif %}
{% endblock %} {% endblock %}

21
sigi/apps/espacos/views.py

@ -111,6 +111,7 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
pdf_template_name = "espacos/uso_espaco_pdf.html" pdf_template_name = "espacos/uso_espaco_pdf.html"
report_title = _("Uso dos espaços - Auditórios e Salas") report_title = _("Uso dos espaços - Auditórios e Salas")
pagesize = "A4 landscape" pagesize = "A4 landscape"
attachment = False
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
form = UsoEspacoReportForm(self.request.GET) form = UsoEspacoReportForm(self.request.GET)
@ -118,6 +119,8 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
data_inicio = form.cleaned_data["data_inicio"] data_inicio = form.cleaned_data["data_inicio"]
data_fim = form.cleaned_data["data_fim"] data_fim = form.cleaned_data["data_fim"]
sel_espacos = form.cleaned_data["espaco"] sel_espacos = form.cleaned_data["espaco"]
virtual = form.cleaned_data["virtual"]
agrupar_espacos = form.cleaned_data["agrupar_espacos"]
else: else:
form = UsoEspacoReportForm( form = UsoEspacoReportForm(
initial={"espaco": Espaco.objects.all()} initial={"espaco": Espaco.objects.all()}
@ -125,21 +128,32 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
semana = form.get_semana() semana = form.get_semana()
data_inicio = semana["first"] data_inicio = semana["first"]
data_fim = semana["last"] data_fim = semana["last"]
virtual = UsoEspacoReportForm.VIRTUAL_ALL
agrupar_espacos = False
sel_espacos = None sel_espacos = None
if not sel_espacos: if not sel_espacos:
sel_espacos = Espaco.objects.all() sel_espacos = Espaco.objects.all()
if virtual == UsoEspacoReportForm.VIRTUAL_VIRTUAL:
q_virtual = Q(virtual=True)
elif virtual == UsoEspacoReportForm.VIRTUAL_PRESENCIAL:
q_virtual = Q(virtual=False)
else:
q_virtual = Q()
reservas_qs = ( reservas_qs = (
Reserva.objects.filter(status=Reserva.STATUS_ATIVO) Reserva.objects.filter(q_virtual, status=Reserva.STATUS_ATIVO)
.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("inicio", "termino") .order_by("inicio", "termino")
) )
if agrupar_espacos:
espacos = ( espacos = (
sel_espacos.filter(reserva__status=Reserva.STATUS_ATIVO) sel_espacos.filter(q_virtual, reserva__status=Reserva.STATUS_ATIVO)
.filter( .filter(
Q(reserva__inicio__range=(data_inicio, data_fim)) Q(reserva__inicio__range=(data_inicio, data_fim))
| Q(reserva__termino__range=(data_inicio, data_fim)) | Q(reserva__termino__range=(data_inicio, data_fim))
@ -153,11 +167,14 @@ class UsoEspacos(ReportViewMixin, StaffMemberRequiredMixin, TemplateView):
) )
) )
) )
else:
espacos = None
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context.update( context.update(
{ {
"espacos": espacos, "espacos": espacos,
"reservas": reservas_qs,
"form": form, "form": form,
"data_inicio": data_inicio, "data_inicio": data_inicio,
"data_termino": data_fim, "data_termino": data_fim,

Loading…
Cancel
Save