diff --git a/member/admin.py b/member/admin.py index d055d268..dc595d7e 100644 --- a/member/admin.py +++ b/member/admin.py @@ -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) diff --git a/note/admin.py b/note/admin.py index 78936da9..e634e607 100644 --- a/note/admin.py +++ b/note/admin.py @@ -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): """