]> 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>
Thu, 20 Apr 2017 20:16:51 +0000 (22:16 +0200)
telemeta/views/item.py

index ed0c6e41e68e4dad9a8d55f7ef53d8a1f8d489e1..636b8bc894d2ce3a406223d0dd10b50e6f7c3a65 100644 (file)
@@ -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'):