diff --git a/pandora/archive/tasks.py b/pandora/archive/tasks.py index 88e7d7cd6..4247e6cf1 100644 --- a/pandora/archive/tasks.py +++ b/pandora/archive/tasks.py @@ -87,7 +87,6 @@ def update_files(user, volume, files): @task(queue="encoding") def process_stream(fileId): file = models.File.objects.get(id=fileId) - streams = file.streams.filter(source=None) if streams.count() > 0: stream = streams[0] diff --git a/pandora/archive/views.py b/pandora/archive/views.py index d5d46f3b6..f23ee960d 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -196,14 +196,17 @@ def addFile(request): response['data']['item'] = f.item.itemId response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.itemId) else: - title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title'] - i = Item() - i.data = { - 'title': title, - 'director': data.get('director', []), - } - i.user = request.user - i.save() + if 'item' in data: + i = Item.objects.get(itemId=data['item']) + else: + title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title'] + i = Item() + i.data = { + 'title': title, + 'director': data.get('director', []), + } + i.user = request.user + i.save() f = models.File(oshash=oshash, item=i) f.path = data.get('filename', 'Untitled') extension = f.path.split('.') @@ -327,7 +330,7 @@ def moveFiles(request): f.save() for itemId in changed: c = Item.objects.get(itemId=itemId) - if c.files.count() == 0: + if c.files.count() == 0 and settings.CONFIG['itemRequiresVideo']: c.delete() else: c.rendered = False diff --git a/pandora/item/models.py b/pandora/item/models.py index 12cec41f6..bca5d0ed4 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1089,6 +1089,8 @@ class Item(models.Model): if offset: self.data['volume'] /= offset #extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8]) + self.json = self.get_json() + self.update_sort() self.select_frame() self.make_poster(True) self.make_icon() @@ -1219,11 +1221,12 @@ class Item(models.Model): self.poster_frame = frames[self.poster_frame]['position'] def get_poster_frame_path(self): - frames = [] path = None + frames = self.poster_frames() + if frames and self.poster_frame < 0: + self.select_frame() if self.poster_frame >= 0: if settings.CONFIG['media']['importFrames']: - frames = self.poster_frames() if frames and len(frames) > int(self.poster_frame): path = frames[int(self.poster_frame)]['path'] elif frames: @@ -1231,6 +1234,7 @@ class Item(models.Model): else: size = settings.CONFIG['video']['resolutions'][0] path = self.frame(self.poster_frame, size) + return path def make_icon(self): diff --git a/static/js/pandora/filesView.js b/static/js/pandora/filesView.js index 9a400c4f1..df0084116 100644 --- a/static/js/pandora/filesView.js +++ b/static/js/pandora/filesView.js @@ -568,6 +568,9 @@ pandora.ui.filesView = function(options, self) { ]('ignore'); } + that.reload = function() { + self.$filesList.reloadList(); + } return that; }; diff --git a/static/js/pandora/uploadDialog.js b/static/js/pandora/uploadDialog.js index faa5a3688..f4843e654 100644 --- a/static/js/pandora/uploadDialog.js +++ b/static/js/pandora/uploadDialog.js @@ -65,7 +65,16 @@ pandora.ui.uploadDialog = function(data) { // FIXME: is this necessary? pandora._status = $status; pandora._info = $info; - if (typeof Firefogg == 'undefined') { + if (!pandora.site.itemRequiresVideo && !pandora.user.ui.item) { + $info.html( + 'You can only upload a video to an existing ' + + pandora.site.itemName.singular.toLowerCase() + + '. Please check if an entry for the ' + + pandora.site.itemName.singular.toLowerCase() + + ' you want to upload exists and create otherwise.' + ); + $actionButton.hide(); + } else if (typeof Firefogg == 'undefined') { /* selectFile = $('') .attr({ @@ -148,7 +157,8 @@ pandora.ui.uploadDialog = function(data) { pandora.api.addFile({ filename: filename, id: oshash, - info: info + info: info, + item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item }, function(result) { item = result.data.item; pandora.firefogg.encode( @@ -170,10 +180,14 @@ pandora.ui.uploadDialog = function(data) { }, done: function(data) { Ox.Request.clearCache(); - pandora.UI.set({ - item: item, - itemView: 'files' - }); + if (pandora.user.ui.item == item && pandora.user.ui.itemView == 'files') { + pandora.$ui.item.reload(); + } else { + pandora.UI.set({ + item: item, + itemView: 'files' + }); + } delete pandora.firefogg; that.close(); }