upload files for an item
This commit is contained in:
parent
a36da2fcbb
commit
f01534b36c
5 changed files with 41 additions and 18 deletions
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -568,6 +568,9 @@ pandora.ui.filesView = function(options, self) {
|
|||
]('ignore');
|
||||
}
|
||||
|
||||
that.reload = function() {
|
||||
self.$filesList.reloadList();
|
||||
}
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
|
@ -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 = $('<input>')
|
||||
.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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue