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")
|
@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]
|
||||||
|
|
|
@ -196,14 +196,17 @@ def addFile(request):
|
||||||
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:
|
else:
|
||||||
title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title']
|
if 'item' in data:
|
||||||
i = Item()
|
i = Item.objects.get(itemId=data['item'])
|
||||||
i.data = {
|
else:
|
||||||
'title': title,
|
title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title']
|
||||||
'director': data.get('director', []),
|
i = Item()
|
||||||
}
|
i.data = {
|
||||||
i.user = request.user
|
'title': title,
|
||||||
i.save()
|
'director': data.get('director', []),
|
||||||
|
}
|
||||||
|
i.user = request.user
|
||||||
|
i.save()
|
||||||
f = models.File(oshash=oshash, item=i)
|
f = models.File(oshash=oshash, item=i)
|
||||||
f.path = data.get('filename', 'Untitled')
|
f.path = data.get('filename', 'Untitled')
|
||||||
extension = f.path.split('.')
|
extension = f.path.split('.')
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -568,6 +568,9 @@ pandora.ui.filesView = function(options, self) {
|
||||||
]('ignore');
|
]('ignore');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
that.reload = function() {
|
||||||
|
self.$filesList.reloadList();
|
||||||
|
}
|
||||||
return that;
|
return that;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -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();
|
||||||
pandora.UI.set({
|
if (pandora.user.ui.item == item && pandora.user.ui.itemView == 'files') {
|
||||||
item: item,
|
pandora.$ui.item.reload();
|
||||||
itemView: 'files'
|
} else {
|
||||||
});
|
pandora.UI.set({
|
||||||
|
item: item,
|
||||||
|
itemView: 'files'
|
||||||
|
});
|
||||||
|
}
|
||||||
delete pandora.firefogg;
|
delete pandora.firefogg;
|
||||||
that.close();
|
that.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue