]> git.parisson.com Git - telemeta.git/commitdiff
Limit public access to graphers
authorThomas Fillon <thomas@parisson.com>
Thu, 20 Apr 2017 20:16:51 +0000 (22:16 +0200)
committerThomas Fillon <thomas@parisson.com>
Fri, 2 Jun 2017 11:55:23 +0000 (13:55 +0200)
telemeta/views/item.py

index 1e2d6f731f18125715379692a7090338c6cc53e4..d6e0a0ca8966930132e467b96f653427fb300042 100644 (file)
@@ -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'):