upload files for an item

This commit is contained in:
j 2013-03-01 09:14:57 +00:00
parent a36da2fcbb
commit f01534b36c
5 changed files with 41 additions and 18 deletions

View file

@ -87,7 +87,6 @@ def update_files(user, volume, files):
@task(queue="encoding") @task(queue="encoding")
def process_stream(fileId): def process_stream(fileId):
file = models.File.objects.get(id=fileId) file = models.File.objects.get(id=fileId)
streams = file.streams.filter(source=None) streams = file.streams.filter(source=None)
if streams.count() > 0: if streams.count() > 0:
stream = streams[0] stream = streams[0]

View file

@ -195,6 +195,9 @@ def addFile(request):
response['status']['text'] = 'file exists' response['status']['text'] = 'file exists'
response['data']['item'] = f.item.itemId response['data']['item'] = f.item.itemId
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.itemId) response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.itemId)
else:
if 'item' in data:
i = Item.objects.get(itemId=data['item'])
else: else:
title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title'] title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title']
i = Item() i = Item()
@ -327,7 +330,7 @@ def moveFiles(request):
f.save() f.save()
for itemId in changed: for itemId in changed:
c = Item.objects.get(itemId=itemId) c = Item.objects.get(itemId=itemId)
if c.files.count() == 0: if c.files.count() == 0 and settings.CONFIG['itemRequiresVideo']:
c.delete() c.delete()
else: else:
c.rendered = False c.rendered = False

View file

@ -1089,6 +1089,8 @@ class Item(models.Model):
if offset: if offset:
self.data['volume'] /= offset self.data['volume'] /= offset
#extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8]) #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.select_frame()
self.make_poster(True) self.make_poster(True)
self.make_icon() self.make_icon()
@ -1219,11 +1221,12 @@ class Item(models.Model):
self.poster_frame = frames[self.poster_frame]['position'] self.poster_frame = frames[self.poster_frame]['position']
def get_poster_frame_path(self): def get_poster_frame_path(self):
frames = []
path = None path = None
frames = self.poster_frames()
if frames and self.poster_frame < 0:
self.select_frame()
if self.poster_frame >= 0: if self.poster_frame >= 0:
if settings.CONFIG['media']['importFrames']: if settings.CONFIG['media']['importFrames']:
frames = self.poster_frames()
if frames and len(frames) > int(self.poster_frame): if frames and len(frames) > int(self.poster_frame):
path = frames[int(self.poster_frame)]['path'] path = frames[int(self.poster_frame)]['path']
elif frames: elif frames:
@ -1231,6 +1234,7 @@ class Item(models.Model):
else: else:
size = settings.CONFIG['video']['resolutions'][0] size = settings.CONFIG['video']['resolutions'][0]
path = self.frame(self.poster_frame, size) path = self.frame(self.poster_frame, size)
return path return path
def make_icon(self): def make_icon(self):

View file

@ -568,6 +568,9 @@ pandora.ui.filesView = function(options, self) {
]('ignore'); ]('ignore');
} }
that.reload = function() {
self.$filesList.reloadList();
}
return that; return that;
}; };

View file

@ -65,7 +65,16 @@ pandora.ui.uploadDialog = function(data) {
// FIXME: is this necessary? // FIXME: is this necessary?
pandora._status = $status; pandora._status = $status;
pandora._info = $info; 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 = $('<input>') selectFile = $('<input>')
.attr({ .attr({
@ -148,7 +157,8 @@ pandora.ui.uploadDialog = function(data) {
pandora.api.addFile({ pandora.api.addFile({
filename: filename, filename: filename,
id: oshash, id: oshash,
info: info info: info,
item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item
}, function(result) { }, function(result) {
item = result.data.item; item = result.data.item;
pandora.firefogg.encode( pandora.firefogg.encode(
@ -170,10 +180,14 @@ pandora.ui.uploadDialog = function(data) {
}, },
done: function(data) { done: function(data) {
Ox.Request.clearCache(); Ox.Request.clearCache();
if (pandora.user.ui.item == item && pandora.user.ui.itemView == 'files') {
pandora.$ui.item.reload();
} else {
pandora.UI.set({ pandora.UI.set({
item: item, item: item,
itemView: 'files' itemView: 'files'
}); });
}
delete pandora.firefogg; delete pandora.firefogg;
that.close(); that.close();
} }