From 20a2a51c5189019f5c6e47e65c9cafdc344d418b Mon Sep 17 00:00:00 2001 From: Thomas Fillon Date: Thu, 20 Apr 2017 22:16:51 +0200 Subject: [PATCH] Limit public access to graphers --- telemeta/views/item.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/telemeta/views/item.py b/telemeta/views/item.py index 1e2d6f73..d6e0a0ca 100644 --- a/telemeta/views/item.py +++ b/telemeta/views/item.py @@ -45,9 +45,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'): -- 2.39.5