Check in some random production changes

This commit is contained in:
Piotr Dobrowolski 2020-05-12 20:58:10 +02:00
parent 5e598d80b4
commit 83e2afcf06
2 changed files with 9 additions and 5 deletions

View File

@ -175,7 +175,7 @@ REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions, # Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users. # or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [ 'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly', 'rest_framework.permissions.IsAuthenticatedOrReadOnly',
], ],
'DEFAULT_AUTHENTICATION_CLASSES': [ 'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.BasicAuthentication',

View File

@ -30,17 +30,17 @@ class LabelInline(admin.TabularInline):
model = Label model = Label
class StaffModelAdmin(admin.ModelAdmin): class ModelAdminMixin(object):
def has_add_permission(self, request, obj=None): def has_add_permission(self, request, obj=None):
return request.user.is_staff or request.user.is_superuser return request.user.is_authenticated()
has_change_permission = has_add_permission has_change_permission = has_add_permission
has_delete_permission = has_add_permission has_delete_permission = has_add_permission
has_module_permission = has_add_permission has_module_permission = has_add_permission
class ItemAdmin(StaffModelAdmin): class ItemAdmin(ModelAdminMixin, admin.ModelAdmin):
list_display = ('_name',) list_display = ('_name',)
list_filter = ('categories',) list_filter = ('categories',)
form = ItemForm form = ItemForm
@ -81,11 +81,15 @@ class ItemAdmin(StaffModelAdmin):
return super(ItemAdmin, self).response_action(request, queryset) return super(ItemAdmin, self).response_action(request, queryset)
class NormalModelAdmin(ModelAdminMixin, admin.ModelAdmin):
pass
admin.site.site_title = 'Hackerspace Storage Admin' admin.site.site_title = 'Hackerspace Storage Admin'
admin.site.site_header = 'Hackerspace Storage Admin' admin.site.site_header = 'Hackerspace Storage Admin'
admin.site.register(Item, ItemAdmin) admin.site.register(Item, ItemAdmin)
admin.site.register(Category, StaffModelAdmin) admin.site.register(Category, NormalModelAdmin)
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.auth.models import Group from django.contrib.auth.models import Group