rightslevel

This commit is contained in:
rolux 2011-10-25 13:59:27 +00:00
parent 47dfb7f5a9
commit 389619feaf
8 changed files with 126 additions and 49 deletions

View file

@ -16,10 +16,11 @@
"canDeleteItems": {"admin": true}, "canDeleteItems": {"admin": true},
"canDownloadVideo": {"guest": 0, "member": 0, "friend": 4, "staff": 4, "admin": 4}, "canDownloadVideo": {"guest": 0, "member": 0, "friend": 4, "staff": 4, "admin": 4},
"canEditMetadata": {"staff": true, "admin": true}, "canEditMetadata": {"staff": true, "admin": true},
"canEditUsers": {"admin": true},
"canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4}, "canPlayClips": {"guest": 2, "member": 2, "friend": 4, "staff": 4, "admin": 4},
"canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4}, "canPlayVideo": {"guest": 1, "member": 1, "friend": 4, "staff": 4, "admin": 4},
"canReloadMetadata": {"staff": true, "admin": true}, "canReloadMetadata": {"staff": true, "admin": true},
"canSeeDebugMenu": {"admin": true}, "canSeeDebugMenu": {"staff": true, "admin": true},
"canSeeFiles": {"staff": true, "admin": true}, "canSeeFiles": {"staff": true, "admin": true},
"canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4}, "canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4},
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true} "canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true}
@ -321,7 +322,7 @@
"type": "float", "type": "float",
"columnWidth": 90, "columnWidth": 90,
"format": {"type": "color", "args": ["hue"]}, "format": {"type": "color", "args": ["hue"]},
"sortOperator": "-" "sortOperator": "+"
}, },
{ {
"id": "saturation", "id": "saturation",
@ -444,6 +445,13 @@
"columnWidth": 60, "columnWidth": 60,
"format": {"type": "percent", "args": ["auto", 2]} "format": {"type": "percent", "args": ["auto", 2]}
}, },
{
"id": "rightslevel",
"title": "Rights Level",
"type": "integer",
"columnWidth": 60,
"sortOperator": "+"
},
{ {
"id": "canPlayVideo", "id": "canPlayVideo",
"title": "Can Play Video", "title": "Can Play Video",

View file

@ -18,18 +18,22 @@ RUN_RELOADER = True
def load_config(): def load_config():
with open(settings.SITE_CONFIG) as f: 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 if config:
config['site']['name'] = settings.SITENAME config['site']['id'] = settings.SITEID
config['site']['sectionName'] = settings.SITENAME config['site']['name'] = settings.SITENAME
config['site']['url'] = settings.URL config['site']['sectionName'] = settings.SITENAME
config['site']['url'] = settings.URL
config['keys'] = {} config['keys'] = {}
for key in config['itemKeys']: for key in config['itemKeys']:
config['keys'][key['id']] = key config['keys'][key['id']] = key
settings.CONFIG = config settings.CONFIG = config
def reloader_thread(): def reloader_thread():
_config_mtime = 0 _config_mtime = 0

View file

@ -424,7 +424,7 @@ class Item(models.Model):
i = { i = {
'id': self.itemId, 'id': self.itemId,
'rendered': self.rendered, 'rendered': self.rendered,
'rightsLevel': self.level 'rightslevel': self.level
} }
i.update(self.external_data) i.update(self.external_data)
i.update(self.data) i.update(self.data)
@ -587,6 +587,7 @@ class Item(models.Model):
'popularity', 'popularity',
'published', 'published',
'resolution', 'resolution',
'rightslevel',
'saturation', 'saturation',
'size', 'size',
'volume', 'volume',
@ -647,6 +648,7 @@ class Item(models.Model):
s.itemId = self.itemId.replace('0x', 'xx') s.itemId = self.itemId.replace('0x', 'xx')
s.modified = self.modified s.modified = self.modified
s.published = self.published s.published = self.published
s.rightslevel = self.level
s.aspectratio = self.get('aspectRatio') s.aspectratio = self.get('aspectRatio')
s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')]) s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')])

