addFile
This commit is contained in:
parent
7a8756161e
commit
30313e35ce
4 changed files with 49 additions and 10 deletions
|
@ -38,7 +38,8 @@
|
||||||
"canSeeFiles": {"staff": true, "admin": true},
|
"canSeeFiles": {"staff": true, "admin": true},
|
||||||
"canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4},
|
"canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4},
|
||||||
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true},
|
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true},
|
||||||
"canSendMail": {"staff": true, "admin": true}
|
"canSendMail": {"staff": true, "admin": true},
|
||||||
|
"canUploadVideo": {"guest": false, "member": false, "staff": true, "admin": true}
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
clipKeys are the properties that clips can by sorted by.
|
clipKeys are the properties that clips can by sorted by.
|
||||||
|
|
|
@ -84,15 +84,15 @@ def update(request):
|
||||||
if 'info' in data:
|
if 'info' in data:
|
||||||
for oshash in data['info']:
|
for oshash in data['info']:
|
||||||
info = data['info'][oshash]
|
info = data['info'][oshash]
|
||||||
instance = models.Instance.objects.filter(file__oshash=oshash, volume__user=user)
|
f = models.File.objects(oshash=oshash)
|
||||||
if instance.count()>0:
|
if f.count()>0:
|
||||||
instance = instance[0]
|
f = f[0]
|
||||||
if not instance.file.info:
|
if not f.info:
|
||||||
for key in ('atime', 'mtime', 'ctime'):
|
for key in ('atime', 'mtime', 'ctime'):
|
||||||
if key in info:
|
if key in info:
|
||||||
del info[key]
|
del info[key]
|
||||||
instance.file.info = info
|
f.info = info
|
||||||
instance.file.save()
|
f.save()
|
||||||
if not upload_only:
|
if not upload_only:
|
||||||
files = models.Instance.objects.filter(volume__user=user, file__available=False)
|
files = models.Instance.objects.filter(volume__user=user, file__available=False)
|
||||||
if volume:
|
if volume:
|
||||||
|
@ -169,13 +169,49 @@ class VideoChunkForm(forms.Form):
|
||||||
chunkId = forms.IntegerField(required=False)
|
chunkId = forms.IntegerField(required=False)
|
||||||
done = forms.IntegerField(required=False)
|
done = forms.IntegerField(required=False)
|
||||||
|
|
||||||
|
@login_required_json
|
||||||
|
def addFile(request):
|
||||||
|
'''
|
||||||
|
id: oshash
|
||||||
|
title:
|
||||||
|
info: {}
|
||||||
|
return {
|
||||||
|
status: {'code': int, 'text': string},
|
||||||
|
data: {
|
||||||
|
item: id,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
response = json_response({})
|
||||||
|
data = json.loads(request.POST['data'])
|
||||||
|
oshash = data.pop('id')
|
||||||
|
if not request.user.get_profile().capability('canUploadVideo'):
|
||||||
|
response = json_response(status=403, text='permissino denied')
|
||||||
|
elif models.File.objects.filter(oshash=oshash).count() > 0:
|
||||||
|
response = json_response(status=200, text='file exists')
|
||||||
|
f = models.File.objects.get(oshash=oshash)
|
||||||
|
response['data']['item'] = f.item.itemId
|
||||||
|
else:
|
||||||
|
i = Item()
|
||||||
|
i.data = {
|
||||||
|
'title': data.get('title', ''),
|
||||||
|
'director': data.get('director', []),
|
||||||
|
}
|
||||||
|
i.user = request.user
|
||||||
|
i.save()
|
||||||
|
f = models.File(oshash=oshash, item=i)
|
||||||
|
f.info = data['info']
|
||||||
|
f.save()
|
||||||
|
response['data']['item'] = i.itemId
|
||||||
|
return render_to_json_response(response)
|
||||||
|
actions.register(addFile, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def firefogg_upload(request):
|
def firefogg_upload(request):
|
||||||
profile = request.GET['profile']
|
profile = request.GET['profile']
|
||||||
oshash = request.GET['id']
|
oshash = request.GET['id']
|
||||||
config = settings.CONFIG['video']
|
config = settings.CONFIG['video']
|
||||||
video_profile = "%sp.%s" % (config['resolutions'][0], config['formats'][0])
|
video_profile = "%sp.%s" % (max(config['resolutions']), config['formats'][0])
|
||||||
|
|
||||||
#handle video upload
|
#handle video upload
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
|
@ -74,8 +74,9 @@ def get_item(info, user=None, async=False):
|
||||||
item_data = {
|
item_data = {
|
||||||
'title': info.get('title', ''),
|
'title': info.get('title', ''),
|
||||||
'director': info.get('director', []),
|
'director': info.get('director', []),
|
||||||
'year': info.get('year', '')
|
|
||||||
}
|
}
|
||||||
|
if filter(lambda k: k['id'] == 'year', settings.CONFIG['itemKeys']):
|
||||||
|
item_data['year'] =info.get('year', '')
|
||||||
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
|
for key in ('episodeTitle', 'episodeDirector', 'episodeYear',
|
||||||
'season', 'episode', 'seriesTitle'):
|
'season', 'episode', 'seriesTitle'):
|
||||||
if key in info and info[key]:
|
if key in info and info[key]:
|
||||||
|
|
|
@ -36,7 +36,8 @@
|
||||||
"canSeeFiles": {"staff": true, "admin": true},
|
"canSeeFiles": {"staff": true, "admin": true},
|
||||||
"canSeeItem": {"guest": 1, "member": 1, "staff": 4, "admin": 4},
|
"canSeeItem": {"guest": 1, "member": 1, "staff": 4, "admin": 4},
|
||||||
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true},
|
"canSeeExtraItemViews": {"friend": true, "staff": true, "admin": true},
|
||||||
"canSendMail": {"staff": true, "admin": true}
|
"canSendMail": {"staff": true, "admin": true},
|
||||||
|
"canUploadVideo": {"guest": false, "member": true, "staff": true, "admin": true}
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
clipKeys are the properties that clips can by sorted by.
|
clipKeys are the properties that clips can by sorted by.
|
||||||
|
|
Loading…
Reference in a new issue