diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 470af358..0326e37d 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -378,6 +378,8 @@ class Annotation(models.Model): streams = self.item.streams() if streams: j['videoRatio'] = streams[0].aspect_ratio + if 'clip' in keys: + j[key] = self.clip.public_id for key in keys: if key not in j: if key in self._clip_keys: diff --git a/pandora/clip/views.py b/pandora/clip/views.py index 700a95a1..7c2fcd23 100644 --- a/pandora/clip/views.py +++ b/pandora/clip/views.py @@ -78,7 +78,7 @@ def findClips(request, data): takes { query: object, // find clips, query object, see `find` itemsQuery: object, // limit to matching items, query object, see `find` - keys: [string], // list of properties to return + keys: [string], // list of properties to return, include 'annotations' to get all annotations for a clip positions: [int], // list of positions range: [int, int], // range of results to return sort: [object] // list of sort objects, see `find` diff --git a/static/js/infoView.indiancinema.js b/static/js/infoView.indiancinema.js index 9776dd42..277c706d 100644 --- a/static/js/infoView.indiancinema.js +++ b/static/js/infoView.indiancinema.js @@ -621,19 +621,6 @@ pandora.ui.infoView = function(data, isMixed) { $('
').css({height: '16px'}).appendTo($statistics); - function cleanupDate(value) { - if (/\d{2}-\d{2}-\d{4}/.test(value)) { - value = Ox.reverse(value.split('-')).join('-') - } - if (/\d{4}i\/\d{2}\/\d{d}/.test(value)) { - value = value.split('/').join('-') - } - if (/\d{2}\/\d{2}\/\d{4}/.test(value)) { - value = Ox.reverse(value.split('/')).join('-') - } - return value - } - function editMetadata(key, value) { if (value != data[key]) { var itemKey = Ox.getObjectById(pandora.site.itemKeys, key); @@ -661,7 +648,7 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value; } if (itemKey && itemKey.type && itemKey.type[0] == 'date') { - edit[key] = edit[key].map(cleanupDate); + edit[key] = edit[key].map(pandora.cleanupDate); } pandora.api.edit(edit, function(result) { if (!isMultiple) { @@ -763,14 +750,14 @@ pandora.ui.infoView = function(data, isMixed) { specialListKeys.indexOf(key) > -1 && itemKey && itemKey.type[0] == 'date' ) { ret = value.split('; ').map(function(date) { - date = cleanupDate(date) + date = pandora.cleanupDate(date) return date ? formatLink(Ox.formatDate(date, ['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length], true ), key, date) : ''; }).join('; '); } else if (['releasedate'].indexOf(key) > -1) { - value = cleanupDate(value); + value = pandora.cleanupDate(value); ret = value ? Ox.formatDate(value, ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length], true diff --git a/static/js/infoView.js b/static/js/infoView.js index 9c18ff69..abdc4180 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -38,6 +38,15 @@ pandora.ui.infoView = function(data, isMixed) { }) ), posterKeys = nameKeys.concat(['title', 'year']), + displayedKeys = [ // FIXME: can tis be a flag in the config? + 'title', 'notes', 'name', 'summary', 'id', + 'hue', 'saturation', 'lightness', 'cutsperminute', 'volume', + 'user', 'rightslevel', 'bitrate', 'timesaccessed', + 'numberoffiles', 'numberofannotations', 'numberofcuts', 'words', 'wordsperminute', + 'duration', 'aspectratio', 'pixels', 'size', 'resolution', + 'created', 'modified', 'accessed', + 'random' + ], statisticsWidth = 128, $bar = Ox.Bar({size: 16}) @@ -236,14 +245,18 @@ pandora.ui.infoView = function(data, isMixed) { ) .appendTo($text); - // Director, Year and Country ---------------------------------------------- + // Director, Year and Country, Language -------------------------------- - renderGroup(['director', 'year', 'country']); + renderGroup(['director', 'year', 'country', 'language']); // Featuring ---------------------------------------------- renderGroup(['featuring']); + // Render any remaing keys defined in config + + renderRemainingKeys(); + // Summary ----------------------------------------------------------------- if (canEdit || data.summary) { @@ -278,6 +291,7 @@ pandora.ui.infoView = function(data, isMixed) { .appendTo($text); } + // Duration, Aspect Ratio -------------------------------------------------- if (!isMultiple) { ['duration', 'aspectratio'].forEach(function(key) { @@ -371,19 +385,6 @@ pandora.ui.infoView = function(data, isMixed) { $('
').css({height: '16px'}).appendTo($statistics); - function cleanupDate(value) { - if (/\d{2}-\d{2}-\d{4}/.test(value)) { - value = Ox.reverse(value.split('-')).join('-') - } - if (/\d{4}i\/\d{2}\/\d{d}/.test(value)) { - value = value.split('/').join('-') - } - if (/\d{2}\/\d{2}\/\d{4}/.test(value)) { - value = Ox.reverse(value.split('/')).join('-') - } - return value - } - function editMetadata(key, value) { if (value != data[key]) { var itemKey = Ox.getObjectById(pandora.site.itemKeys, key); @@ -400,7 +401,7 @@ pandora.ui.infoView = function(data, isMixed) { edit[key] = value ? value : null; } if (itemKey && itemKey.type && itemKey.type[0] == 'date') { - edit[key] = edit[key].map(cleanupDate); + edit[key] = edit[key].map(pandora.cleanupDate); } pandora.api.edit(edit, function(result) { if (!isMultiple) { @@ -474,7 +475,7 @@ pandora.ui.infoView = function(data, isMixed) { listKeys.indexOf(key) > -1 && Ox.getObjectById(pandora.site.itemKeys, key).type[0] == 'date' ) { ret = value.split('; ').map(function(date) { - date = cleanupDate(date) + date = pandora.cleanupDate(date) return date ? formatLink(Ox.formatDate(date, ['', '%Y', '%B %Y', '%B %e, %Y'][date.split('-').length], true @@ -588,6 +589,7 @@ pandora.ui.infoView = function(data, isMixed) { function renderGroup(keys) { var $element; + keys.forEach(function(key) { displayedKeys.push(key) }); if (canEdit || keys.filter(function(key) { return data[key]; }).length) { @@ -619,6 +621,17 @@ pandora.ui.infoView = function(data, isMixed) { } } + function renderRemainingKeys() { + var keys = pandora.site.itemKeys.filter(function(item) { + return item.id != '*' && item.type != 'layer' && !Ox.contains(displayedKeys, item.id); + }).map(function(item) { + return item.id; + }); + if (keys.length) { + renderGroup(keys) + } + } + function renderRightsLevel() { var $rightsLevelElement = getRightsLevelElement(data.rightslevel), $rightsLevelSelect; diff --git a/static/js/infoViewUtils.js b/static/js/infoViewUtils.js new file mode 100644 index 00000000..9ab90665 --- /dev/null +++ b/static/js/infoViewUtils.js @@ -0,0 +1,16 @@ +'use strict'; + + +pandora.cleanupDate = function(value) { + if (/\d{2}-\d{2}-\d{4}/.test(value)) { + value = Ox.reverse(value.split('-')).join('-') + } + if (/\d{4}i\/\d{2}\/\d{d}/.test(value)) { + value = value.split('/').join('-') + } + if (/\d{2}\/\d{2}\/\d{4}/.test(value)) { + value = Ox.reverse(value.split('/')).join('-') + } + return value +}; + diff --git a/static/js/item.js b/static/js/item.js index 91c9b8f4..c5045d1f 100644 --- a/static/js/item.js +++ b/static/js/item.js @@ -41,11 +41,28 @@ pandora.ui.item = function() { pandora.user.ui.itemView.slice(0, 1) ) > -1 ? 'an': 'a') + ' ' +'{1} view.', [result.data.title, Ox._(pandora.user.ui.itemView)]); - pandora.$ui.contentPanel.replaceElement(1, - Ox.Element() - .css({marginTop: '32px', fontSize: '12px', textAlign: 'center'}) - .html(html) - ); + + var note = Ox.Element() + .css({marginTop: '32px', fontSize: '12px', textAlign: 'center'}) + pandora.$ui.contentPanel.replaceElement(1, note); + if (pandora.user.username == item.user || pandora.hasCapability('canSeeAllTasks')) { + pandora.api.getTasks({ + user: pandora.hasCapability('canSeeAllTasks') ? '' : pandora.user.username + }, function(result_) { + var tasks = result_.data.items.filter(function(task) { return task.item == item}) + if (tasks.length == 0) { + html = Ox._( + '{0} is currently processed. ' + + '{1} view will be available in a moment.', + [result.data.title, Ox._(pandora.user.ui.itemView)] + ) + } + note.html(html) + }) + } else { + note.html(html) + } + pandora.site.itemViews.filter(function(view) { return view.id == 'documents'; }).length && pandora.api.get({ diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index b797b4bd..87bfbc52 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -229,8 +229,10 @@ pandora.ui.mainMenu = function() { { id: 'names', title: Ox._('Manage Names...'), disabled: !pandora.hasCapability('canManageTitlesAndNames') }, { id: 'translations', title: Ox._('Manage Translations...'), disabled: !pandora.hasCapability('canManageTranslations') }, {}, - { id: 'places', title: Ox._('Manage Places...'), disabled: !pandora.hasCapability('canManagePlacesAndEvents') }, - { id: 'events', title: Ox._('Manage Events...'), disabled: !pandora.hasCapability('canManagePlacesAndEvents') }, + pandora.hasView('map') + ? [{ id: 'places', title: Ox._('Manage Places...'), disabled: !pandora.hasCapability('canManagePlacesAndEvents') }] : [], + pandora.hasView('calendar') + ? [{ id: 'events', title: Ox._('Manage Events...'), disabled: !pandora.hasCapability('canManagePlacesAndEvents') }] : [], {}, { id: 'users', title: Ox._('Manage Users...'), disabled: !pandora.hasCapability('canManageUsers') }, { id: 'statistics', title: Ox._('Statistics...'), disabled: !pandora.hasCapability('canManageUsers') }, diff --git a/static/js/utils.js b/static/js/utils.js index 32c40c08..ae2758cc 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -2489,6 +2489,9 @@ pandora.hasPlacesLayer = function() { }); }; +pandora.hasView = function(id) { + return !!(Ox.getObjectById(pandora.site.itemViews, id) || Ox.getObjectById(pandora.site.listViews, id)) +}; pandora.isClipView = function(view, item) { if (pandora.user.ui.section == 'items') {