From df531b87476cc59251ccc2f3285ae39b7c66cdf6 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Wed, 4 Apr 2018 11:25:45 +0200 Subject: [PATCH] Add fonts to the medifile serve view --- openslides/mediafiles/models.py | 6 ++++++ openslides/mediafiles/views.py | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/openslides/mediafiles/models.py b/openslides/mediafiles/models.py index 84eda474f..043f1d5b5 100644 --- a/openslides/mediafiles/models.py +++ b/openslides/mediafiles/models.py @@ -101,3 +101,9 @@ class Mediafile(RESTModelMixin, models.Model): if config[key]['path'] == self.mediafile.url: return True return False + + def is_font(self): + for key in config['fonts_available']: + if config[key]['path'] == self.mediafile.url: + return True + return False diff --git a/openslides/mediafiles/views.py b/openslides/mediafiles/views.py index 3a50682d5..430aa400c 100644 --- a/openslides/mediafiles/views.py +++ b/openslides/mediafiles/views.py @@ -77,9 +77,11 @@ def protected_serve(request, path, document_root=None, show_indexes=False): except Mediafile.DoesNotExist: return HttpResponseNotFound(content="Not found.") - if ((not has_perm(request.user, 'mediafiles.can_see') or - (mediafile.hidden and not has_perm(request.user, 'mediafiles.can_see_hidden'))) and - not mediafile.is_logo()): + can_see = has_perm(request.user, 'mediafiles.can_see') + is_special_file = mediafile.is_logo() or mediafile.is_font() + is_hidden_but_no_perms = mediafile.hidden and not has_perm(request.user, 'mediafiles.can_see_hidden') + + if not can_see or (is_hidden_but_no_perms and not is_special_file): return HttpResponseForbidden(content="Forbidden.") else: return serve(request, path, document_root, show_indexes)