2017-02-21 11:07:36 +01:00
|
|
|
from django.contrib import admin
|
2018-08-04 05:38:03 +02:00
|
|
|
from django.contrib.admin import AdminSite
|
|
|
|
from django.contrib.sites.admin import SiteAdmin
|
|
|
|
from django.contrib.sites.models import Site
|
2017-02-21 11:07:36 +01:00
|
|
|
|
2018-08-04 05:38:03 +02:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.contrib.auth.models import Group
|
|
|
|
from django.contrib.auth.admin import UserAdmin, GroupAdmin
|
|
|
|
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
|
|
|
|
class CustomAdminSite(AdminSite):
|
|
|
|
site_header = "Administration du Poulpe"
|
|
|
|
site_title = "Poulpe"
|
|
|
|
index_title = "Administration"
|
|
|
|
|
|
|
|
def index(self, request, extra_context=None):
|
|
|
|
if extra_context is None:
|
|
|
|
extra_context = {}
|
|
|
|
|
|
|
|
# Move last app to the top of `app_list`.
|
|
|
|
# TODO fournir un bon ordre
|
|
|
|
app_list = self.get_app_list(request)
|
|
|
|
app_list.insert(0, app_list.pop(-1))
|
|
|
|
|
|
|
|
extra_context['app_list'] = app_list
|
|
|
|
return super().index(request, extra_context)
|
|
|
|
|
|
|
|
|
|
|
|
admin_site = CustomAdminSite(name='admin')
|
|
|
|
admin_site.register(User, UserAdmin)
|
|
|
|
admin_site.register(Group, GroupAdmin)
|
|
|
|
admin_site.register(Site, SiteAdmin)
|
|
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|