From 4b6ce77d362c60a612f8214d9739134e41f84c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Norman=20J=C3=A4ckel?= Date: Tue, 19 Feb 2019 21:41:49 +0100 Subject: [PATCH] Reset logo configs if logo is deleted. --- CHANGELOG.rst | 1 + openslides/mediafiles/views.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 13b1782de..38a1f64a9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -23,6 +23,7 @@ Core: - Added password reset link (password reset via email) [#3914, #4199]. - Added global history mode [#3977, #4141]. - Projector refactoring [4119, #4130]. + - Fixed logo configuration if logo file is deleted [#4374]. Agenda: - Added viewpoint to assign multiple items to a new parent item [#4037]. diff --git a/openslides/mediafiles/views.py b/openslides/mediafiles/views.py index 03e479beb..5684ebb89 100644 --- a/openslides/mediafiles/views.py +++ b/openslides/mediafiles/views.py @@ -1,6 +1,7 @@ from django.http import HttpResponseForbidden, HttpResponseNotFound from django.views.static import serve +from ..core.config import config from ..utils.auth import has_perm from ..utils.rest_api import ModelViewSet, ValidationError from .access_permissions import MediafileAccessPermissions @@ -76,6 +77,12 @@ class MediafileViewSet(ModelViewSet): # on server via Django methods (file, open(), save(), ...). mediafile = self.get_object() mediafile.mediafile.storage.delete(mediafile.mediafile.name) + for logo in config["logos_available"]: + if config[logo]["path"] == mediafile.mediafile.url: + config[logo] = { + "display_name": config[logo]["display_name"], + "path": "", + } return super().destroy(request, *args, **kwargs)