View file

@ -396,7 +396,7 @@ def get(request):
if data['keys'] and 'files' in data['keys']: if data['keys'] and 'files' in data['keys']:
info['files'] = item.get_files(request.user) info['files'] = item.get_files(request.user)
if not data['keys'] or 'notes' in data['keys'] \ 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 info['notes'] = item.notes
response['data'] = info response['data'] = info
else: else:
@ -442,12 +442,12 @@ def edit(request):
if item.editable(request.user): if item.editable(request.user):
response = json_response(status=200, text='ok') response = json_response(status=200, text='ok')
if 'notes' in data: if 'notes' in data:
if request.user.get_profile().capability('canSeeNotes'): if request.user.get_profile().capability('canEditMetadata'):
item.notes = data['notes'] item.notes = data['notes']
del data['notes'] del data['notes']
if 'rightsLevel' in data: if 'rightslevel' in data:
item.level = data['rightsLevel'] item.level = data['rightslevel']
del data['rightsLevel'] del data['rightslevel']
r = item.edit(data) r = item.edit(data)
if r: if r:
r.wait() r.wait()

View file

@ -132,13 +132,13 @@ pandora.ui.clipList = function(videoRatio) {
width = fixedRatio > 1 ? size : Math.round(size * fixedRatio); width = fixedRatio > 1 ? size : Math.round(size * fixedRatio);
height = fixedRatio > 1 ? Math.round(size / fixedRatio) : size; 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')], var points = [that.value(id, 'in'), that.value(id, 'out')],
partsAndPoints = pandora.getVideoPartsAndPoints( partsAndPoints = pandora.getVideoPartsAndPoints(
result.data.durations, points result.data.durations, points
), ),
$player = Ox.VideoPlayer({ $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]}] ? [{'in': partsAndPoints.points[0], out: partsAndPoints.points[1]}]
: [], : [],
height: height, height: height,

View file

