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},
"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",

View file

@ -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

View file

@ -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='')])

View file

@ -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()

View file

@ -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,

View file

@ -416,9 +416,9 @@ pandora.ui.infoView = function(data) {
.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) {
$('<div>')
@ -428,6 +428,8 @@ pandora.ui.infoView = function(data) {
.appendTo($statistics);
});
// Rights Level ------------------------------------------------------------
var $rightsLevel = $('<div>');
$('<div>')
.css({marginBottom: '4px'})
@ -436,6 +438,43 @@ pandora.ui.infoView = function(data) {
.appendTo($statistics);
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) {
$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 = $('<div>').appendTo($rightsLevel);
renderCapabilities(data.rightsLevel);
renderCapabilities(data.rightslevel);
}
function toggleIconSize() {

View file

@ -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

View file

@ -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,