mirror of https://gitlab.crans.org/bde/nk20
More models in admin
This commit is contained in:
parent
eed5f4b542
commit
90ffaae2f2
|
@ -7,7 +7,7 @@ from django.contrib.auth.admin import UserAdmin
|
|||
from django.contrib.auth.models import User
|
||||
|
||||
from .forms import CustomUserChangeForm
|
||||
from .models import Club, Profile
|
||||
from .models import Club, Membership, Profile, Role
|
||||
|
||||
|
||||
class ProfileInline(admin.StackedInline):
|
||||
|
@ -33,6 +33,11 @@ class CustomUserAdmin(UserAdmin):
|
|||
return super().get_inline_instances(request, obj)
|
||||
|
||||
|
||||
# Update Django User with profile
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User, CustomUserAdmin)
|
||||
|
||||
# Add other models
|
||||
admin.site.register(Club)
|
||||
admin.site.register(Membership)
|
||||
admin.site.register(Role)
|
||||
|
|
|
@ -26,6 +26,21 @@ class NoteClubAdmin(admin.ModelAdmin):
|
|||
list_filter = ('is_active',)
|
||||
search_fields = ['club__name']
|
||||
|
||||
# We can't change club after creation
|
||||
readonly_fields = ('club',)
|
||||
|
||||
def has_add_permission(self, request):
|
||||
"""
|
||||
A club note should not be manually added
|
||||
"""
|
||||
return False
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
"""
|
||||
A club note should not be manually removed
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
class NoteSpecialAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
|
@ -47,6 +62,21 @@ class NoteUserAdmin(admin.ModelAdmin):
|
|||
date_hierarchy = 'user__date_joined'
|
||||
ordering = ['-user__date_joined']
|
||||
|
||||
# We can't change user after creation
|
||||
readonly_fields = ('user',)
|
||||
|
||||
def has_add_permission(self, request):
|
||||
"""
|
||||
An user note should not be manually added
|
||||
"""
|
||||
return False
|
||||
|
||||
def has_delete_permission(self, request, obj=None):
|
||||
"""
|
||||
An user note should not be manually removed
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
class TransactionTemplateAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue