From 45c4772f781b7a9c14c49439bde4b5b2a6be0017 Mon Sep 17 00:00:00 2001 From: d42 Date: Wed, 10 Oct 2018 20:37:56 +0200 Subject: [PATCH] staff ItemAdmin --- storage/admin.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/storage/admin.py b/storage/admin.py index 6755f32..29098a4 100644 --- a/storage/admin.py +++ b/storage/admin.py @@ -29,7 +29,17 @@ class LabelInline(admin.TabularInline): model = Label -class ItemAdmin(admin.ModelAdmin): +class StaffModelAdmin(admin.ModelAdmin): + + def has_add_permission(self, request, obj=None): + return request.user.is_staff or request.user.is_superuser + + has_change_permission = has_add_permission + has_delete_permission = has_add_permission + has_module_permission = has_add_permission + + +class ItemAdmin(StaffModelAdmin): list_display = ('_name',) list_filter = ('categories',) form = ItemForm @@ -71,7 +81,7 @@ class ItemAdmin(admin.ModelAdmin): admin.site.register(Item, ItemAdmin) -admin.site.register(Category) +admin.site.register(Category, StaffModelAdmin) from django.contrib.auth.models import User from django.contrib.auth.models import Group