Browse Source

Removendo import e export com carrinho

pull/183/head
Sesóstris Vieira 1 month ago
parent
commit
117b0431b8
  1. 14
      sigi/apps/casas/admin.py
  2. 15
      sigi/apps/contatos/admin.py
  3. 12
      sigi/apps/convenios/admin.py
  4. 7
      sigi/apps/espacos/admin.py
  5. 39
      sigi/apps/eventos/admin.py
  6. 15
      sigi/apps/parlamentares/admin.py
  7. 12
      sigi/apps/servicos/admin.py
  8. 1
      sigi/templates/admin/import_export/change_list.html
  9. 9
      sigi/templates/admin/import_export/change_list_export_item.html

14
sigi/apps/casas/admin.py

@ -11,6 +11,8 @@ from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from django_weasyprint.views import WeasyTemplateResponse
from import_export import resources
from import_export.admin import ExportActionMixin
from import_export.fields import Field
from sigi.apps.casas.forms import OrgaoForm
from sigi.apps.casas.models import Orgao, Funcionario, TipoOrgao
@ -30,14 +32,10 @@ from sigi.apps.servicos.models import Servico
from sigi.apps.servicos.filters import ServicoAtivoFilter
from sigi.apps.servidores.models import Servidor
from sigi.apps.utils.mixins import AsciifyQParameter
from sigi.apps.utils.mixins import (
ReturnMixin,
CartExportReportMixin,
LabeledResourse,
)
from sigi.apps.utils.mixins import ReturnMixin
class OrgaoExportResourceContato(LabeledResourse):
class OrgaoExportResourceContato(resources.ModelResource):
class Meta:
model = Orgao
fields = ("nome", "email")
@ -55,7 +53,7 @@ class OrgaoExportResourceContato(LabeledResourse):
return super().export(queryset, *args, **kwargs)
class OrgaoExportResourseGeral(LabeledResourse):
class OrgaoExportResourseGeral(resources.ModelResource):
presidente = Field(column_name="presidente")
telefone = Field(column_name="telefone")
# servicos_seit = Field(column_name='servicos_seit')
@ -346,7 +344,7 @@ class FuncionarioAdmin(ReturnMixin, admin.ModelAdmin):
@admin.register(Orgao)
class OrgaoAdmin(AsciifyQParameter, CartExportReportMixin, admin.ModelAdmin):
class OrgaoAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin):
form = OrgaoForm
resource_classes = [OrgaoExportResourseGeral, OrgaoExportResourceContato]
inlines = (

15
sigi/apps/contatos/admin.py

@ -1,6 +1,8 @@
from admin_auto_filters.filters import AutocompleteFilter
from django.contrib import admin
from django.utils.translation import gettext as _
from import_export import resources
from import_export.admin import ExportActionMixin
from sigi.apps.utils.filters import RangeFilter
from sigi.apps.contatos.models import (
UnidadeFederativa,
@ -12,11 +14,6 @@ from sigi.apps.contatos.models import (
)
from sigi.apps.parlamentares.models import Senador
from sigi.apps.utils.mixins import AsciifyQParameter
from sigi.apps.utils.mixins import (
ReturnMixin,
CartExportMixin,
LabeledResourse,
)
class MicrorregiaoFilter(AutocompleteFilter):
@ -24,7 +21,7 @@ class MicrorregiaoFilter(AutocompleteFilter):
field_name = "microrregiao"
class UnidadeFederativaResource(LabeledResourse):
class UnidadeFederativaResource(resources.ModelResource):
class Meta:
model = UnidadeFederativa
fields = ("codigo_ibge", "nome", "sigla", "regiao", "populacao")
@ -35,7 +32,7 @@ class UnidadeFederativaResource(LabeledResourse):
return dict(UnidadeFederativa.REGIAO_CHOICES)[uf.regiao]
class MunicipioResource(LabeledResourse):
class MunicipioResource(resources.ModelResource):
class Meta:
model = Municipio
fields = (
@ -81,7 +78,7 @@ class SenadorInline(admin.StackedInline):
@admin.register(UnidadeFederativa)
class UnidadeFederativaAdmin(
AsciifyQParameter, CartExportMixin, admin.ModelAdmin
AsciifyQParameter, ExportActionMixin, admin.ModelAdmin
):
actions = None
resource_classes = [UnidadeFederativaResource]
@ -117,7 +114,7 @@ class MicrorregiaoAdmin(AsciifyQParameter, admin.ModelAdmin):
@admin.register(Municipio)
class MunicipioAdmin(AsciifyQParameter, CartExportMixin, admin.ModelAdmin):
class MunicipioAdmin(AsciifyQParameter, ExportActionMixin, admin.ModelAdmin):
actions = None
resource_classes = [MunicipioResource]
list_display = (

12
sigi/apps/convenios/admin.py

@ -4,6 +4,8 @@ from django.utils import timezone
from django.utils.translation import gettext as _
from django.utils.safestring import mark_safe
from django_weasyprint.views import WeasyTemplateResponse
from import_export import resources
from import_export.admin import ExportActionMixin
from tinymce.models import HTMLField
from tinymce.widgets import AdminTinyMCE
from sigi.apps.convenios.models import (
@ -17,15 +19,11 @@ from sigi.apps.convenios.models import (
)
from sigi.apps.utils.mixins import AsciifyQParameter
from sigi.apps.casas.admin import GerentesInterlegisFilter
from sigi.apps.utils.mixins import (
ReturnMixin,
CartExportReportMixin,
LabeledResourse,
)
from sigi.apps.utils.mixins import ReturnMixin
from sigi.apps.utils.filters import DateRangeFilter
class ConvenioExportResourse(LabeledResourse):
class ConvenioExportResourse(resources.ModelResource):
class Meta:
model = Convenio
fields = (
@ -112,7 +110,7 @@ class ProjetoAdmin(admin.ModelAdmin):
@admin.register(Convenio)
class ConvenioAdmin(
AsciifyQParameter, ReturnMixin, CartExportReportMixin, admin.ModelAdmin
AsciifyQParameter, ReturnMixin, ExportActionMixin, admin.ModelAdmin
):
fieldsets = (
(

7
sigi/apps/espacos/admin.py

@ -5,6 +5,8 @@ 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 import resources
from import_export.admin import ExportActionMixin
from import_export.fields import Field
from sigi.apps.espacos.models import (
Espaco,
@ -13,10 +15,9 @@ from sigi.apps.espacos.models import (
RecursoSolicitado,
)
from sigi.apps.espacos.forms import ReservaAdminForm
from sigi.apps.utils.mixins import CartExportMixin, LabeledResourse
class ReservaResource(LabeledResourse):
class ReservaResource(resources.ModelResource):
recursos_solicitados = Field(column_name="recursos solicitados")
class Meta:
@ -67,7 +68,7 @@ class RecursoAdmin(admin.ModelAdmin):
@admin.register(Reserva)
class ReservaAdmin(CartExportMixin, admin.ModelAdmin):
class ReservaAdmin(ExportActionMixin, admin.ModelAdmin):
form = ReservaAdminForm
resource_classes = [ReservaResource]
list_display = [

39
sigi/apps/eventos/admin.py

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

15
sigi/apps/parlamentares/admin.py

@ -9,22 +9,17 @@ from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.translation import gettext as _
from import_export import resources
from import_export.admin import ImportMixin
from import_export.admin import ImportMixin, ExportActionMixin
from import_export.formats.base_formats import CSV
from sigi.apps.contatos.models import UnidadeFederativa
from sigi.apps.parlamentares.jobs import import_path, json_path
from sigi.apps.parlamentares.models import Partido, Parlamentar, Senador
from sigi.apps.parlamentares.forms import ImportForm
from sigi.apps.utils.filters import AlphabeticFilter
from sigi.apps.utils.mixins import (
ReturnMixin,
CartImportExportMixin,
CartExportMixin,
LabeledResourse,
)
from sigi.apps.utils.mixins import ReturnMixin
class ParlamentarResource(LabeledResourse):
class ParlamentarResource(resources.ModelResource):
class Meta:
model = Parlamentar
fields = (
@ -142,13 +137,13 @@ class ParlamentarNomeCompletoFilter(AlphabeticFilter):
@admin.register(Partido)
class PartidoAdmin(CartImportExportMixin, admin.ModelAdmin):
class PartidoAdmin(ImportMixin, ExportActionMixin, admin.ModelAdmin):
list_display = ("legenda", "nome", "sigla")
search_fields = ("legenda", "nome", "sigla")
@admin.register(Parlamentar)
class ParlamentarAdmin(ReturnMixin, CartExportMixin, admin.ModelAdmin):
class ParlamentarAdmin(ReturnMixin, ExportActionMixin, admin.ModelAdmin):
resource_class = ParlamentarResource
import_export_change_list_template = (
"admin/parlamentares/parlamentar/cart/"

12
sigi/apps/servicos/admin.py

@ -4,7 +4,9 @@ from django.utils.encoding import force_str
from django.utils.safestring import mark_safe
from django.http import Http404, HttpResponseRedirect
from django.utils.translation import gettext as _
from import_export import resources
from import_export.fields import Field
from import_export.admin import ExportActionMixin
from sigi.apps.casas.admin import GerentesInterlegisFilter
from sigi.apps.servicos.models import Servico, LogServico, TipoServico
from sigi.apps.servicos.filters import (
@ -16,14 +18,10 @@ from sigi.apps.convenios.filters import (
ExcluirTipoProjetoFilter,
)
from sigi.apps.utils.filters import DateRangeFilter
from sigi.apps.utils.mixins import (
ReturnMixin,
CartExportMixin,
ValueLabeledResource,
)
from sigi.apps.utils.mixins import ReturnMixin
class ServicoExportResourse(ValueLabeledResource):
class ServicoExportResourse(resources.ModelResource):
hospedagem_interlegis = Field(column_name="hospedagem no interlegis")
class Meta:
@ -76,7 +74,7 @@ class TipoServicoAdmin(admin.ModelAdmin):
@admin.register(Servico)
class ServicoAdmin(ReturnMixin, CartExportMixin, admin.ModelAdmin):
class ServicoAdmin(ReturnMixin, ExportActionMixin, admin.ModelAdmin):
actions = [
"calcular_data_uso",
]

1
sigi/templates/admin/import_export/change_list.html

@ -0,0 +1 @@
{% extends ie_base_change_list_template|default:"admin/change_list.html" %}

9
sigi/templates/admin/import_export/change_list_export_item.html

@ -0,0 +1,9 @@
{% load i18n djbs_extras %}
{% load admin_urls %}
{% if has_export_permission %}
<a href="{% url opts|admin_urlname:'export' %}{{cl.get_query_string}}" class="export_link nav-link" aria-labelledby="text-tool-export-all" title="{% translate "Export all" %}">
{% icon "export-all" %}
<span id="text-tool-export-all" class="d-lg-none">{% translate "Export all" %}</span>
</a>
{% endif %}
Loading…
Cancel
Save