use placeholders for missing item pages, remove item from getItem result
This commit is contained in:
parent
1a2d34caab
commit
5ca80fd7ee
4 changed files with 46 additions and 37 deletions
|
@ -312,7 +312,7 @@ def getItem(request):
|
|||
info = item.get_json()
|
||||
info['stream'] = item.get_stream()
|
||||
info['layers'] = item.get_layers(request.user)
|
||||
response['data']['item'] = info
|
||||
response['data'] = info
|
||||
else:
|
||||
response = json_response(status=403, text='permission denied')
|
||||
return render_to_json_response(response)
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.utils import simplejson as json
|
|||
from django.conf import settings
|
||||
from django.core.mail import send_mail, BadHeaderError
|
||||
|
||||
from ox.django.shortcuts import render_to_json_response, json_response
|
||||
from ox.django.shortcuts import render_to_json_response, json_response, get_object_or_404_json
|
||||
from ox.django.decorators import login_required_json
|
||||
import ox
|
||||
|
||||
|
@ -451,7 +451,7 @@ def setUI(request):
|
|||
profile.save()
|
||||
|
||||
if data.get('item', False):
|
||||
item = Item.objects.get(itemId=data['item'])
|
||||
item = get_object_or_404_json(Item, itemId=data['item'])
|
||||
if request.user.is_authenticated():
|
||||
access, created = Access.objects.get_or_create(item=item, user=request.user)
|
||||
else:
|
||||
|
|
|
@ -16,7 +16,7 @@ pandora.ui.info = function() {
|
|||
position: 'absolute',
|
||||
left: 0,
|
||||
bottom: 0,
|
||||
height: '16px',
|
||||
height: '16px'
|
||||
})
|
||||
)
|
||||
.bindEvent({
|
||||
|
@ -27,7 +27,7 @@ pandora.ui.info = function() {
|
|||
});
|
||||
if(app.user.ui.item) {
|
||||
pandora.api.getItem(app.user.ui.item, function(result) {
|
||||
app.ui.infoRatio = result.data.item.stream.aspectRatio;
|
||||
app.ui.infoRatio = result.data.stream.aspectRatio;
|
||||
var width = that.width() || 256,
|
||||
height = width / app.ui.infoRatio + 16;
|
||||
app.$ui.infoStill.removeElement();
|
||||
|
@ -43,7 +43,7 @@ pandora.ui.info = function() {
|
|||
!app.user.ui.showInfo && app.$ui.leftPanel.css({bottom: -height});
|
||||
app.$ui.leftPanel.size(2, height );
|
||||
});
|
||||
app.$ui.infoTimeline.attr('src', '/'+app.user.ui.item+'/timeline.16.png')
|
||||
app.$ui.infoTimeline.attr('src', '/'+app.user.ui.item+'/timeline.16.png');
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
// vim: et:ts=4:sw=4:sts=4:ft=js
|
||||
pandora.ui.item = function() {
|
||||
var that;
|
||||
if (app.user.ui.itemView == 'info' || app.user.ui.itemView == 'files') {
|
||||
that = new Ox.Element();
|
||||
} else if (app.user.ui.itemView == 'player') {
|
||||
that = new Ox.Element();
|
||||
} else if (app.user.ui.itemView == 'timeline') {
|
||||
that = new Ox.Element();
|
||||
}
|
||||
var that = new Ox.Element();
|
||||
pandora.api.getItem(app.user.ui.item, function(result) {
|
||||
if (app.user.ui.itemView == 'info') {
|
||||
//Ox.print('result.data.item', result.data.item)
|
||||
if (result.status.code != 200) {
|
||||
app.$ui.contentPanel.replaceElement(1,
|
||||
Ox.Element().html(
|
||||
'The '+app.config.itemName.singular+' you are looking for does not exist.'));
|
||||
} else if (app.user.ui.itemView == 'calendar') {
|
||||
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
|
||||
} else if (app.user.ui.itemView == 'clips') {
|
||||
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Clips'));
|
||||
} else if (app.user.ui.itemView == 'info') {
|
||||
//Ox.print('result.data', result.data)
|
||||
if (app.user.level == 'admin') {
|
||||
var $form,
|
||||
$edit = new Ox.Element()
|
||||
|
@ -20,7 +21,7 @@ pandora.ui.item = function() {
|
|||
id: key.id,
|
||||
label: key.title,
|
||||
labelWidth: 100,
|
||||
value: result.data.item[key.id],
|
||||
value: result.data[key.id],
|
||||
type: 'text',
|
||||
width: 500
|
||||
});
|
||||
|
@ -37,11 +38,12 @@ pandora.ui.item = function() {
|
|||
var values = $form.value();
|
||||
var changed = {};
|
||||
Ox.map(app.config.itemKeys, function(key, i) {
|
||||
if(values[i] && values[i] != ''+result.data.item[key.id]) {
|
||||
if(Ox.isArray(key.type) && key.type[0] == 'string')
|
||||
if(values[i] && values[i] != ''+result.data[key.id]) {
|
||||
if(Ox.isArray(key.type) && key.type[0] == 'string') {
|
||||
changed[key.id] = values[i].split(', ');
|
||||
else
|
||||
} else {
|
||||
changed[key.id] = values[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
if(changed) {
|
||||
|
@ -58,16 +60,17 @@ pandora.ui.item = function() {
|
|||
//Ox.print(template);
|
||||
app.$ui.contentPanel.replaceElement(1,
|
||||
app.$ui.item = new Ox.Element()
|
||||
.append($.tmpl(template, result.data.item))
|
||||
.append($.tmpl(template, result.data))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (app.user.ui.itemView == 'map') {
|
||||
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Map'));
|
||||
} else if (app.user.ui.itemView == 'player') {
|
||||
var video = result.data.item.stream,
|
||||
subtitles = result.data.item.layers.subtitles,
|
||||
var video = result.data.stream,
|
||||
format = $.support.video.supportedFormat(video.formats);
|
||||
video.height = video.profiles[0]
|
||||
video.height = video.profiles[0];
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
||||
app.$ui.contentPanel.replaceElement(1, app.$ui.player = new Ox.VideoPanelPlayer({
|
||||
|
@ -77,7 +80,9 @@ pandora.ui.item = function() {
|
|||
position: app.user.ui.videoPosition[app.user.ui.item] || 0,
|
||||
showAnnotations: app.user.ui.showAnnotations,
|
||||
showControls: app.user.ui.showControls,
|
||||
subtitles: subtitles,
|
||||
subtitles: result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}),
|
||||
videoHeight: video.height,
|
||||
videoId: app.user.ui.item,
|
||||
videoWidth: video.width,
|
||||
|
@ -99,17 +104,21 @@ pandora.ui.item = function() {
|
|||
});
|
||||
}
|
||||
}));
|
||||
} else if (app.user.ui.itemView == 'statistics') {
|
||||
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Statistics'));
|
||||
} else if (app.user.ui.itemView == 'timeline') {
|
||||
var layers = [],
|
||||
video = result.data.item.stream,
|
||||
cuts = result.data.item.cuts || {},
|
||||
format = $.support.video.supportedFormat(video.formats);
|
||||
subtitles = result.data.item.layers.subtitles;
|
||||
video = result.data.stream,
|
||||
cuts = result.data.cuts || {},
|
||||
format = $.support.video.supportedFormat(video.formats),
|
||||
streams = {};
|
||||
video.height = video.profiles[0];
|
||||
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
|
||||
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
|
||||
video.profiles.forEach(function(profile) {
|
||||
streams[profile] = video.baseUrl + '/' + profile + 'p.' + format;
|
||||
});
|
||||
$.each(app.config.layers, function(i, layer) {
|
||||
layers[i] = $.extend({}, layer, {items: result.data.item.layers[layer.id]});
|
||||
layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]});
|
||||
});
|
||||
app.$ui.contentPanel.replaceElement(1, app.$ui.editor = new Ox.VideoEditor({
|
||||
annotationsSize: app.user.ui.annotationsSize,
|
||||
|
@ -117,7 +126,7 @@ pandora.ui.item = function() {
|
|||
duration: video.duration,
|
||||
find: '',
|
||||
getFrameURL: function(position) {
|
||||
return '/' + app.user.ui.item + '/frame/' + video.width.toString() + '/' + position.toString() + '.jpg'
|
||||
return '/' + app.user.ui.item + '/frame/' + video.width.toString() + '/' + position.toString() + '.jpg';
|
||||
},
|
||||
getLargeTimelineImageURL: function(i) {
|
||||
return '/' + app.user.ui.item + '/timelines/timeline.64.' + i + '.png';
|
||||
|
@ -135,14 +144,14 @@ pandora.ui.item = function() {
|
|||
showAnnotations: app.user.ui.showAnnotations,
|
||||
showLargeTimeline: true,
|
||||
// fixme: layers have value, subtitles has text?
|
||||
subtitles: subtitles.map(function(subtitle) {
|
||||
subtitles: result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}),
|
||||
videoHeight: video.height,
|
||||
videoId: app.user.ui.item,
|
||||
videoWidth: video.width,
|
||||
videoSize: app.user.ui.videoSize,
|
||||
video: video.url,
|
||||
video: streams,
|
||||
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
|
||||
}).bindEvent({
|
||||
resize: function(event, data) {
|
||||
|
@ -190,12 +199,12 @@ pandora.ui.item = function() {
|
|||
} else if (app.user.ui.itemView == 'files') {
|
||||
app.$ui.contentPanel.replaceElement(1,
|
||||
app.$ui.item = new Ox.FilesView({
|
||||
id: result.data.item.id
|
||||
id: result.data.id
|
||||
})
|
||||
);
|
||||
}
|
||||
var director = result.data.item.director?' ('+result.data.item.director.join(', ')+')':'';
|
||||
app.$ui.total.html(result.data.item.title + director);
|
||||
var director = result.data.director?' ('+result.data.director.join(', ')+')':'';
|
||||
app.$ui.total.html(result.data.title + director);
|
||||
});
|
||||
return that;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue