Merge pull request #3683 from FinnStutzenstein/addFontsToMediafileServeView
Add fonts to the medifile serve view
This commit is contained in:
commit
ef90f55472
@ -101,3 +101,9 @@ class Mediafile(RESTModelMixin, models.Model):
|
|||||||
if config[key]['path'] == self.mediafile.url:
|
if config[key]['path'] == self.mediafile.url:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_font(self):
|
||||||
|
for key in config['fonts_available']:
|
||||||
|
if config[key]['path'] == self.mediafile.url:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
@ -77,9 +77,11 @@ def protected_serve(request, path, document_root=None, show_indexes=False):
|
|||||||
except Mediafile.DoesNotExist:
|
except Mediafile.DoesNotExist:
|
||||||
return HttpResponseNotFound(content="Not found.")
|
return HttpResponseNotFound(content="Not found.")
|
||||||
|
|
||||||
if ((not has_perm(request.user, 'mediafiles.can_see') or
|
can_see = has_perm(request.user, 'mediafiles.can_see')
|
||||||
(mediafile.hidden and not has_perm(request.user, 'mediafiles.can_see_hidden'))) and
|
is_special_file = mediafile.is_logo() or mediafile.is_font()
|
||||||
not mediafile.is_logo()):
|
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.")
|
return HttpResponseForbidden(content="Forbidden.")
|
||||||
else:
|
else:
|
||||||
return serve(request, path, document_root, show_indexes)
|
return serve(request, path, document_root, show_indexes)
|
||||||
|
Loading…
Reference in New Issue
Block a user