show selected/wanted files
This commit is contained in:
parent
3c3f932c68
commit
74f777e0d1
5 changed files with 121 additions and 40 deletions
|
|
@ -261,28 +261,26 @@ class File(models.Model):
|
|||
if resolution == (0, 0):
|
||||
resolution = None
|
||||
duration = self.duration
|
||||
if self.get_type() != 'video':
|
||||
if self.type != 'video':
|
||||
duration = None
|
||||
data = {
|
||||
'audioCodec': self.audio_codec,
|
||||
'available': self.available,
|
||||
'duration': duration,
|
||||
'framerate': self.framerate,
|
||||
#'height': self.height,
|
||||
#'width': self.width,
|
||||
'resolution': resolution,
|
||||
'id': self.oshash,
|
||||
'samplerate': self.samplerate,
|
||||
'video_codec': self.video_codec,
|
||||
'audio_codec': self.audio_codec,
|
||||
'path': self.path,
|
||||
'size': self.size,
|
||||
#'info': self.info,
|
||||
'users': list(set([u.username
|
||||
for u in User.objects.filter(volumes__files__in=self.instances.all())])),
|
||||
'instances': [i.json() for i in self.instances.all()],
|
||||
'type': self.get_type(),
|
||||
'part': self.get_part()
|
||||
'part': self.part,
|
||||
'path': self.path,
|
||||
'resolution': resolution,
|
||||
'samplerate': self.samplerate,
|
||||
'selected': self.selected,
|
||||
'size': self.size,
|
||||
'type': self.type,
|
||||
'videoCodec': self.video_codec,
|
||||
'wanted': self.wanted,
|
||||
}
|
||||
data['users'] = [i['user'] for i in data['instances']]
|
||||
if keys:
|
||||
for k in data.keys():
|
||||
if k not in keys:
|
||||
|
|
@ -290,7 +288,6 @@ class File(models.Model):
|
|||
return data
|
||||
|
||||
def get_part(self):
|
||||
#FIXME: this breaks for sub/idx/srt
|
||||
if os.path.splitext(self.path)[-1] in ('.sub', '.idx', '.srt'):
|
||||
name = os.path.splitext(self.path)[0]
|
||||
if self.language:
|
||||
|
|
@ -388,9 +385,10 @@ class Instance(models.Model):
|
|||
|
||||
def json(self):
|
||||
return {
|
||||
'ignore': self.ignore,
|
||||
'path': self.path,
|
||||
'user': self.volume.user.username,
|
||||
'volume': self.volume.name,
|
||||
'path': self.path
|
||||
}
|
||||
|
||||
def frame_path(frame, name):
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from datetime import datetime
|
|||
from django import forms
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
from django.conf import settings
|
||||
from django.db.models import Count, Sum
|
||||
from django.db.models import Count
|
||||
|
||||
import ox
|
||||
from ox.utils import json
|
||||
|
|
@ -288,7 +288,8 @@ def editFile(request):
|
|||
param data {
|
||||
id: hash of file
|
||||
part:
|
||||
id_extra: boolean
|
||||
language:
|
||||
ignore: boolean
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
@ -297,17 +298,26 @@ def editFile(request):
|
|||
}
|
||||
}
|
||||
'''
|
||||
#FIXME: permissions, need to be checked
|
||||
data = json.loads(request.POST['data'])
|
||||
f = get_object_or_404_json(models.File, oshash=data['id'])
|
||||
response = json_response()
|
||||
if data.keys() != ('id', ):
|
||||
for key in data:
|
||||
if key in ('is_extra', 'is_subtitle', 'is_video', 'is_version',
|
||||
'part', 'language'):
|
||||
if f.editable(request.user):
|
||||
update = False
|
||||
#FIXME: should all instances be ignored?
|
||||
if 'ignore' in data:
|
||||
f.instances.update(ignore=True)
|
||||
#FIXME: is this to slow to run sync?
|
||||
f.item.update_selected()
|
||||
for key in ('part', 'language'):
|
||||
if key in data:
|
||||
setattr(f, key, data[key])
|
||||
f.auto = False
|
||||
f.save()
|
||||
f.auto = False
|
||||
update = True
|
||||
if update:
|
||||
f.save()
|
||||
response = json_response(status=200, text='updated')
|
||||
else:
|
||||
response = json_response(status=403, text='permissino denied')
|
||||
return render_to_json_response(response)
|
||||
actions.register(editFile, cache=False)
|
||||
|
||||
|
|
@ -415,8 +425,6 @@ Positions
|
|||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
if settings.JSON_DEBUG:
|
||||
print json.dumps(data, indent=2)
|
||||
query = parse_query(data, request.user)
|
||||
|
||||
response = json_response({})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue