summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord42 <d42@users.noreply.github.com>2018-10-10 20:37:56 +0200
committerd42 <d42@users.noreply.github.com>2018-10-10 20:37:56 +0200
commit45c4772f781b7a9c14c49439bde4b5b2a6be0017 (patch)
treef40147455624d5915e2cb86a4341127b0625e952
parent26901367113c1cbc55986b9e17ad6fdafe9ffd8d (diff)
downloadspejstore-45c4772f781b7a9c14c49439bde4b5b2a6be0017.tar.gz
spejstore-45c4772f781b7a9c14c49439bde4b5b2a6be0017.tar.bz2
spejstore-45c4772f781b7a9c14c49439bde4b5b2a6be0017.zip
staff ItemAdmin
-rw-r--r--storage/admin.py14
1 files 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