From 991ef938760c5bdd015bdd0f6e93993cc393b328 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 2 Oct 2014 20:08:38 +0200 Subject: [PATCH] totals admin: true -> capability, fixes #2504 --- pandora/config.0xdb.jsonc | 6 +++--- pandora/config.indiancinema.jsonc | 6 +++--- pandora/config.padma.jsonc | 6 +++--- pandora/config.pandora.jsonc | 6 +++--- pandora/item/views.py | 3 +-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index db1c2e74..b210226c 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -749,9 +749,9 @@ "totals": [ {"id": "items"}, {"id": "runtime"}, - {"id": "files", "admin": true}, - {"id": "duration", "admin": true}, - {"id": "size", "admin": true}, + {"id": "files", "capability": "canSeeMedia"}, + {"id": "duration", "capability": "canSeeMedia"}, + {"id": "size", "capability": "canSeeMedia"}, {"id": "pixels"} ], "tv": { diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index 0c0a3ad6..dafd55c1 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -762,9 +762,9 @@ "totals": [ {"id": "items"}, {"id": "runtime"}, - {"id": "files", "admin": true}, - {"id": "duration", "admin": true}, - {"id": "size", "admin": true}, + {"id": "files", "capability": "canSeeMedia"}, + {"id": "duration", "capability": "canSeeMedia"}, + {"id": "size", "capability": "canSeeMedia"}, {"id": "pixels"} ], "tv": { diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index 47c1e839..589e6a06 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -644,9 +644,9 @@ ], "totals": [ {"id": "items"}, - {"id": "files", "admin": true}, - {"id": "duration", "admin": true}, - {"id": "size", "admin": true}, + {"id": "files", "capability": "canSeeMedia"}, + {"id": "duration", "capability": "canSeeMedia"}, + {"id": "size", "capability": "canSeeMedia"}, {"id": "pixels"} ], "tv": { diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index e9e86417..e2f92d48 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -560,9 +560,9 @@ ], "totals": [ {"id": "items"}, - {"id": "files", "admin": true}, - {"id": "duration", "admin": true}, - {"id": "size", "admin": true}, + {"id": "files", "capability": "canSeeMedia"}, + {"id": "duration", "capability": "canSeeMedia"}, + {"id": "size", "capability": "canSeeMedia"}, {"id": "pixels"} ], "tv": { diff --git a/pandora/item/views.py b/pandora/item/views.py index c175376e..7cbad78a 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -282,10 +282,9 @@ Positions Sum('pixels'), Sum('size') ) - level = 'guest' if request.user.is_anonymous() else request.user.get_profile().get_level() totals = [i['id'] for i in settings.CONFIG['totals'] - if not i.get('admin', False) or level in ('admin', 'staff') + if not 'capability' in i or has_capability(request.user, i['capability']) ] if 'duration' in totals: response['data']['duration'] = r['duration__sum']