@ -416,9 +416,9 @@ pandora.ui.infoView = function(data) {
.appendTo($text); .appendTo($text);
}); });
$('<div>').css({height: '8px'}).appendTo($text); $('<div>').css({height: '16px'}).appendTo($text);
//pandora.createLinks($text); // Hue, Saturation, Lightness, Volume --------------------------------------
['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) { ['hue', 'saturation', 'lightness', 'volume'].forEach(function(key) {
$('<div>') $('<div>')
@ -428,6 +428,8 @@ pandora.ui.infoView = function(data) {
.appendTo($statistics); .appendTo($statistics);
}); });
// Rights Level ------------------------------------------------------------
var $rightsLevel = $('<div>'); var $rightsLevel = $('<div>');
$('<div>') $('<div>')
.css({marginBottom: '4px'}) .css({marginBottom: '4px'})
@ -436,6 +438,43 @@ pandora.ui.infoView = function(data) {
.appendTo($statistics); .appendTo($statistics);
renderRightsLevel(); renderRightsLevel();
// Notes -------------------------------------------------------------------
if (canEdit) {
Ox.print('DATA', data)
$('<div>')
.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);
}
$('<div>').css({height: '16px'}).appendTo($statistics);
if (canEdit) { if (canEdit) {
$icon.bindEvent({ $icon.bindEvent({
doubleclick: function() { doubleclick: function() {
@ -587,21 +626,23 @@ pandora.ui.infoView = function(data) {
marginBottom: '4px' marginBottom: '4px'
}) })
.appendTo($capabilities); .appendTo($capabilities);
Ox.Label({ if (canEdit) {
textAlign: 'center', Ox.Label({
title: canEdit ? Ox.toTitleCase(userLevel) : pandora.site.rightsLevels[data.rightsLevel].name, textAlign: 'center',
width: canEdit ? 48 : 68 title: Ox.toTitleCase(userLevel),
}) width: 48
.css(Ox.extend( })
{ .css(Ox.extend(
float: 'left', {
paddingTop: '2px', float: 'left',
height: '12px', paddingTop: '2px',
fontSize: '8px' height: '12px',
}, fontSize: '8px'
canEdit ? getUserLevelCSS(userLevel) : getRightsLevelCSS(data.rightsLevel) },
)) getUserLevelCSS(userLevel)
.appendTo($line); ))
.appendTo($line);
}
capabilities.forEach(function(capability) { capabilities.forEach(function(capability) {
var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel; var hasCapability = pandora.site.capabilities[capability.name][userLevel] >= rightsLevel;
Ox.Button({ Ox.Button({
@ -613,11 +654,24 @@ pandora.ui.infoView = function(data) {
title: capability.symbol, title: capability.symbol,
type: 'image' type: 'image'
}) })
.css(Ox.extend({ .css(getCapabilityCSS(hasCapability))
marginLeft: '4px' .css('margin' + (canEdit ? 'Left' : 'Right'), '4px')
}, getCapabilityCSS(hasCapability)))
.appendTo($line); .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() { function renderRightsLevel() {
var $capabilites, $rightsLevelSelect, var $capabilites, $rightsLevelLabel, $rightsLevelSelect,
rightsLevelCSS = getRightsLevelCSS(data.rightsLevel); rightsLevelCSS = getRightsLevelCSS(data.rightslevel);
$rightsLevel.empty(); $rightsLevel.empty();
if (canEdit) { if (canEdit) {
$rightsLevelSelect = Ox.Select({ $rightsLevelSelect = Ox.Select({
items: pandora.site.rightsLevels.map(function(rightsLevel, i) { 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 width: 128
}) })
@ -742,15 +796,24 @@ pandora.ui.infoView = function(data) {
var rightsLevel = event.selected[0].id; var rightsLevel = event.selected[0].id;
$rightsLevelSelect.css(getRightsLevelCSS(rightsLevel)); $rightsLevelSelect.css(getRightsLevelCSS(rightsLevel));
renderCapabilities(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); .appendTo($rightsLevel);
} else {
$rightsLevelLabel = Ox.Label({
title: pandora.site.rightsLevels[data.rightslevel].name,
width: 128
})
.css(Ox.extend({
marginBottom: '4px'
}, rightsLevelCSS))
.appendTo($rightsLevel);
} }
$capabilities = $('<div>').appendTo($rightsLevel); $capabilities = $('<div>').appendTo($rightsLevel);
renderCapabilities(data.rightsLevel); renderCapabilities(data.rightslevel);
} }
function toggleIconSize() { function toggleIconSize() {

View file

@ -7,7 +7,7 @@ pandora.ui.item = function() {
pandora.api.get({ pandora.api.get({
id: pandora.user.ui.item, id: pandora.user.ui.item,
keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1 ? 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) { }, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
if (result.status.code == 200) { if (result.status.code == 200) {
@ -34,8 +34,8 @@ pandora.ui.item = function() {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value}; return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}) })
: [], : [],
canPlayClips = pandora.site.capabilities.canPlayClips[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, canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= result.data.rightslevel,
censored = canPlayVideo ? [] censored = canPlayVideo ? []
: canPlayClips ? ( : canPlayClips ? (
subtitles.length subtitles.length

View file

@ -75,12 +75,12 @@ pandora.ui.itemClips = function(options) {
$img = $item.find('.OxIcon > img'); $img = $item.find('.OxIcon > img');
points = [$item.data('in'), $item.data('out')]; points = [$item.data('in'), $item.data('out')];
if ($img.length) { 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( var partsAndPoints = pandora.getVideoPartsAndPoints(
result.data.durations, points result.data.durations, points
), ),
$player = Ox.VideoPlayer({ $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]}] ? [{'in': partsAndPoints.points[0], out: partsAndPoints.points[1]}]
: [], : [],
enableMouse: true, enableMouse: true,