diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index a1b8c9f6..df662574 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -38,7 +38,8 @@ "canSeeFiles": {"staff": true, "admin": true}, "canSeeItem": {"guest": 3, "member": 3, "friend": 4, "staff": 4, "admin": 4}, "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. diff --git a/pandora/archive/views.py b/pandora/archive/views.py index bebc6685..27c34172 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -84,15 +84,15 @@ def update(request): if 'info' in data: for oshash in data['info']: info = data['info'][oshash] - instance = models.Instance.objects.filter(file__oshash=oshash, volume__user=user) - if instance.count()>0: - instance = instance[0] - if not instance.file.info: + f = models.File.objects(oshash=oshash) + if f.count()>0: + f = f[0] + if not f.info: for key in ('atime', 'mtime', 'ctime'): if key in info: del info[key] - instance.file.info = info - instance.file.save() + f.info = info + f.save() if not upload_only: files = models.Instance.objects.filter(volume__user=user, file__available=False) if volume: @@ -169,13 +169,49 @@ class VideoChunkForm(forms.Form): chunkId = 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 def firefogg_upload(request): profile = request.GET['profile'] oshash = request.GET['id'] 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 if request.method == 'POST': diff --git a/pandora/item/models.py b/pandora/item/models.py index 311b7c68..cceedf74 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -74,8 +74,9 @@ def get_item(info, user=None, async=False): item_data = { 'title': info.get('title', ''), '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', 'season', 'episode', 'seriesTitle'): if key in info and info[key]: diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index 47958a71..636d5e3a 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -36,7 +36,8 @@ "canSeeFiles": {"staff": true, "admin": true}, "canSeeItem": {"guest": 1, "member": 1, "staff": 4, "admin": 4}, "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.