From 1587f26181f9a0bd7ca4ea3809f3bd24b75a4d83 Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Thu, 14 May 2020 23:16:53 +0200 Subject: [PATCH] attempt at fixing missing label editor --- storage/admin.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/storage/admin.py b/storage/admin.py index 8dc7a21..fbdcae1 100644 --- a/storage/admin.py +++ b/storage/admin.py @@ -7,6 +7,15 @@ from django_select2.forms import ModelSelect2Widget, Select2MultipleWidget from .models import Item, ItemImage, Category, Label from .widgets import ItemSelectWidget, PropsSelectWidget +class ModelAdminMixin(object): + + def has_add_permission(self, request, obj=None): + return request.user.is_authenticated() + + has_change_permission = has_add_permission + has_delete_permission = has_add_permission + has_module_permission = has_add_permission + class ItemForm(forms.ModelForm): name = forms.CharField(widget=forms.TextInput()) @@ -21,24 +30,15 @@ class ItemForm(forms.ModelForm): } -class ItemImageInline(admin.TabularInline): +class ItemImageInline(ModelAdminMixin, admin.TabularInline): model = ItemImage extra = 1 -class LabelInline(admin.TabularInline): +class LabelInline(ModelAdminMixin, admin.TabularInline): model = Label -class ModelAdminMixin(object): - - def has_add_permission(self, request, obj=None): - return request.user.is_authenticated() - - has_change_permission = has_add_permission - has_delete_permission = has_add_permission - has_module_permission = has_add_permission - class ItemAdmin(ModelAdminMixin, admin.ModelAdmin): list_display = ('_name',)