Skip to content

Commit

Permalink
Merge pull request #1214 from betagouv/1213-admin-improvements
Browse files Browse the repository at this point in the history
Améliore des éléments de l'interface admin
  • Loading branch information
alemangui authored Oct 31, 2024
2 parents e2ecdfb + 7c566c8 commit 004bbe3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
3 changes: 3 additions & 0 deletions data/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from data.models import PlantPart, PlantFamily
from simple_history.admin import SimpleHistoryAdmin

from django.contrib.auth.models import Group


@admin.register(PlantPart)
class PlantPartAdmin(SimpleHistoryAdmin):
Expand All @@ -37,3 +39,4 @@ def get_admin_header():

admin.site.site_header = get_admin_header()
admin.site.site_title = get_admin_header()
admin.site.unregister(Group)
4 changes: 3 additions & 1 deletion data/admin/declaration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django import forms
from django.contrib import admin

from simple_history.admin import SimpleHistoryAdmin

from data.models import (
ComputedSubstance,
Declaration,
Expand Down Expand Up @@ -184,7 +186,7 @@ class Meta:


@admin.register(Declaration)
class DeclarationAdmin(admin.ModelAdmin):
class DeclarationAdmin(SimpleHistoryAdmin):
form = DeclarationForm
list_display = ("name", "status", "company", "author")
list_filter = ("status", "company", "author")
Expand Down
40 changes: 35 additions & 5 deletions data/admin/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _

from data.models import DeclarantRole, SupervisorRole

Expand All @@ -23,11 +24,6 @@ class SupervisorRoleInline(admin.TabularInline):

@admin.register(get_user_model())
class UserAdmin(UserAdmin):
def __init__(self, model, admin_site):
fieldsets = self.fieldsets[:1] + ((None, {"fields": ("is_verified", "phone_number")}),) + self.fieldsets[1:]
self.fieldsets = fieldsets
super().__init__(model, admin_site)

add_fieldsets = UserAdmin.add_fieldsets + (
(None, {"fields": ("email", "first_name", "last_name", "phone_number")}),
)
Expand All @@ -43,3 +39,37 @@ def __init__(self, model, admin_site):
DeclarantRoleInline,
SupervisorRoleInline,
)

fieldsets = (
(
None,
{
"fields": (
"username",
"password",
"is_verified",
)
},
),
(
_("Personal info"),
{
"fields": (
"first_name",
"last_name",
"email",
"phone_number",
)
},
),
(
_("Permissions"),
{
"fields": (
"is_active",
"is_staff",
"is_superuser",
),
},
),
)

0 comments on commit 004bbe3

Please sign in to comment.