from import_export.admin import ImportExportModelAdmin
from django.contrib import admin
# from django.core.cache import cache
# from django.core.paginator import Paginator
from . import models
from . import resources


# # Modified version of a GIST I found in a SO thread
# # cfr. http://masnun.rocks/2017/03/20/django-admin-expensive-count-all-queries/
# class CachingPaginator(Paginator):
#     def _get_count(self):
#         if not hasattr(self, "_count"):
#             self._count = None
#         if self._count is None:
#             try:
#                 key = "adm:{0}:count".format(hash(self.object_list.query.__str__()))
#                 self._count = cache.get(key, -1)
#                 if self._count == -1:
#                     self._count = super().count
#                     cache.set(key, self._count, 60)
#             except:
#                 self._count = len(self.object_list)
#         return self._count
#     count = property(_get_count)

# # Main reusable Admin class for only viewing
# class ViewAdminMixin(admin.ModelAdmin):
#     def has_add_permission(self, request):
#         return False
#
#     def has_change_permission(self, request, obj=None):
#         return False
#
#     def has_delete_permission(self, request, obj=None):
#         return False

# --------------- FINE PREFISSO TEMPLATE ---------------


@admin.register(models.FatturaElettronica)
class FatturaElettronicaAdmin(ImportExportModelAdmin):
    # resource = resources.FatturaElettronicaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RegimeFiscale)
class RegimeFiscaleAdmin(ImportExportModelAdmin):
    # resource = resources.RegimeFiscaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoCassa)
class TipoCassaAdmin(ImportExportModelAdmin):
    # resource = resources.TipoCassaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ModalitaPagamento)
class ModalitaPagamentoAdmin(ImportExportModelAdmin):
    # resource = resources.ModalitaPagamentoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoDocumento)
class TipoDocumentoAdmin(ImportExportModelAdmin):
    # resource = resources.TipoDocumentoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.Natura)
class NaturaAdmin(ImportExportModelAdmin):
    # resource = resources.NaturaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoRitenuta)
class TipoRitenutaAdmin(ImportExportModelAdmin):
    # resource = resources.TipoRitenutaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.XmlFatturaElettronica)
class XmlFatturaElettronicaAdmin(ImportExportModelAdmin):
    # resource = resources.XmlFatturaElettronicaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SoggettiFatturaElettronica)
class SoggettiFatturaElettronicaAdmin(ImportExportModelAdmin):
    # resource = resources.SoggettiFatturaElettronicaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SoggettoFiscale)
class SoggettoFiscaleAdmin(ImportExportModelAdmin):
    # resource = resources.SoggettoFiscaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.PartitaIvaCF)
class PartitaIvaCFAdmin(ImportExportModelAdmin):
    # resource = resources.PartitaIvaCFResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.FormatoTrasmissione)
class FormatoTrasmissioneAdmin(ImportExportModelAdmin):
    # resource = resources.FormatoTrasmissioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CodiceDestinatario)
class CodiceDestinatarioAdmin(ImportExportModelAdmin):
    # resource = resources.CodiceDestinatarioResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.IscrizioneAlboProfessionale)
class IscrizioneAlboProfessionaleAdmin(ImportExportModelAdmin):
    # resource = resources.IscrizioneAlboProfessionaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.IscrizioneREA)
class IscrizioneREAAdmin(ImportExportModelAdmin):
    # resource = resources.IscrizioneREAResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SocioUnico)
class SocioUnicoAdmin(ImportExportModelAdmin):
    # resource = resources.SocioUnicoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.StatoLiquidazione)
class StatoLiquidazioneAdmin(ImportExportModelAdmin):
    # resource = resources.StatoLiquidazioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TerzoIntermediarioOSoggettoEmittente)
class TerzoIntermediarioOSoggettoEmittenteAdmin(ImportExportModelAdmin):
    # resource = resources.TerzoIntermediarioOSoggettoEmittenteResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SoggettoEmittente)
class SoggettoEmittenteAdmin(ImportExportModelAdmin):
    # resource = resources.SoggettoEmittenteResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.AlboProfessionale)
class AlboProfessionaleAdmin(ImportExportModelAdmin):
    # resource = resources.AlboProfessionaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.Allegato)
class AllegatoAdmin(ImportExportModelAdmin):
    # resource = resources.AllegatoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatoPagamento)
class DatoPagamentoAdmin(ImportExportModelAdmin):
    # resource = resources.DatoPagamentoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiVeicoli)
class DatiVeicoliAdmin(ImportExportModelAdmin):
    # resource = resources.DatiVeicoliResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiDocumentali)
