mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-25 10:08:36 +02:00
feat(app): disable API when demo mode is enabled
This commit is contained in:
@@ -261,7 +261,10 @@ if DEBUG:
|
|||||||
REST_FRAMEWORK = {
|
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": ["rest_framework.permissions.DjangoModelPermissions"],
|
"DEFAULT_PERMISSION_CLASSES": [
|
||||||
|
"apps.api.permissions.NotInDemoMode",
|
||||||
|
"rest_framework.permissions.DjangoModelPermissions",
|
||||||
|
],
|
||||||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
|
||||||
"PAGE_SIZE": 10,
|
"PAGE_SIZE": 10,
|
||||||
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
|
||||||
|
|||||||
10
app/apps/api/permissions.py
Normal file
10
app/apps/api/permissions.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
from rest_framework.permissions import BasePermission
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
class NotInDemoMode(BasePermission):
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
if settings.DEMO and not request.user.is_superuser:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user