diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 513b0dd43..b8def0f45 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -16,10 +16,11 @@ "canDeleteItems": {"admin": true}, "canDownloadVideo": {"guest": 0, "member": 0, "friend": 4, "staff": 4, "admin": 4}, "canEditMetadata": {"staff": true, "admin": true}, + "canEditUsers": {"admin": true}, "canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4}, "canReloadMetadata": {"staff": true, "admin": true}, - "canSeeDebugMenu": {"admin": true}, + "canSeeDebugMenu": {"staff": true, "admin": true}, "canSeeFiles": {"staff": true, "admin": true}, "canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4}, "canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true} @@ -321,7 +322,7 @@ "type": "float", "columnWidth": 90, "format": {"type": "color", "args": ["hue"]}, - "sortOperator": "-" + "sortOperator": "+" }, { "id": "saturation", @@ -444,6 +445,13 @@ "columnWidth": 60, "format": {"type": "percent", "args": ["auto", 2]} }, + { + "id": "rightslevel", + "title": "Rights Level", + "type": "integer", + "columnWidth": 60, + "sortOperator": "+" + }, { "id": "canPlayVideo", "title": "Can Play Video", diff --git a/pandora/app/config.py b/pandora/app/config.py index 233cf7f76..0545a0855 100644 --- a/pandora/app/config.py +++ b/pandora/app/config.py @@ -18,18 +18,22 @@ RUN_RELOADER = True def load_config(): with open(settings.SITE_CONFIG) as f: - config = ox.jsonc.load(f) + try: + config = ox.jsonc.load(f) + except: + config = None - config['site']['id'] = settings.SITEID - config['site']['name'] = settings.SITENAME - config['site']['sectionName'] = settings.SITENAME - config['site']['url'] = settings.URL + if config: + config['site']['id'] = settings.SITEID + config['site']['name'] = settings.SITENAME + config['site']['sectionName'] = settings.SITENAME + config['site']['url'] = settings.URL - config['keys'] = {} - for key in config['itemKeys']: - config['keys'][key['id']] = key + config['keys'] = {} + for key in config['itemKeys']: + config['keys'][key['id']] = key - settings.CONFIG = config + settings.CONFIG = config def reloader_thread(): _config_mtime = 0 diff --git a/pandora/item/models.py b/pandora/item/models.py index a9a3875a8..5de4b8aae 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -424,7 +424,7 @@ class Item(models.Model): i = { 'id': self.itemId, 'rendered': self.rendered, - 'rightsLevel': self.level + 'rightslevel': self.level } i.update(self.external_data) i.update(self.data) @@ -587,6 +587,7 @@ class Item(models.Model): 'popularity', 'published', 'resolution', + 'rightslevel', 'saturation', 'size', 'volume', @@ -647,6 +648,7 @@ class Item(models.Model): s.itemId = self.itemId.replace('0x', 'xx') s.modified = self.modified s.published = self.published + s.rightslevel = self.level s.aspectratio = self.get('aspectRatio') s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')]) diff --git a/pandora/item/views.py b/pandora/item/views.py index ace853233..5498a6853 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -396,7 +396,7 @@ def get(request): if data['keys'] and 'files' in data['keys']: info['files'] = item.get_files(request.user) if not data['keys'] or 'notes' in data['keys'] \ - and request.user.get_profile().capability('canSeeNotes'): + and request.user.get_profile().capability('canEditMetadata'): info['notes'] = item.notes response['data'] = info else: @@ -442,12 +442,12 @@ def edit(request): if item.editable(request.user): response = json_response(status=200, text='ok') if 'notes' in data: - if request.user.get_profile().capability('canSeeNotes'): + if request.user.get_profile().capability('canEditMetadata'): item.notes = data['notes'] del data['notes'] - if 'rightsLevel' in data: - item.level = data['rightsLevel'] - del data['rightsLevel'] + if 'rightslevel' in data: + item.level = data['rightslevel'] + del data['rightslevel'] r = item.edit(data) if r: r.wait() diff --git a/static/js/pandora/clipList.js b/static/js/pandora/clipList.js index 2500dfea1..5a703be4b 100644 --- a/static/js/pandora/clipList.js +++ b/static/js/pandora/clipList.js @@ -132,13 +132,13 @@ pandora.ui.clipList = function(videoRatio) { width = fixedRatio > 1 ? size : Math.round(size * fixedRatio); height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size; } - pandora.api.get({id: item, keys: ['durations', 'rightsLevel']}, function(result) { + pandora.api.get({id: item, keys: ['durations', 'rightslevel']}, function(result) { var points = [that.value(id, 'in'), that.value(id, 'out')], partsAndPoints = pandora.getVideoPartsAndPoints( result.data.durations, points ), $player = Ox.VideoPlayer({ - censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightsLevel + censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightslevel ? [{'in': partsAndPoints.points[0], out: partsAndPoints.points[1]}] : [], height: height, diff --git a/static/js/pandora/infoView.js b/static/js/pandora/infoView.js index 5cfb44b1f..33f0b42a7 100644 --- a/static/js/pandora/infoView.js +++ b/static/js/pandora/infoView.js @@ -416,9 +416,9 @@ pandora.ui.infoView = function(data) { .appendTo($text); }); - $('
').css({height: '8px'}).appendTo($text); + $('
').css({height: '16px'}).appendTo($text); - //pandora.createLinks($text); + // Hue, Saturation, Lightness, Volume -------------------------------------- ['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) { $('
') @@ -428,6 +428,8 @@ pandora.ui.infoView = function(data) { .appendTo($statistics); }); + // Rights Level ------------------------------------------------------------ + var $rightsLevel = $('
'); $('
') .css({marginBottom: '4px'}) @@ -436,6 +438,43 @@ pandora.ui.infoView = function(data) { .appendTo($statistics); renderRightsLevel(); + // Notes ------------------------------------------------------------------- + + if (canEdit) { + + Ox.print('DATA', data) + $('
') + .css({marginBottom: '4px'}) + .append(formatKey('Notes', true)) + .append( + Ox.Editable({ + format: function(value) { + return value || formatLight('No notes'); + }, + height: 128, + placeholder: formatLight('No notes'), + tooltip: 'Doubleclick to edit', + type: 'textarea', + value: data.notes, + width: 128 + }) + .bindEvent({ + submit: function(event) { + pandora.api.edit({ + id: data.id, + notes: event.value + }, function(result) { + // ... + }); + } + }) + ) + .appendTo($statistics); + + } + + $('
').css({height: '16px'}).appendTo($statistics); + if (canEdit) { $icon.bindEvent({ doubleclick: function() { @@ -587,21 +626,23 @@ pandora.ui.infoView = function(data) { marginBottom: '4px' }) .appendTo($capabilities); - Ox.Label({ - textAlign: 'center', - title: canEdit ? Ox.toTitleCase(userLevel) : pandora.site.rightsLevels[data.rightsLevel].name, - width: canEdit ? 48 : 68 - }) - .css(Ox.extend( - { - float: 'left', - paddingTop: '2px', - height: '12px', - fontSize: '8px' - }, - canEdit ? getUserLevelCSS(userLevel) : getRightsLevelCSS(data.rightsLevel) - )) - .appendTo($line); + if (canEdit) { + Ox.Label({ + textAlign: 'center', + title: Ox.toTitleCase(userLevel), + width: 48 + }) + .css(Ox.extend( + { + float: 'left', + paddingTop: '2px', + height: '12px', + fontSize: '8px' + }, + getUserLevelCSS(userLevel) + )) + .appendTo($line); + } capabilities.forEach(function(capability) { var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel; Ox.Button({ @@ -613,11 +654,24 @@ pandora.ui.infoView = function(data) { title: capability.symbol, type: 'image' }) - .css(Ox.extend({ - marginLeft: '4px' - }, getCapabilityCSS(hasCapability))) + .css(getCapabilityCSS(hasCapability)) + .css('margin' + (canEdit ? 'Left' : 'Right'), '4px') .appendTo($line); }); + if (!canEdit) { + Ox.Button({ + title: 'Help', + tooltip: 'About Rights', + type: 'image' + }) + .css({marginLeft: '52px'}) + .bindEvent({ + click: function() { + pandora.URL.push('/rights'); + } + }) + .appendTo($line); + } }); } @@ -724,13 +778,13 @@ pandora.ui.infoView = function(data) { } function renderRightsLevel() { - var $capabilites, $rightsLevelSelect, - rightsLevelCSS = getRightsLevelCSS(data.rightsLevel); + var $capabilites, $rightsLevelLabel, $rightsLevelSelect, + rightsLevelCSS = getRightsLevelCSS(data.rightslevel); $rightsLevel.empty(); if (canEdit) { $rightsLevelSelect = Ox.Select({ items: pandora.site.rightsLevels.map(function(rightsLevel, i) { - return {id: i, title: rightsLevel.name, checked: i == data.rightsLevel}; + return {id: i, title: rightsLevel.name, checked: i == data.rightslevel}; }), width: 128 }) @@ -742,15 +796,24 @@ pandora.ui.infoView = function(data) { var rightsLevel = event.selected[0].id; $rightsLevelSelect.css(getRightsLevelCSS(rightsLevel)); renderCapabilities(rightsLevel); - pandora.api.edit({id: data.id, rightsLevel: rightsLevel}, function(result) { + pandora.api.edit({id: data.id, rightslevel: rightsLevel}, function(result) { // ... }); } }) .appendTo($rightsLevel); + } else { + $rightsLevelLabel = Ox.Label({ + title: pandora.site.rightsLevels[data.rightslevel].name, + width: 128 + }) + .css(Ox.extend({ + marginBottom: '4px' + }, rightsLevelCSS)) + .appendTo($rightsLevel); } $capabilities = $('
').appendTo($rightsLevel); - renderCapabilities(data.rightsLevel); + renderCapabilities(data.rightslevel); } function toggleIconSize() { diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 61c84398b..6fe192c74 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -7,7 +7,7 @@ pandora.ui.item = function() { pandora.api.get({ id: pandora.user.ui.item, keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1 ? - [ 'cuts', 'duration', 'layers', 'parts', 'rendered', 'rightsLevel', 'size', 'title', 'videoRatio'] : [] + [ 'cuts', 'duration', 'layers', 'parts', 'rendered', 'rightslevel', 'size', 'title', 'videoRatio'] : [] }, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) { if (result.status.code == 200) { @@ -34,8 +34,8 @@ pandora.ui.item = function() { return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; }) : [], - canPlayClips = pandora.site.capabilities.canPlayClips[pandora.user.level] >= result.data.rightsLevel, - canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= result.data.rightsLevel, + canPlayClips = pandora.site.capabilities.canPlayClips[pandora.user.level] >= result.data.rightslevel, + canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= result.data.rightslevel, censored = canPlayVideo ? [] : canPlayClips ? ( subtitles.length diff --git a/static/js/pandora/itemClips.js b/static/js/pandora/itemClips.js index 8b835e1f1..82e1c5a8e 100644 --- a/static/js/pandora/itemClips.js +++ b/static/js/pandora/itemClips.js @@ -75,12 +75,12 @@ pandora.ui.itemClips = function(options) { $img = $item.find('.OxIcon > img'); points = [$item.data('in'), $item.data('out')]; if ($img.length) { - pandora.api.get({id: self.options.id, keys: ['durations', 'rightsLevel']}, function(result) { + pandora.api.get({id: self.options.id, keys: ['durations', 'rightslevel']}, function(result) { var partsAndPoints = pandora.getVideoPartsAndPoints( result.data.durations, points ), $player = Ox.VideoPlayer({ - censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightsLevel + censored: pandora.site.capabilities.canPlayClips[pandora.user.level] < result.data.rightslevel ? [{'in': partsAndPoints.points[0], out: partsAndPoints.points[1]}] : [], enableMouse: true,