From b0f1b2b0270cfee9689267602a235ca94c0194c1 Mon Sep 17 00:00:00 2001 From: Happy Felix Chukwuma Date: Sat, 10 Aug 2024 00:00:39 +0200 Subject: [PATCH] Updated environment config --- server/apps/research/permissions.py | 6 ++++-- server/core/production.py | 2 +- server/core/settings.py | 20 +++++++++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/server/apps/research/permissions.py b/server/apps/research/permissions.py index 09effbe..fe9899c 100644 --- a/server/apps/research/permissions.py +++ b/server/apps/research/permissions.py @@ -1,5 +1,5 @@ from rest_framework.permissions import BasePermission, SAFE_METHODS - +from rest_framework.exceptions import PermissionDenied class ArticleUserWritePermission(BasePermission): message = 'Editing articles is restricted to the author only.' @@ -7,4 +7,6 @@ class ArticleUserWritePermission(BasePermission): def has_object_permission(self, request, view, obj): if request.method in SAFE_METHODS: return True - return obj.author == request.user + if obj.author != request.user: + raise PermissionDenied('You do not have permission to edit this article.') + return True diff --git a/server/core/production.py b/server/core/production.py index 9c9cd1c..17b4dab 100644 --- a/server/core/production.py +++ b/server/core/production.py @@ -27,7 +27,7 @@ CSP_SCRIPT_SRC = ("self",) -CSP_IMG_SRC = ("self",) +CSP_IMG_SRC = ("self", "http://cms.2077.xyz", "https:cms.2077.xyz") CSP_FONT_SRC = ("self",) diff --git a/server/core/settings.py b/server/core/settings.py index 1ab41f6..7c07cd4 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -279,7 +279,7 @@ } # CKEDITOR CONFIGS -CKEDITOR_UPLOAD_PATH = "images/ckeditor_uploads/" +CKEDITOR_UPLOAD_PATH = 'ckeditor_uploads/' CKEDITOR_IMAGE_BACKEND = "pillow" @@ -320,6 +320,9 @@ 'blockQuote', 'fullscreen', 'removeFormat'], 'image': { + 'upload': { + 'path': 'ckeditor_uploads/', + }, 'toolbar': ['imageTextAlternative', '|', 'imageStyle:alignLeft', 'imageStyle:alignRight', 'imageStyle:alignCenter', 'imageStyle:side', 'imageResize', '|'], 'styles': [ @@ -328,8 +331,13 @@ 'alignLeft', 'alignRight', 'alignCenter', - ] - },'blockToolbar': { + ], + 'resize': { + 'enabled': False # Disable image resizing + } + }, + + 'blockToolbar': { 'items': [ 'paragraph', 'heading1', 'heading2', 'heading3', '|', @@ -339,7 +347,13 @@ ], 'location': 'left', # Position the block toolbar on the left }, + 'plugins': { + 'imageInsert': { + 'enabled': True + } + } }, + 'extends': { },