Commit bb1b7c51 authored by Hypsug0's avatar Hypsug0
Browse files

refactor: cleaup admin files

parent c36bfe9c
import logging
from django.apps import AppConfig, apps
from django.contrib import admin
logger = logging.getLogger(__name__)
class ListAdminMixin(object):
def __init__(self, model, admin_site):
......@@ -18,4 +22,5 @@ class CustomApp(AppConfig):
try:
admin.site.register(model, admin_class)
except admin.sites.AlreadyRegistered as e:
logger.error(e)
pass
......@@ -15,48 +15,6 @@ from .models import (
Tree,
)
# # =========================================================================
# # Set nested inline formsfor DictSpecie submodels
# # =========================================================================
#
#
# class DictSpecieDetailInline(nested_admin.NestedTabularInline):
# model = DictSpecieDetail
# can_delete = False
# verbose_name_plural = "Détails de l'espèce"
#
#
# class DictSpecieStatusInline(nested_admin.NestedTabularInline):
# model = DictSpecieStatus
# can_delete = False
# verbose_name_plural = "Détails des statuts de l'espèce"
#
#
# class DictSpecieAdmin(admin.ModelAdmin):
# inlines = (DictSpecieDetailInline, DictSpecieStatusInline,)
# # =========================================================================
# # Set nested inline formsfor User submodels
# # =========================================================================
#
#
# class UserDetailInline(LeafletGeoAdminMixin, nested_admin.NestedStackedInline):
# model = UserDetail
# can_delete = False
# verbose_name_plural = 'Details de utilisateur'
#
#
# class UserAdmin(nested_admin.NestedModelAdmin):
# inlines = (UserDetailInline,)
# list_display = ['id','username','email','first_name','last_name','is_superuser','is_staff','is_active','last_login']
# search_fields = ['username','email','first_name','last_name']
# list_filter = ('is_active','is_staff','is_superuser')
# =========================================================================
# Set nested inline forms for Place & Sight submodels
# =========================================================================
class CountDetailInLine(nested_admin.NestedStackedInline):
model = CountDetail
......@@ -346,15 +304,6 @@ class PlaceAdmin(LeafletGeoAdminMixin, nested_admin.NestedModelAdmin):
),
)
# =========================================================================
# fieldsets = (
# (None, {'fields': (('name', 'precision', 'territory', 'domain', 'plan_localite'), ('type', 'is_hidden', 'habitat', 'altitude', 'photo_file'), ('is_gite',
# 'convention', 'convention_file'), 'geom')}),
# ('Autres infos', {'classes': ('collapse', 'grp-collapse grp-open',),
# 'fields': (('x_l93', 'y_l93'), ('municipality', 'department', 'region'))}),
# )
# =========================================================================
def save_model(self, request, obj, form, change):
if getattr(obj, "created_by", None) is None:
obj.created_by = request.user
......@@ -366,30 +315,6 @@ class PlaceAdmin(LeafletGeoAdminMixin, nested_admin.NestedModelAdmin):
continue
yield inline.get_formset(request, obj)
# =========================================================================
# def save_model(self, request, obj, form, change):
# if getattr(obj, 'author', None) is None:
# obj.author = Territory.object.filter(geom__contains=geom)
# obj.save()
# =========================================================================
# class CommentAdmin(admin.ModelAdmin):
# pass
#
# def save_model(self, request, obj, form, change):
# if getattr(obj, 'created_by', None) is None:
# obj.created_by = request.user
# obj.save()
# class CatchAuthAdmin(admin.ModelAdmin):
# model = CatchAuth
# list_display = ('id_catchauth', 'date_start', 'date_end',
# 'territory', 'official_reference', 'file')
# search_fields = ('territory',)
# sortable_field_name = ['__all__']
class ActuAdmin(admin.ModelAdmin):
list_display = ("title", "author", "timestamp_create", "timestamp_update")
......@@ -403,15 +328,8 @@ class ActuAdmin(admin.ModelAdmin):
obj.save()
# admin.site.unregister(User)
# admin.site.register(User, UserAdmin)
# admin.site.register(Territory,LeafletGeoAdmin)
admin.site.register(Place, PlaceAdmin)
admin.site.register(Sighting, SightingAdmin)
# admin.site.register(DictSpecie, DictSpecieAdmin)
# admin.site.register(CatchAuth, CatchAuthAdmin)
admin.site.register(Session, SessionAdmin)
admin.site.register(Transmitter)
# admin.site.register(Comment, CommentAdmin)
admin.site.register(Study)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment