|
@ -27,6 +27,8 @@ from django.utils.safestring import mark_safe |
|
|
from django.utils.translation import gettext as _ |
|
|
from django.utils.translation import gettext as _ |
|
|
from django_weasyprint.utils import django_url_fetcher |
|
|
from django_weasyprint.utils import django_url_fetcher |
|
|
from django_weasyprint.views import WeasyTemplateResponse |
|
|
from django_weasyprint.views import WeasyTemplateResponse |
|
|
|
|
|
from import_export import resources |
|
|
|
|
|
from import_export.admin import ExportActionMixin |
|
|
from import_export.fields import Field |
|
|
from import_export.fields import Field |
|
|
from tinymce.models import HTMLField |
|
|
from tinymce.models import HTMLField |
|
|
from tinymce.widgets import AdminTinyMCE |
|
|
from tinymce.widgets import AdminTinyMCE |
|
@ -56,13 +58,7 @@ from sigi.apps.eventos.views import ( |
|
|
) |
|
|
) |
|
|
from sigi.apps.utils import abreviatura |
|
|
from sigi.apps.utils import abreviatura |
|
|
from sigi.apps.utils.filters import DateRangeFilter |
|
|
from sigi.apps.utils.filters import DateRangeFilter |
|
|
from sigi.apps.utils.mixins import ( |
|
|
from sigi.apps.utils.mixins import AsciifyQParameter |
|
|
AsciifyQParameter, |
|
|
|
|
|
CartExportMixin, |
|
|
|
|
|
CartExportReportMixin, |
|
|
|
|
|
LabeledResourse, |
|
|
|
|
|
ValueLabeledResource, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ActVigenteFilter(admin.SimpleListFilter): |
|
|
class ActVigenteFilter(admin.SimpleListFilter): |
|
@ -113,7 +109,7 @@ class MicrorregiaoFilter(AutocompleteFilter): |
|
|
rel_model = Municipio |
|
|
rel_model = Municipio |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SolicitacaoResource(LabeledResourse): |
|
|
class SolicitacaoResource(resources.ModelResource): |
|
|
act_vigente = Field(column_name="ACT vigente") |
|
|
act_vigente = Field(column_name="ACT vigente") |
|
|
data_termino_act = Field(column_name="término vigência ACT") |
|
|
data_termino_act = Field(column_name="término vigência ACT") |
|
|
oficinas = Field(column_name="oficinas solicitadas") |
|
|
oficinas = Field(column_name="oficinas solicitadas") |
|
@ -246,7 +242,7 @@ class SolicitacaoResource(LabeledResourse): |
|
|
return obj.casa.municipio.uf.get_regiao_display() |
|
|
return obj.casa.municipio.uf.get_regiao_display() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EventoResource(ValueLabeledResource): |
|
|
class EventoResource(resources.ModelResource): |
|
|
class Meta: |
|
|
class Meta: |
|
|
model = Evento |
|
|
model = Evento |
|
|
fields = ( |
|
|
fields = ( |
|
@ -397,7 +393,7 @@ class TipoEventoAdmin(admin.ModelAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Solicitacao) |
|
|
@admin.register(Solicitacao) |
|
|
class SolicitacaoAdmin(AsciifyQParameter, CartExportMixin, admin.ModelAdmin): |
|
|
class SolicitacaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): |
|
|
resource_class = SolicitacaoResource |
|
|
resource_class = SolicitacaoResource |
|
|
list_display = ( |
|
|
list_display = ( |
|
|
"casa", |
|
|
"casa", |
|
@ -873,7 +869,7 @@ class ModeloDeclaracaoAdmin(admin.ModelAdmin): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(Evento) |
|
|
@admin.register(Evento) |
|
|
class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): |
|
|
class EventoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin): |
|
|
form = EventoAdminForm |
|
|
form = EventoAdminForm |
|
|
resource_class = EventoResource |
|
|
resource_class = EventoResource |
|
|
fieldsets = ( |
|
|
fieldsets = ( |
|
@ -1005,6 +1001,7 @@ class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): |
|
|
CronogramaInline, |
|
|
CronogramaInline, |
|
|
) |
|
|
) |
|
|
save_as = True |
|
|
save_as = True |
|
|
|
|
|
actions = ["custos_eventos_report", "custos_servidor_report"] |
|
|
reports = ["custos_eventos_report", "custos_servidor_report"] |
|
|
reports = ["custos_eventos_report", "custos_servidor_report"] |
|
|
|
|
|
|
|
|
@admin.display(description=_("banner")) |
|
|
@admin.display(description=_("banner")) |
|
@ -1481,19 +1478,14 @@ class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): |
|
|
content_type="application/pdf", |
|
|
content_type="application/pdf", |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
def custos_eventos_report(self, request): |
|
|
@admin.action(description=_("Custos por eventos")) |
|
|
context = context_custos_eventos(self.get_queryset(request)) |
|
|
def custos_eventos_report(self, request, queryset): |
|
|
|
|
|
context = context_custos_eventos(queryset) |
|
|
context["data_inicio"] = ( |
|
|
context["data_inicio"] = ( |
|
|
self.get_queryset(request) |
|
|
queryset.order_by("data_inicio").first().data_inicio |
|
|
.order_by("data_inicio") |
|
|
|
|
|
.first() |
|
|
|
|
|
.data_inicio |
|
|
|
|
|
) |
|
|
) |
|
|
context["data_fim"] = ( |
|
|
context["data_fim"] = ( |
|
|
self.get_queryset(request) |
|
|
queryset.order_by("data_termino").last().data_termino |
|
|
.order_by("data_termino") |
|
|
|
|
|
.last() |
|
|
|
|
|
.data_termino |
|
|
|
|
|
) |
|
|
) |
|
|
return WeasyTemplateResponse( |
|
|
return WeasyTemplateResponse( |
|
|
filename=f"custos_eventos-{timezone.localdate()}.pdf", |
|
|
filename=f"custos_eventos-{timezone.localdate()}.pdf", |
|
@ -1503,8 +1495,9 @@ class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): |
|
|
content_type="application/pdf", |
|
|
content_type="application/pdf", |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
custos_eventos_report.title = _("Custos por eventos") |
|
|
custos_eventos_report.djbs_icon = "report" |
|
|
|
|
|
|
|
|
|
|
|
@admin.action(description=_("Custos por servidor")) |
|
|
def custos_servidor_report(self, request): |
|
|
def custos_servidor_report(self, request): |
|
|
context = context_custos_servidor(self.get_queryset(request)) |
|
|
context = context_custos_servidor(self.get_queryset(request)) |
|
|
context["data_inicio"] = ( |
|
|
context["data_inicio"] = ( |
|
@ -1529,7 +1522,7 @@ class EventoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin): |
|
|
content_type="application/pdf", |
|
|
content_type="application/pdf", |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
custos_servidor_report.title = _("Custos por servidor") |
|
|
custos_servidor_report.djbs_icon = "report" |
|
|
|
|
|
|
|
|
def create_course(self, request, object_id): |
|
|
def create_course(self, request, object_id): |
|
|
evento = get_object_or_404(Evento, id=object_id) |
|
|
evento = get_object_or_404(Evento, id=object_id) |
|
|