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.Progetto)
class ProgettoAdmin(ImportExportModelAdmin):
    # resource = resources.ProgettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ValorizzazioneEconomicaProgetto)
class ValorizzazioneEconomicaProgettoAdmin(ImportExportModelAdmin):
    # resource = resources.ValorizzazioneEconomicaProgettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.Repository)
class RepositoryAdmin(ImportExportModelAdmin):
    # resource = resources.RepositoryResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoRelazione)
class TipoRelazioneAdmin(ImportExportModelAdmin):
    # resource = resources.TipoRelazioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.Attivita)
class AttivitaAdmin(ImportExportModelAdmin):
    # resource = resources.AttivitaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RisorsaChiave)
class RisorsaChiaveAdmin(ImportExportModelAdmin):
    # resource = resources.RisorsaChiaveResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.PropostaDiValore)
class PropostaDiValoreAdmin(ImportExportModelAdmin):
    # resource = resources.PropostaDiValoreResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CanaleDiDistribuzione)
class CanaleDiDistribuzioneAdmin(ImportExportModelAdmin):
    # resource = resources.CanaleDiDistribuzioneResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SettoreDiMercato)
class SettoreDiMercatoAdmin(ImportExportModelAdmin):
    # resource = resources.SettoreDiMercatoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.FlussoDiRicavi)
class FlussoDiRicaviAdmin(ImportExportModelAdmin):
    # resource = resources.FlussoDiRicaviResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.StrutturaDeiCosti)
class StrutturaDeiCostiAdmin(ImportExportModelAdmin):
    # resource = resources.StrutturaDeiCostiResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.SettoreAzienda)
class SettoreAziendaAdmin(ImportExportModelAdmin):
    # resource = resources.SettoreAziendaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RelazioneConAzienda)
class RelazioneConAziendaAdmin(ImportExportModelAdmin):
    # resource = resources.RelazioneConAziendaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.TipoAttivita)
class TipoAttivitaAdmin(ImportExportModelAdmin):
    # resource = resources.TipoAttivitaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ValoreDelProgetto)
class ValoreDelProgettoAdmin(ImportExportModelAdmin):
    # resource = resources.ValoreDelProgettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.AttivitaDelProgetto)
class AttivitaDelProgettoAdmin(ImportExportModelAdmin):
    # resource = resources.AttivitaDelProgettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.AssetDelProgetto)
class AssetDelProgettoAdmin(ImportExportModelAdmin):
    # resource = resources.AssetDelProgettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RisorsaPersonale)
class RisorsaPersonaleAdmin(ImportExportModelAdmin):
    # resource = resources.RisorsaPersonaleResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RisorsaFisica)
class RisorsaFisicaAdmin(ImportExportModelAdmin):
    # resource = resources.RisorsaFisicaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.RisorsaFinanziaria)
class RisorsaFinanziariaAdmin(ImportExportModelAdmin):
    # resource = resources.RisorsaFinanziariaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ValoreDellAttivita)
class ValoreDellAttivitaAdmin(ImportExportModelAdmin):
    # resource = resources.ValoreDellAttivitaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ValorizzazioneEconomicaAttivita)
class ValorizzazioneEconomicaAttivitaAdmin(ImportExportModelAdmin):
    # resource = resources.ValorizzazioneEconomicaAttivitaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.AssetDaAttivita)
class AssetDaAttivitaAdmin(ImportExportModelAdmin):
    # resource = resources.AssetDaAttivitaResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.ArchivioFiles)
class ArchivioFilesAdmin(ImportExportModelAdmin):
    # resource = resources.ArchivioFilesResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass


@admin.register(models.CanaleDistribuzioneIndiretto)
class CanaleDistribuzioneIndirettoAdmin(ImportExportModelAdmin):
    # resource = resources.CanaleDistribuzioneIndirettoResource
    # list_per_page = 15
    # paginator = CachingPaginator
    # show_full_result_count = False
    pass

