attempt at fixing missing label editor
This commit is contained in:
parent
4c4d889aac
commit
1587f26181
|
@ -7,6 +7,15 @@ from django_select2.forms import ModelSelect2Widget, Select2MultipleWidget
|
||||||
from .models import Item, ItemImage, Category, Label
|
from .models import Item, ItemImage, Category, Label
|
||||||
from .widgets import ItemSelectWidget, PropsSelectWidget
|
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):
|
class ItemForm(forms.ModelForm):
|
||||||
name = forms.CharField(widget=forms.TextInput())
|
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
|
model = ItemImage
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
class LabelInline(admin.TabularInline):
|
class LabelInline(ModelAdminMixin, admin.TabularInline):
|
||||||
model = Label
|
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):
|
class ItemAdmin(ModelAdminMixin, admin.ModelAdmin):
|
||||||
list_display = ('_name',)
|
list_display = ('_name',)
|
||||||
|
|
Loading…
Reference in New Issue