Commit 90ffaae2 authored by erdnaxe's avatar erdnaxe 🎇

More models in admin

parent eed5f4b5
Pipeline #1352 passed with stage
in 2 minutes and 24 seconds
......@@ -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):
"""
......
Markdown is supported
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