From: Thomas Fillon Date: Thu, 20 Apr 2017 20:16:51 +0000 (+0200) Subject: Limit public access to graphers X-Git-Tag: 1.7.0~2^2~21^2^2~17 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=959827e99a25e177876d47e2421fce29cdf52b68;p=telemeta.git Limit public access to graphers --- diff --git a/telemeta/views/item.py b/telemeta/views/item.py index ed0c6e41..636b8bc8 100644 --- a/telemeta/views/item.py +++ b/telemeta/views/item.py @@ -44,9 +44,18 @@ class ItemBaseMixin(TelemetaBaseMixin): default_grapher_sizes = getattr(settings, 'TIMESIDE_DEFAULT_GRAPHER_SIZES', ['346x130', ]) auto_zoom = getattr(settings, 'TIMESIDE_AUTO_ZOOM', False) + public_graphers = ['waveform_centroid' ,'waveform_simple', + 'spectrogram', 'spectrogram_log'] + def get_graphers(self): graphers = [] + user = self.request.user + graphers_access = False + if user.is_staff or user.is_superuser: + graphers_access = True for grapher in self.graphers: + if not graphers_access and grapher.id() not in self.public_graphers: + continue if grapher.id() == self.default_grapher_id: graphers.insert(0, {'name': grapher.name(), 'id': grapher.id()}) elif not hasattr(grapher, '_staging'):