class DatiDocumentaliAdmin(ImportExportModelAdmin):
    # resource = resources.DatiDocumentaliResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiFattureCollegate)
class DatiFattureCollegateAdmin(ImportExportModelAdmin):
    # resource = resources.DatiFattureCollegateResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiSAL)
class DatiSALAdmin(ImportExportModelAdmin):
    # resource = resources.DatiSALResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiDDT)
class DatiDDTAdmin(ImportExportModelAdmin):
    # resource = resources.DatiDDTResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiTrasporto)
class DatiTrasportoAdmin(ImportExportModelAdmin):
    # resource = resources.DatiTrasportoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.Valuta)
class ValutaAdmin(ImportExportModelAdmin):
    # resource = resources.ValutaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiRitenuta)
class DatiRitenutaAdmin(ImportExportModelAdmin):
    # resource = resources.DatiRitenutaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CausalePagamento)
class CausalePagamentoAdmin(ImportExportModelAdmin):
    # resource = resources.CausalePagamentoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiBollo)
class DatiBolloAdmin(ImportExportModelAdmin):
    # resource = resources.DatiBolloResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DatiCassaPrevidenziale)
class DatiCassaPrevidenzialeAdmin(ImportExportModelAdmin):
    # resource = resources.DatiCassaPrevidenzialeResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ScontoMaggiorazione)
class ScontoMaggiorazioneAdmin(ImportExportModelAdmin):
    # resource = resources.ScontoMaggiorazioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoScontoMaggiorazione)
class TipoScontoMaggiorazioneAdmin(ImportExportModelAdmin):
    # resource = resources.TipoScontoMaggiorazioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.AliquotaIva)
class AliquotaIvaAdmin(ImportExportModelAdmin):
    # resource = resources.AliquotaIvaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ContoBancario)
class ContoBancarioAdmin(ImportExportModelAdmin):
    # resource = resources.ContoBancarioResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.IstitutoFinanziario)
class IstitutoFinanziarioAdmin(ImportExportModelAdmin):
    # resource = resources.IstitutoFinanziarioResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DettaglioBancario)
class DettaglioBancarioAdmin(ImportExportModelAdmin):
    # resource = resources.DettaglioBancarioResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CondizionePagamento)
class CondizionePagamentoAdmin(ImportExportModelAdmin):
    # resource = resources.CondizionePagamentoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.DettaglioLinee)
class DettaglioLineeAdmin(ImportExportModelAdmin):
    # resource = resources.DettaglioLineeResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.altroDatoGestionale)
class altroDatoGestionaleAdmin(ImportExportModelAdmin):
    # resource = resources.altroDatoGestionaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoCessionePrestazione)
class TipoCessionePrestazioneAdmin(ImportExportModelAdmin):
    # resource = resources.TipoCessionePrestazioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CodiceArticolo)
class CodiceArticoloAdmin(ImportExportModelAdmin):
    # resource = resources.CodiceArticoloResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoCodiceArticolo)
class TipoCodiceArticoloAdmin(ImportExportModelAdmin):
    # resource = resources.TipoCodiceArticoloResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ArticoloLinea)
class ArticoloLineaAdmin(ImportExportModelAdmin):
    # resource = resources.ArticoloLineaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.UnitaMisura)
class UnitaMisuraAdmin(ImportExportModelAdmin):
    # resource = resources.UnitaMisuraResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoResa)
class TipoResaAdmin(ImportExportModelAdmin):
    # resource = resources.TipoResaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RiferimentoDDTNumeroLinea)
class RiferimentoDDTNumeroLineaAdmin(ImportExportModelAdmin):
    # resource = resources.RiferimentoDDTNumeroLineaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RiferimentoOrdineAcquistoNumeroLinea)
class RiferimentoOrdineAcquistoNumeroLineaAdmin(ImportExportModelAdmin):
    # resource = resources.RiferimentoOrdineAcquistoNumeroLineaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CodiciDocumentali)
class CodiciDocumentaliAdmin(ImportExportModelAdmin):
    # resource = resources.CodiciDocumentaliResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipologiaDocumentale)
class TipologiaDocumentaleAdmin(ImportExportModelAdmin):
    # resource = resources.TipologiaDocumentaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.OggettoDaFatturare)
class DatiEstesiDettaglioFatturabileAdmin(ImportExportModelAdmin):
    # resource = resources.DatiEstesiDettaglioFatturabileResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass
