rename Item.itemId to Item.public_id
This commit is contained in:
parent
3ab0e4ba1e
commit
3232ce6989
44 changed files with 382 additions and 213 deletions
|
@ -19,7 +19,7 @@ class Command(BaseCommand):
|
|||
import annotations
|
||||
"""
|
||||
help = 'import annotations from srt'
|
||||
args = 'username itemId layername filename.srt'
|
||||
args = 'username item layername filename.srt'
|
||||
option_list = BaseCommand.option_list + (
|
||||
)
|
||||
|
||||
|
@ -27,13 +27,13 @@ class Command(BaseCommand):
|
|||
if len(args) != 4:
|
||||
print self.usage('import_srt')
|
||||
return
|
||||
username, itemId, layer_id, filename = args
|
||||
username, public_id, layer_id, filename = args
|
||||
user = User.objects.get(username=username)
|
||||
item = Item.objects.get(itemId=itemId)
|
||||
item = Item.objects.get(public_id=public_id)
|
||||
layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])[0]
|
||||
|
||||
annotations = ox.srt.load(filename)
|
||||
print 'importing %d annotations into %s/%s' % (len(annotations), itemId, layer_id)
|
||||
print 'importing %d annotations into %s/%s' % (len(annotations), public_id, layer_id)
|
||||
for i in range(len(annotations)-1):
|
||||
if annotations[i]['out'] == annotations[i+1]['in']:
|
||||
annotations[i]['out'] = annotations[i]['out'] - 0.001
|
||||
|
|
|
@ -119,7 +119,7 @@ class Annotation(models.Model):
|
|||
if not previous.public_id:
|
||||
previous.set_public_id()
|
||||
public_id = ox.fromAZ(previous.public_id.split('/')[-1]) + 1
|
||||
self.public_id = "%s/%s" % (self.item.itemId, ox.toAZ(public_id))
|
||||
self.public_id = "%s/%s" % (self.item.public_id, ox.toAZ(public_id))
|
||||
Annotation.objects.filter(id=self.id).update(public_id=self.public_id)
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -68,7 +68,7 @@ def update_matches(id, type):
|
|||
def add_annotations(data):
|
||||
from item.models import Item
|
||||
from user.models import User
|
||||
item = Item.objects.get(itemId=data['item'])
|
||||
item = Item.objects.get(public_id=data['item'])
|
||||
layer_id = data['layer']
|
||||
layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])
|
||||
if not layer:
|
||||
|
|
|
@ -100,7 +100,7 @@ def findAnnotations(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.public_id for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
@ -114,7 +114,7 @@ actions.register(findAnnotations)
|
|||
def addAnnotation(request):
|
||||
'''
|
||||
takes {
|
||||
item: itemId,
|
||||
item: public_id,
|
||||
layer: layerId,
|
||||
in: float,
|
||||
out: float,
|
||||
|
@ -131,7 +131,7 @@ def addAnnotation(request):
|
|||
return render_to_json_response(json_response(status=400,
|
||||
text='invalid data'))
|
||||
|
||||
item = get_object_or_404_json(Item, itemId=data['item'])
|
||||
item = get_object_or_404_json(Item, public_id=data['item'])
|
||||
|
||||
layer_id = data['layer']
|
||||
layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])[0]
|
||||
|
@ -155,7 +155,7 @@ actions.register(addAnnotation, cache=False)
|
|||
def addAnnotations(request):
|
||||
'''
|
||||
takes {
|
||||
item: itemId,
|
||||
item: public_id,
|
||||
layer: layerId,
|
||||
annotations: [{
|
||||
in: float,
|
||||
|
@ -173,7 +173,7 @@ def addAnnotations(request):
|
|||
return render_to_json_response(json_response(status=400,
|
||||
text='invalid data'))
|
||||
|
||||
item = get_object_or_404_json(Item, itemId=data['item'])
|
||||
item = get_object_or_404_json(Item, public_id=data['item'])
|
||||
|
||||
layer_id = data['layer']
|
||||
layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])[0]
|
||||
|
|
|
@ -213,7 +213,7 @@ def getEmbedDefaults(request):
|
|||
response['data']['edit'] = e['id']
|
||||
response['data']['editDuration'] = e['duration']
|
||||
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
qs = Item.objects.filter(level__lte=level, rendered=True).order_by('sort__itemId')
|
||||
qs = Item.objects.filter(level__lte=level, rendered=True).order_by('sort__public_id')
|
||||
if qs.exists():
|
||||
i = qs[0].json
|
||||
response['data']['item'] = i['id']
|
||||
|
|
|
@ -8,11 +8,11 @@ import models
|
|||
|
||||
class FileAdmin(admin.ModelAdmin):
|
||||
search_fields = ['path','oshash', 'video_codec']
|
||||
list_display = ['available', 'wanted', 'selected', '__unicode__', 'itemId']
|
||||
list_display = ['available', 'wanted', 'selected', '__unicode__', 'public_id']
|
||||
list_display_links = ('__unicode__', )
|
||||
|
||||
def itemId(self, obj):
|
||||
return '%s'%(obj.item.itemId)
|
||||
def public_id(self, obj):
|
||||
return '%s'%(obj.item.public_id)
|
||||
|
||||
|
||||
admin.site.register(models.File, FileAdmin)
|
||||
|
|
|
@ -390,7 +390,7 @@ class File(models.Model):
|
|||
for key in self.PATH_INFO:
|
||||
data[key] = self.info.get(key)
|
||||
data['users'] = list(set([i['user'] for i in data['instances']]))
|
||||
data['item'] = self.item.itemId
|
||||
data['item'] = self.item.public_id
|
||||
if keys:
|
||||
for k in data.keys():
|
||||
if k not in keys:
|
||||
|
@ -567,8 +567,8 @@ class Instance(models.Model):
|
|||
return u"%s's %s <%s>"% (self.volume.user, self.path, self.file.oshash)
|
||||
|
||||
@property
|
||||
def itemId(self):
|
||||
return File.objects.get(oshash=self.oshash).itemId
|
||||
def public_id(self):
|
||||
return File.objects.get(oshash=self.oshash).public_id
|
||||
|
||||
def json(self):
|
||||
return {
|
||||
|
|
|
@ -71,13 +71,13 @@ def update_files(user, volume, files):
|
|||
|
||||
#remove deleted files
|
||||
removed = models.Instance.objects.filter(volume=volume).exclude(file__oshash__in=all_files)
|
||||
ids = [i['itemId'] for i in Item.objects.filter(
|
||||
files__instances__in=removed.filter(file__selected=True)).distinct().values('itemId')]
|
||||
ids = [i['public_id'] for i in Item.objects.filter(
|
||||
files__instances__in=removed.filter(file__selected=True)).distinct().values('public_id')]
|
||||
removed.delete()
|
||||
for f in files:
|
||||
update_or_create_instance(volume, f)
|
||||
for i in ids:
|
||||
i = Item.objects.get(itemId=i)
|
||||
i = Item.objects.get(public_id=i)
|
||||
i.update_selected()
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
|
|
|
@ -138,7 +138,7 @@ def upload(request):
|
|||
os.chmod(fr.frame.path, 0644)
|
||||
f.item.select_frame()
|
||||
f.item.save()
|
||||
item.tasks.update_poster.delay(f.item.itemId)
|
||||
item.tasks.update_poster.delay(f.item.public_id)
|
||||
if 'file' in request.FILES:
|
||||
if not f.available:
|
||||
if f.data:
|
||||
|
@ -146,7 +146,7 @@ def upload(request):
|
|||
f.data.save('data.raw', request.FILES['file'])
|
||||
f.save()
|
||||
os.chmod(f.data.path, 0644)
|
||||
item.tasks.load_subtitles.delay(f.item.itemId)
|
||||
item.tasks.load_subtitles.delay(f.item.public_id)
|
||||
response = json_response(text='file saved')
|
||||
else:
|
||||
response = json_response(status=403, text='permissino denied')
|
||||
|
@ -176,11 +176,11 @@ def addMedia(request):
|
|||
f = models.File.objects.get(oshash=oshash)
|
||||
if f.available:
|
||||
response['status']['text'] = 'file exists'
|
||||
response['data']['item'] = f.item.itemId
|
||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.itemId)
|
||||
response['data']['item'] = f.item.public_id
|
||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % f.item.public_id)
|
||||
else:
|
||||
if 'item' in data:
|
||||
i = Item.objects.get(itemId=data['item'])
|
||||
i = Item.objects.get(public_id=data['item'])
|
||||
else:
|
||||
title = ox.parse_movie_path(os.path.splitext(data['filename'])[0])['title']
|
||||
i = Item()
|
||||
|
@ -204,8 +204,8 @@ def addMedia(request):
|
|||
f.info['extension'] = extension
|
||||
f.parse_info()
|
||||
f.save()
|
||||
response['data']['item'] = i.itemId
|
||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % i.itemId)
|
||||
response['data']['item'] = i.public_id
|
||||
response['data']['itemUrl'] = request.build_absolute_uri('/%s' % i.public_id)
|
||||
return render_to_json_response(response)
|
||||
actions.register(addMedia, cache=False)
|
||||
|
||||
|
@ -231,7 +231,7 @@ def firefogg_upload(request):
|
|||
def save_chunk(chunk, offset, done):
|
||||
return f.save_chunk_stream(chunk, offset, resolution, format, done)
|
||||
response = process_chunk(request, save_chunk)
|
||||
response['resultUrl'] = request.build_absolute_uri('/%s'%f.item.itemId)
|
||||
response['resultUrl'] = request.build_absolute_uri('/%s'%f.item.public_id)
|
||||
if response.get('done'):
|
||||
f.uploading = False
|
||||
if response['result'] == 1:
|
||||
|
@ -262,7 +262,7 @@ def firefogg_upload(request):
|
|||
Item.objects.filter(id=f.item.id).update(rendered=False)
|
||||
response = {
|
||||
'uploadUrl': '/api/upload/?id=%s&profile=%s' % (f.oshash, profile),
|
||||
'url': request.build_absolute_uri('/%s' % f.item.itemId),
|
||||
'url': request.build_absolute_uri('/%s' % f.item.public_id),
|
||||
'result': 1
|
||||
}
|
||||
return render_to_json_response(response)
|
||||
|
@ -340,19 +340,19 @@ def moveMedia(request):
|
|||
change file / item link
|
||||
takes {
|
||||
ids: ids of files
|
||||
item: new itemId
|
||||
item: new public_id
|
||||
}
|
||||
|
||||
returns {
|
||||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
if Item.objects.filter(itemId=data['item']).count() == 1:
|
||||
i = Item.objects.get(itemId=data['item'])
|
||||
if Item.objects.filter(public_id=data['item']).count() == 1:
|
||||
i = Item.objects.get(public_id=data['item'])
|
||||
else:
|
||||
data['itemId'] = data.pop('item').strip()
|
||||
if len(data['itemId']) != 7:
|
||||
del data['itemId']
|
||||
data['public_id'] = data.pop('item').strip()
|
||||
if len(data['public_id']) != 7:
|
||||
del data['public_id']
|
||||
if 'director' in data and isinstance(data['director'], basestring):
|
||||
if data['director'] == '':
|
||||
data['director'] = []
|
||||
|
@ -360,24 +360,24 @@ def moveMedia(request):
|
|||
data['director'] = data['director'].split(', ')
|
||||
i = get_item(data, user=request.user)
|
||||
else:
|
||||
i = get_item({'imdbId': data['itemId']}, user=request.user)
|
||||
changed = [i.itemId]
|
||||
i = get_item({'imdbId': data['public_id']}, user=request.user)
|
||||
changed = [i.public_id]
|
||||
for f in models.File.objects.filter(oshash__in=data['ids']):
|
||||
if f.item.id != i.itemId and f.editable(request.user):
|
||||
if f.item.itemId not in changed:
|
||||
changed.append(f.item.itemId)
|
||||
if f.item.id != i.public_id and f.editable(request.user):
|
||||
if f.item.public_id not in changed:
|
||||
changed.append(f.item.public_id)
|
||||
f.item = i
|
||||
f.save()
|
||||
for itemId in changed:
|
||||
c = Item.objects.get(itemId=itemId)
|
||||
for public_id in changed:
|
||||
c = Item.objects.get(public_id=public_id)
|
||||
if c.files.count() == 0 and settings.CONFIG['itemRequiresVideo']:
|
||||
c.delete()
|
||||
else:
|
||||
c.rendered = False
|
||||
c.save()
|
||||
item.tasks.update_timeline.delay(itemId)
|
||||
item.tasks.update_timeline.delay(public_id)
|
||||
response = json_response(text='updated')
|
||||
response['data']['item'] = i.itemId
|
||||
response['data']['item'] = i.public_id
|
||||
return render_to_json_response(response)
|
||||
actions.register(moveMedia, cache=False)
|
||||
|
||||
|
@ -497,7 +497,7 @@ def _order_query(qs, sort, prefix=''):
|
|||
if operator != '-':
|
||||
operator = ''
|
||||
key = {
|
||||
'id': 'item__itemId',
|
||||
'id': 'item__public_id',
|
||||
'users': 'instances__volume__user__username',
|
||||
'resolution': 'width',
|
||||
'path': 'sort_path'
|
||||
|
@ -673,7 +673,7 @@ def getMediaInfo(request):
|
|||
id: oshash of stream file
|
||||
}
|
||||
returns {
|
||||
item: itemId,
|
||||
item: public_id,
|
||||
file: oshash of source file
|
||||
}
|
||||
'''
|
||||
|
@ -691,7 +691,7 @@ def getMediaInfo(request):
|
|||
if f:
|
||||
response['data'] = {
|
||||
'file': f.oshash,
|
||||
'item': f.item.itemId
|
||||
'item': f.item.public_id
|
||||
}
|
||||
return render_to_json_response(response)
|
||||
actions.register(getMediaInfo)
|
||||
|
|
|
@ -4,14 +4,14 @@ import user.models
|
|||
import archive.models
|
||||
|
||||
def recover_item(id):
|
||||
if item.models.Item.objects.filter(itemId=id).exists():
|
||||
if item.models.Item.objects.filter(public_id=id).exists():
|
||||
raise Exception('id is taken')
|
||||
qs = models.Changelog.objects.filter(value__contains='id": "%s"' % id)
|
||||
if not qs.exists():
|
||||
raise Exception('id not found')
|
||||
old = qs.order_by('-created')[0]
|
||||
i = item.models.Item()
|
||||
i.itemId = id
|
||||
i.public_id = id
|
||||
i.data = old.value
|
||||
created = old.value['created']
|
||||
i.user = user.models.User.objects.get(username=i.data['user'])
|
||||
|
@ -47,7 +47,7 @@ def recover_item(id):
|
|||
if key in i.data:
|
||||
del i.data[key]
|
||||
i.save()
|
||||
i.itemId = id
|
||||
i.public_id = id
|
||||
i.created = created
|
||||
i.save()
|
||||
i.update_sort()
|
||||
|
@ -73,7 +73,7 @@ def recover_item(id):
|
|||
return i
|
||||
|
||||
def recover_file(id, oshash, filename):
|
||||
i = item.models.Item.objects.get(itemId=id)
|
||||
i = item.models.Item.objects.get(public_id=id)
|
||||
file, created = archive.models.File.objects.get_or_create(oshash=oshash)
|
||||
if created:
|
||||
file.item = i
|
||||
|
|
|
@ -59,9 +59,9 @@ def parseCondition(condition, user):
|
|||
return Q()
|
||||
|
||||
if k == 'id':
|
||||
itemId, points = v.split('/')
|
||||
public_id, points = v.split('/')
|
||||
points = [float('%0.03f'%float(p)) for p in points.split('-')]
|
||||
q = Q(item__itemId=itemId, start=points[0], end=points[1])
|
||||
q = Q(item__public_id=public_id, start=points[0], end=points[1])
|
||||
return exclude and ~q or q
|
||||
|
||||
elif k.endswith('__id'):
|
||||
|
|
|
@ -95,7 +95,7 @@ class MetaClip:
|
|||
data = {
|
||||
'id': ox.toAZ(self.id),
|
||||
}
|
||||
data['item'] = self.item.itemId
|
||||
data['item'] = self.item.public_id
|
||||
data['in'] = self.start
|
||||
data['out'] = self.end
|
||||
data['parts'] = self.item.json['parts']
|
||||
|
@ -149,7 +149,7 @@ class MetaClip:
|
|||
|
||||
@property
|
||||
def public_id(self):
|
||||
return u"%s/%0.03f-%0.03f" % (self.item.itemId, float(self.start), float(self.end))
|
||||
return u"%s/%0.03f-%0.03f" % (self.item.public_id, float(self.start), float(self.end))
|
||||
|
||||
def __unicode__(self):
|
||||
return self.public_id
|
||||
|
|
|
@ -61,7 +61,7 @@ def order_query(qs, sort):
|
|||
#key mgith need to be changed, see order_sort in item/views.py
|
||||
key = "sort__%s" % key
|
||||
if key == 'public_id':
|
||||
order_by.append('%s%s' % (operator, 'sort__itemId'))
|
||||
order_by.append('%s%s' % (operator, 'sort__public_id'))
|
||||
order_by.append('%s%s' % (operator, 'start'))
|
||||
order_by.append('end')
|
||||
else:
|
||||
|
@ -150,8 +150,8 @@ def findClips(request):
|
|||
add_annotations(layer, aqs)
|
||||
elif 'position' in query:
|
||||
qs = order_query(qs, query['sort'])
|
||||
ids = [u'%s/%0.03f-%0.03f' % (c['item__itemId'], c['start'], c['end'])
|
||||
for c in qs.values('item__itemId', 'start', 'end')]
|
||||
ids = [u'%s/%0.03f-%0.03f' % (c['item__public_id'], c['start'], c['end'])
|
||||
for c in qs.values('item__public_id', 'start', 'end')]
|
||||
data['conditions'] = data['conditions'] + {
|
||||
'value': data['position'],
|
||||
'key': query['sort'][0]['key'],
|
||||
|
@ -160,11 +160,11 @@ def findClips(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
qs = order_query(qs, query['sort'])
|
||||
ids = [u'%s/%0.03f-%0.03f' % (c['item__itemId'], c['start'], c['end'])
|
||||
for c in qs.values('item__itemId', 'start', 'end')]
|
||||
ids = [u'%s/%0.03f-%0.03f' % (c['item__public_id'], c['start'], c['end'])
|
||||
for c in qs.values('item__public_id', 'start', 'end')]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
else:
|
||||
response['data']['items'] = qs.count()
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
"canEditUsers": {"admin": true},
|
||||
"canExportAnnotations": {"member": true, "staff": true, "admin": true},
|
||||
"canImportAnnotations": {"member": true, "staff": true, "admin": true},
|
||||
"canExportAnnotations": {"member": true, "staff": true, "admin": true},
|
||||
"canManageDocuments": {"member": true, "staff": true, "admin": true},
|
||||
"canManagePlacesAndEvents": {"member": true, "staff": true, "admin": true},
|
||||
"canManageTitlesAndNames": {"member": true, "staff": true, "admin": true},
|
||||
|
|
|
@ -11,7 +11,7 @@ def parseCondition(condition, user, item=None):
|
|||
k = condition.get('key', 'name')
|
||||
k = {
|
||||
'user': 'user__username',
|
||||
'item': 'items__itemId',
|
||||
'item': 'items__public_id',
|
||||
}.get(k, k)
|
||||
if not k:
|
||||
k = 'name'
|
||||
|
|
|
@ -166,7 +166,7 @@ class Document(models.Model):
|
|||
response[key] = getattr(self, _map.get(key,key)) or ''
|
||||
if item:
|
||||
if isinstance(item, basestring):
|
||||
item = Item.objects.get(itemId=item)
|
||||
item = Item.objects.get(public_id=item)
|
||||
d = self.descriptions.filter(item=item)
|
||||
if d.exists():
|
||||
if 'description' in keys and d[0].description:
|
||||
|
|
|
@ -47,7 +47,7 @@ def addDocument(request):
|
|||
ids = [data['id']]
|
||||
if 'item' in data:
|
||||
if isinstance(data['item'], basestring):
|
||||
item = Item.objects.get(itemId=data['item'])
|
||||
item = Item.objects.get(public_id=data['item'])
|
||||
if item.editable(request.user):
|
||||
for id in ids:
|
||||
document = models.Document.get(id)
|
||||
|
@ -55,7 +55,7 @@ def addDocument(request):
|
|||
else:
|
||||
response = json_response(status=403, text='permission denied')
|
||||
else:
|
||||
for item in Item.objects.filter(itemId__in=data['item']):
|
||||
for item in Item.objects.filter(public_id__in=data['item']):
|
||||
if item.editable(request.user):
|
||||
for id in ids:
|
||||
document = models.Document.get(id)
|
||||
|
@ -79,7 +79,7 @@ def editDocument(request):
|
|||
'''
|
||||
response = json_response()
|
||||
data = json.loads(request.POST['data'])
|
||||
item = 'item' in data and Item.objects.get(itemId=data['item']) or None
|
||||
item = 'item' in data and Item.objects.get(public_id=data['item']) or None
|
||||
if data['id']:
|
||||
document = models.Document.get(data['id'])
|
||||
if document.editable(request.user, item):
|
||||
|
@ -230,7 +230,7 @@ def removeDocument(request):
|
|||
ids = data['ids']
|
||||
else:
|
||||
ids = [data['id']]
|
||||
item = 'item' in data and Item.objects.get(itemId=data['item']) or None
|
||||
item = 'item' in data and Item.objects.get(public_id=data['item']) or None
|
||||
if item:
|
||||
if item.editable(request.user):
|
||||
for id in ids:
|
||||
|
@ -261,7 +261,7 @@ def sortDocuments(request):
|
|||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
index = 0
|
||||
item = Item.objects.get(itemId=data['item'])
|
||||
item = Item.objects.get(public_id=data['item'])
|
||||
ids = data['ids']
|
||||
if item.editable(request.user):
|
||||
for i in ids:
|
||||
|
|
|
@ -74,7 +74,7 @@ class Edit(models.Model):
|
|||
clip.annotation = Annotation.objects.get(public_id=data['annotation'])
|
||||
clip.item = clip.annotation.item
|
||||
else:
|
||||
clip.item = Item.objects.get(itemId=data['item'])
|
||||
clip.item = Item.objects.get(public_id=data['item'])
|
||||
clip.start = data['in']
|
||||
clip.end = data['out']
|
||||
clip.index = index
|
||||
|
@ -246,13 +246,13 @@ class Edit(models.Model):
|
|||
poster_frames = []
|
||||
for i in range(0, items.count(), max(1, int(items.count()/4))):
|
||||
poster_frames.append({
|
||||
'item': items[int(i)].itemId,
|
||||
'item': items[int(i)].public_id,
|
||||
'position': items[int(i)].poster_frame
|
||||
})
|
||||
self.poster_frames = tuple(poster_frames)
|
||||
self.save()
|
||||
for i in self.poster_frames:
|
||||
qs = Item.objects.filter(itemId=i['item'])
|
||||
qs = Item.objects.filter(public_id=i['item'])
|
||||
if qs.count() > 0:
|
||||
frame = qs[0].frame(i['position'])
|
||||
if frame:
|
||||
|
@ -387,7 +387,7 @@ class Clip(models.Model):
|
|||
def __unicode__(self):
|
||||
if self.annotation:
|
||||
return u'%s' % self.annotation.public_id
|
||||
return u'%s/%0.3f-%0.3f' % (self.item.itemId, self.start, self.end)
|
||||
return u'%s/%0.3f-%0.3f' % (self.item.public_id, self.start, self.end)
|
||||
|
||||
def get_id(self):
|
||||
return ox.toAZ(self.id)
|
||||
|
@ -426,13 +426,13 @@ class Clip(models.Model):
|
|||
}
|
||||
if self.annotation:
|
||||
data['annotation'] = self.annotation.public_id
|
||||
data['item'] = self.item.itemId
|
||||
data['item'] = self.item.public_id
|
||||
data['in'] = self.annotation.start
|
||||
data['out'] = self.annotation.end
|
||||
data['parts'] = self.annotation.item.json['parts']
|
||||
data['durations'] = self.annotation.item.json['durations']
|
||||
else:
|
||||
data['item'] = self.item.itemId
|
||||
data['item'] = self.item.public_id
|
||||
data['in'] = self.start
|
||||
data['out'] = self.end
|
||||
data['parts'] = self.item.json['parts']
|
||||
|
|
|
@ -178,7 +178,7 @@ def _order_clips(edit, sort):
|
|||
'in': 'start',
|
||||
'out': 'end',
|
||||
'text': 'sortvalue',
|
||||
'item__sort__item': 'item__sort__itemId',
|
||||
'item__sort__item': 'item__sort__public_id',
|
||||
}.get(key, key)
|
||||
order = '%s%s' % (operator, key)
|
||||
order_by.append(order)
|
||||
|
|
|
@ -227,7 +227,7 @@ Positions
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.get_id() for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
|
|
@ -7,8 +7,8 @@ import models
|
|||
|
||||
|
||||
class ItemAdmin(admin.ModelAdmin):
|
||||
search_fields = ['itemId', 'data', 'external_data']
|
||||
list_display = ['rendered', 'itemId', '__unicode__']
|
||||
search_fields = ['public_id', 'data', 'external_data']
|
||||
list_display = ['rendered', 'public_id', '__unicode__']
|
||||
list_display_links = ('__unicode__', )
|
||||
|
||||
admin.site.register(models.Item, ItemAdmin)
|
||||
|
|
|
@ -13,7 +13,7 @@ class Command(BaseCommand):
|
|||
|
||||
def handle(self, id, height, position, **options):
|
||||
position = float(position)
|
||||
i = models.Item.objects.get(itemId=id)
|
||||
i = models.Item.objects.get(public_id=id)
|
||||
path = i.frame(position, height)
|
||||
if path:
|
||||
print path
|
||||
|
|
|
@ -25,6 +25,6 @@ class Command(BaseCommand):
|
|||
for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]:
|
||||
if not os.path.exists(os.path.join(i.timeline_prefix, 'cuts.json')) or \
|
||||
not glob('%s/timelinekeyframes16p0.jpg'%i.timeline_prefix):
|
||||
print i.itemId
|
||||
tasks.rebuild_timeline.delay(i.itemId)
|
||||
print i.public_id
|
||||
tasks.rebuild_timeline.delay(i.public_id)
|
||||
offset += chunk
|
||||
|
|
|
@ -22,7 +22,7 @@ class Command(BaseCommand):
|
|||
count = pos = models.Item.objects.count()
|
||||
while offset <= count:
|
||||
for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]:
|
||||
print pos, i.itemId
|
||||
print pos, i.public_id
|
||||
i.save()
|
||||
time.sleep(1) #dont overload db
|
||||
pos -= 1
|
||||
|
|
|
@ -24,12 +24,12 @@ class Command(BaseCommand):
|
|||
def handle(self, **options):
|
||||
offset = 0
|
||||
chunk = options['all'] and 100 or options['items']
|
||||
qs = models.Item.objects.exclude(itemId__startswith='0x')
|
||||
qs = models.Item.objects.exclude(public_id__startswith='0x')
|
||||
count = pos = qs.count()
|
||||
while (options['all'] and offset <= count) or offset < options['items']:
|
||||
print offset, pos, count
|
||||
for i in qs.order_by('modified')[:chunk]:
|
||||
print pos, i.itemId, i.modified
|
||||
print pos, i.public_id, i.modified
|
||||
i.update_external()
|
||||
pos -= 1
|
||||
offset += chunk
|
||||
|
|
|
@ -51,7 +51,7 @@ def parseCondition(condition, user, owner=None):
|
|||
...
|
||||
'''
|
||||
k = condition.get('key', '*')
|
||||
k = {'id': 'itemId'}.get(k, k)
|
||||
k = {'id': 'public_id'}.get(k, k)
|
||||
if not k:
|
||||
k = '*'
|
||||
v = condition['value']
|
||||
|
@ -135,7 +135,7 @@ def parseCondition(condition, user, owner=None):
|
|||
q = ~q
|
||||
return q
|
||||
elif key_type == "string":
|
||||
in_find = not k.startswith('itemId')
|
||||
in_find = not k.startswith('public_id')
|
||||
if in_find:
|
||||
value_key = 'find__value'
|
||||
else:
|
||||
|
|
168
pandora/item/migrations/0005_public_id.py
Normal file
168
pandora/item/migrations/0005_public_id.py
Normal file
|
@ -0,0 +1,168 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from south.utils import datetime_utils as datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
|
||||
# Rename field 'Item.itemId' to 'Item.public_id'
|
||||
db.rename_column('item_item', 'itemId', 'public_id')
|
||||
|
||||
# Rename field 'ItemSort.itemId' to 'ItemSort.public_id'
|
||||
db.rename_column('item_itemsort', 'itemId', 'public_id')
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Rename field 'Item.public_id' to 'Item.itemId'
|
||||
db.rename_column('item_item', 'public_id', 'itemId')
|
||||
|
||||
# Rename field 'ItemSort.public_id' to 'ItemSort.itemId'
|
||||
db.rename_column('item_itemsort', 'public_id', 'itemId')
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'item.access': {
|
||||
'Meta': {'unique_together': "(('item', 'user'),)", 'object_name': 'Access'},
|
||||
'access': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'accessed': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'accessed'", 'to': "orm['item.Item']"}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'accessed_items'", 'null': 'True', 'to': "orm['auth.User']"})
|
||||
},
|
||||
'item.description': {
|
||||
'Meta': {'unique_together': "(('key', 'value'),)", 'object_name': 'Description'},
|
||||
'description': ('django.db.models.fields.TextField', [], {}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
|
||||
'value': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'db_index': 'True'})
|
||||
},
|
||||
'item.facet': {
|
||||
'Meta': {'unique_together': "(('item', 'key', 'value'),)", 'object_name': 'Facet'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'facets'", 'to': "orm['item.Item']"}),
|
||||
'key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
|
||||
'sortvalue': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'db_index': 'True'}),
|
||||
'value': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'db_index': 'True'})
|
||||
},
|
||||
'item.item': {
|
||||
'Meta': {'object_name': 'Item'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'external_data': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "'items'", 'blank': 'True', 'to': "orm['auth.Group']"}),
|
||||
'icon': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'public_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}),
|
||||
'json': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'level': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'oxdbId': ('django.db.models.fields.CharField', [], {'max_length': '42', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'poster': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}),
|
||||
'poster_frame': ('django.db.models.fields.FloatField', [], {'default': '-1'}),
|
||||
'poster_height': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'poster_source': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'poster_width': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
|
||||
'rendered': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}),
|
||||
'stream_aspect': ('django.db.models.fields.FloatField', [], {'default': '1.3333333333333333'}),
|
||||
'stream_info': ('ox.django.fields.DictField', [], {'default': '{}'}),
|
||||
'torrent': ('django.db.models.fields.files.FileField', [], {'default': 'None', 'max_length': '1000', 'blank': 'True'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'items'", 'null': 'True', 'to': "orm['auth.User']"})
|
||||
},
|
||||
'item.itemfind': {
|
||||
'Meta': {'unique_together': "(('item', 'key'),)", 'object_name': 'ItemFind'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'item': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'find'", 'to': "orm['item.Item']"}),
|
||||
'key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
|
||||
'value': ('django.db.models.fields.TextField', [], {'db_index': 'False', 'blank': 'True'})
|
||||
},
|
||||
'item.itemsort': {
|
||||
'Meta': {'object_name': 'ItemSort'},
|
||||
'accessed': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'aspectratio': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'bitrate': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'cinematographer': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'codirector': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'color': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'composer': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'country': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'cutsperminute': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'director': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'duration': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'editor': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'genre': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'height': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'hue': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'imdbId': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'item': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'sort'", 'unique': 'True', 'primary_key': 'True', 'to': "orm['item.Item']"}),
|
||||
'public_id': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'language': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'lightness': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'lyricist': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'numberofactors': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'numberofcuts': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'numberoffiles': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'parts': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'pixels': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'producer': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'productionCompany': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'random': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'resolution': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'rightslevel': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'runtime': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'saturation': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'size': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'sound': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'timesaccessed': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'volume': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'width': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'words': ('django.db.models.fields.BigIntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'wordsperminute': ('django.db.models.fields.FloatField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}),
|
||||
'writer': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'db_index': 'True'}),
|
||||
'year': ('django.db.models.fields.CharField', [], {'max_length': '4', 'null': 'True', 'db_index': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['item']
|
|
@ -58,7 +58,7 @@ def get_id(info):
|
|||
else:
|
||||
q = q.filter(**{k:key, v:info[key]})
|
||||
if q.count() == 1:
|
||||
return q[0].itemId
|
||||
return q[0].public_id
|
||||
if settings.DATA_SERVICE:
|
||||
r = external_data('getId', info)
|
||||
if r['status']['code'] == 200:
|
||||
|
@ -95,34 +95,34 @@ def get_item(info, user=None, async=False):
|
|||
if settings.USE_IMDB:
|
||||
if 'imdbId' in info and info['imdbId']:
|
||||
try:
|
||||
item = Item.objects.get(itemId=info['imdbId'])
|
||||
item = Item.objects.get(public_id=info['imdbId'])
|
||||
except Item.DoesNotExist:
|
||||
item = Item(itemId=info['imdbId'])
|
||||
item = Item(public_id=info['imdbId'])
|
||||
if 'title' in info and 'director' in info:
|
||||
item.external_data = item_data
|
||||
item.user = user
|
||||
item.oxdbId = item.itemId
|
||||
item.oxdbId = item.public_id
|
||||
item.save()
|
||||
if async:
|
||||
tasks.update_external.delay(item.itemId)
|
||||
tasks.update_external.delay(item.public_id)
|
||||
else:
|
||||
item.update_external()
|
||||
else:
|
||||
itemId = get_id(info)
|
||||
if itemId:
|
||||
public_id = get_id(info)
|
||||
if public_id:
|
||||
try:
|
||||
item = Item.objects.get(itemId=itemId)
|
||||
item = Item.objects.get(public_id=public_id)
|
||||
except Item.DoesNotExist:
|
||||
info['imdbId'] = itemId
|
||||
info['imdbId'] = public_id
|
||||
item = get_item(info, user)
|
||||
return item
|
||||
try:
|
||||
item = Item.objects.get(itemId=info.get('oxdbId'))
|
||||
item = Item.objects.get(public_id=info.get('oxdbId'))
|
||||
except Item.DoesNotExist:
|
||||
item = Item()
|
||||
item.user = user
|
||||
item.data = item_data
|
||||
item.itemId = info.get('oxdbId', item.oxdb_id())
|
||||
item.public_id = info.get('oxdbId', item.oxdb_id())
|
||||
try:
|
||||
existing_item = Item.objects.get(oxdbId=item.oxdb_id())
|
||||
item = existing_item
|
||||
|
@ -130,7 +130,7 @@ def get_item(info, user=None, async=False):
|
|||
item.oxdbId = item.oxdb_id()
|
||||
p = item.save()
|
||||
if not p:
|
||||
tasks.update_poster.delay(item.itemId)
|
||||
tasks.update_poster.delay(item.public_id)
|
||||
else:
|
||||
qs = Item.objects.filter(find__key='title', find__value__iexact=info['title'])
|
||||
if 'year' in info:
|
||||
|
@ -143,7 +143,7 @@ def get_item(info, user=None, async=False):
|
|||
item.user = user
|
||||
p = item.save()
|
||||
if not p:
|
||||
tasks.update_poster.delay(item.itemId)
|
||||
tasks.update_poster.delay(item.public_id)
|
||||
return item
|
||||
|
||||
class Item(models.Model):
|
||||
|
@ -158,7 +158,7 @@ class Item(models.Model):
|
|||
#should be set based on user
|
||||
level = models.IntegerField(db_index=True)
|
||||
|
||||
itemId = models.CharField(max_length=128, unique=True, blank=True)
|
||||
public_id = models.CharField(max_length=128, unique=True, blank=True)
|
||||
oxdbId = models.CharField(max_length=42, unique=True, blank=True, null=True)
|
||||
external_data = fields.DictField(default={}, editable=False)
|
||||
data = fields.DictField(default={}, editable=False)
|
||||
|
@ -280,7 +280,7 @@ class Item(models.Model):
|
|||
self.data[key] = ox.escape_html(data[key])
|
||||
p = self.save()
|
||||
if not settings.USE_IMDB and filter(lambda k: k in ('title', 'director', 'year'), data):
|
||||
p = tasks.update_poster.delay(self.itemId)
|
||||
p = tasks.update_poster.delay(self.public_id)
|
||||
return p
|
||||
|
||||
def log(self):
|
||||
|
@ -289,8 +289,8 @@ class Item(models.Model):
|
|||
c.save()
|
||||
|
||||
def update_external(self):
|
||||
if settings.DATA_SERVICE and not self.itemId.startswith('0x'):
|
||||
response = external_data('getData', {'id': self.itemId})
|
||||
if settings.DATA_SERVICE and not self.public_id.startswith('0x'):
|
||||
response = external_data('getData', {'id': self.public_id})
|
||||
if response['status']['code'] == 200:
|
||||
self.external_data = response['data']
|
||||
p = self.save()
|
||||
|
@ -313,8 +313,8 @@ class Item(models.Model):
|
|||
c[t]= [{'id': i, 'title': None} for i in c[t]]
|
||||
ids = [i['id'] for i in c[t]]
|
||||
known = {}
|
||||
for l in Item.objects.filter(itemId__in=ids):
|
||||
known[l.itemId] = l.get('title')
|
||||
for l in Item.objects.filter(public_id__in=ids):
|
||||
known[l.public_id] = l.get('title')
|
||||
for i in c[t]:
|
||||
if i['id'] in known:
|
||||
i['item'] = i['id']
|
||||
|
@ -330,10 +330,10 @@ class Item(models.Model):
|
|||
string = u'%s (%s)' % (ox.decode_html(self.get('title', 'Untitled')), self.get('year'))
|
||||
else:
|
||||
string = self.get('title', u'Untitled')
|
||||
return u'[%s] %s' % (self.itemId,string)
|
||||
return u'[%s] %s' % (self.public_id,string)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return '/%s' % self.itemId
|
||||
return '/%s' % self.public_id
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
update_poster = False
|
||||
|
@ -343,12 +343,12 @@ class Item(models.Model):
|
|||
self.level = settings.CONFIG['rightsLevel'][self.user.get_profile().get_level()]
|
||||
else:
|
||||
self.level = settings.CONFIG['rightsLevel']['member']
|
||||
if not self.itemId:
|
||||
self.itemId = str(uuid.uuid1())
|
||||
if not self.public_id:
|
||||
self.public_id = str(uuid.uuid1())
|
||||
self.add_default_data()
|
||||
super(Item, self).save(*args, **kwargs)
|
||||
if not settings.USE_IMDB:
|
||||
self.itemId = ox.toAZ(self.id)
|
||||
self.public_id = ox.toAZ(self.id)
|
||||
|
||||
#this does not work if another item without imdbid has the same metadata
|
||||
oxdbId = self.oxdb_id()
|
||||
|
@ -358,7 +358,7 @@ class Item(models.Model):
|
|||
if self.oxdbId != oxdbId:
|
||||
q = Item.objects.filter(oxdbId=oxdbId).exclude(id=self.id)
|
||||
if q.count() != 0:
|
||||
if len(self.itemId) == 7:
|
||||
if len(self.public_id) == 7:
|
||||
self.oxdbId = None
|
||||
q[0].merge_with(self, save=False)
|
||||
else:
|
||||
|
@ -372,14 +372,14 @@ class Item(models.Model):
|
|||
q = Item.objects.filter(oxdbId=oxdbId).exclude(id=self.id)
|
||||
self.oxdbId = oxdbId
|
||||
update_poster = True
|
||||
if len(self.itemId) != 7:
|
||||
if len(self.public_id) != 7:
|
||||
update_ids = True
|
||||
|
||||
#id changed, what about existing item with new id?
|
||||
if settings.USE_IMDB and len(self.itemId) != 7 and self.oxdbId != self.itemId:
|
||||
self.itemId = self.oxdbId
|
||||
if settings.USE_IMDB and len(self.public_id) != 7 and self.oxdbId != self.public_id:
|
||||
self.public_id = self.oxdbId
|
||||
#FIXME: move files to new id here
|
||||
if settings.USE_IMDB and len(self.itemId) == 7:
|
||||
if settings.USE_IMDB and len(self.public_id) == 7:
|
||||
for key in ('title', 'year', 'director', 'season', 'episode',
|
||||
'seriesTitle', 'episodeTitle'):
|
||||
if key in self.data:
|
||||
|
@ -389,7 +389,7 @@ class Item(models.Model):
|
|||
if settings.USE_IMDB:
|
||||
defaults = filter(lambda k: 'default' in k, settings.CONFIG['itemKeys'])
|
||||
for k in defaults:
|
||||
if len(self.itemId) == 7:
|
||||
if len(self.public_id) == 7:
|
||||
if k['id'] in self.data and self.data[k['id']] == k['default']:
|
||||
del self.data[k['id']]
|
||||
else:
|
||||
|
@ -414,13 +414,13 @@ class Item(models.Model):
|
|||
for c in self.clips.all(): c.save()
|
||||
for a in self.annotations.all():
|
||||
public_id = a.public_id.split('/')[1]
|
||||
public_id = "%s/%s" % (self.itemId, public_id)
|
||||
public_id = "%s/%s" % (self.public_id, public_id)
|
||||
if public_id != a.public_id:
|
||||
a.public_id = public_id
|
||||
a.save()
|
||||
tasks.update_file_paths.delay(self.itemId)
|
||||
tasks.update_file_paths.delay(self.public_id)
|
||||
if update_poster:
|
||||
return tasks.update_poster.delay(self.itemId)
|
||||
return tasks.update_poster.delay(self.public_id)
|
||||
return None
|
||||
|
||||
def delete_files(self):
|
||||
|
@ -498,7 +498,7 @@ class Item(models.Model):
|
|||
poster = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))
|
||||
if os.path.exists(poster):
|
||||
posters.append({
|
||||
'url': '/%s/siteposter.jpg' % self.itemId,
|
||||
'url': '/%s/siteposter.jpg' % self.public_id,
|
||||
'width': 640,
|
||||
'height': 1024,
|
||||
'source': settings.URL,
|
||||
|
@ -529,7 +529,7 @@ class Item(models.Model):
|
|||
'index': p,
|
||||
'position': f['position'],
|
||||
'selected': p == pos,
|
||||
'url': '/%s/posterframe%d.jpg' %(self.itemId, p),
|
||||
'url': '/%s/posterframe%d.jpg' %(self.public_id, p),
|
||||
'height': f['height'],
|
||||
'width': f['width']
|
||||
})
|
||||
|
@ -564,7 +564,7 @@ class Item(models.Model):
|
|||
|
||||
def get_json(self, keys=None):
|
||||
i = {
|
||||
'id': self.itemId,
|
||||
'id': self.public_id,
|
||||
'rendered': self.rendered,
|
||||
'rightslevel': self.level
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ class Item(models.Model):
|
|||
i.update(self.external_data)
|
||||
i.update(self.data)
|
||||
if settings.USE_IMDB:
|
||||
i['oxdbId'] = self.oxdbId or self.oxdb_id() or self.itemId
|
||||
i['oxdbId'] = self.oxdbId or self.oxdb_id() or self.public_id
|
||||
for k in settings.CONFIG['itemKeys']:
|
||||
key = k['id']
|
||||
if not keys or key in keys:
|
||||
|
@ -710,7 +710,7 @@ class Item(models.Model):
|
|||
|
||||
def oxdb_id(self):
|
||||
if not self.get('title') and not self.get('director'):
|
||||
return self.itemId
|
||||
return self.public_id
|
||||
return ox.get_oxid(self.get('seriesTitle', self.get('title', '')),
|
||||
self.get('director', []),
|
||||
self.get('seriesYear', self.get('year', '')),
|
||||
|
@ -884,10 +884,10 @@ class Item(models.Model):
|
|||
)
|
||||
|
||||
#sort keys based on database, these will always be available
|
||||
s.itemId = self.itemId.replace('0x', 'xx')
|
||||
s.public_id = self.public_id.replace('0x', 'xx')
|
||||
s.oxdbId = self.oxdbId
|
||||
if not settings.USE_IMDB:
|
||||
s.itemId = ox.sort_string(str(ox.fromAZ(s.itemId)))
|
||||
s.public_id = ox.sort_string(str(ox.fromAZ(s.public_id)))
|
||||
s.modified = self.modified or datetime.now()
|
||||
s.created = self.created or datetime.now()
|
||||
s.rightslevel = self.level
|
||||
|
@ -1062,7 +1062,7 @@ class Item(models.Model):
|
|||
self.update_layer_facets()
|
||||
|
||||
def path(self, name=''):
|
||||
h = self.itemId
|
||||
h = self.public_id
|
||||
h = (7-len(h))*'0' + h
|
||||
return os.path.join('items', h[:2], h[2:4], h[4:6], h[6:], name)
|
||||
|
||||
|
@ -1157,7 +1157,7 @@ class Item(models.Model):
|
|||
if update:
|
||||
self.rendered = False
|
||||
self.save()
|
||||
tasks.update_timeline.delay(self.itemId)
|
||||
tasks.update_timeline.delay(self.public_id)
|
||||
break
|
||||
if not sets:
|
||||
self.rendered = False
|
||||
|
@ -1295,10 +1295,10 @@ class Item(models.Model):
|
|||
self.save()
|
||||
if self.rendered:
|
||||
if async:
|
||||
get_sequences.delay(self.itemId)
|
||||
get_sequences.delay(self.public_id)
|
||||
else:
|
||||
get_sequences(self.itemId)
|
||||
tasks.load_subtitles.delay(self.itemId)
|
||||
get_sequences(self.public_id)
|
||||
tasks.load_subtitles.delay(self.public_id)
|
||||
|
||||
def save_poster(self, data):
|
||||
self.poster.name = self.path('poster.jpg')
|
||||
|
@ -1365,7 +1365,7 @@ class Item(models.Model):
|
|||
data['frame'] = frame
|
||||
if os.path.exists(timeline):
|
||||
data['timeline'] = timeline
|
||||
data['oxdbId'] = self.oxdbId or self.oxdb_id() or self.itemId
|
||||
data['oxdbId'] = self.oxdbId or self.oxdb_id() or self.public_id
|
||||
ox.makedirs(os.path.join(settings.MEDIA_ROOT,self.path()))
|
||||
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, close_fds=True)
|
||||
p.communicate(json.dumps(data, default=fields.to_json))
|
||||
|
@ -1624,7 +1624,7 @@ attrs = {
|
|||
}
|
||||
for key in filter(lambda k: k.get('sort', False) or k['type'] in ('integer', 'time', 'float', 'date', 'enum'), settings.CONFIG['itemKeys']):
|
||||
name = key['id']
|
||||
name = {'id': 'itemId'}.get(name, name)
|
||||
name = {'id': 'public_id'}.get(name, name)
|
||||
sort_type = key.get('sortType', key['type'])
|
||||
if isinstance(sort_type, list):
|
||||
sort_type = sort_type[0]
|
||||
|
|
|
@ -40,13 +40,13 @@ def update_random_clip_sort():
|
|||
cursor.execute('CREATE INDEX "clip_random_random" ON "clip_random" ("random")')
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_clips(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def update_clips(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
item.clips.all().update(user=item.user.id)
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_poster(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def update_poster(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
item.make_poster(True)
|
||||
item.make_icon()
|
||||
if item.poster and os.path.exists(item.poster.path):
|
||||
|
@ -58,32 +58,32 @@ def update_poster(itemId):
|
|||
)
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_file_paths(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def update_file_paths(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
for f in item.files.all():
|
||||
if f.normalize_path() != f.path:
|
||||
f.save()
|
||||
|
||||
@task(ignore_results=True, queue='default')
|
||||
def update_external(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def update_external(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
item.update_external()
|
||||
|
||||
@task(queue="encoding")
|
||||
def update_timeline(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def update_timeline(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
item.update_timeline(async=False)
|
||||
|
||||
@task(queue="encoding")
|
||||
def rebuild_timeline(itemId):
|
||||
i = models.Item.objects.get(itemId=itemId)
|
||||
def rebuild_timeline(public_id):
|
||||
i = models.Item.objects.get(public_id=public_id)
|
||||
for s in i.streams():
|
||||
s.make_timeline()
|
||||
i.update_timeline(async=False)
|
||||
|
||||
@task(queue="encoding")
|
||||
def load_subtitles(itemId):
|
||||
item = models.Item.objects.get(itemId=itemId)
|
||||
def load_subtitles(public_id):
|
||||
item = models.Item.objects.get(public_id=public_id)
|
||||
if item.load_subtitles():
|
||||
item.update_find()
|
||||
item.update_sort()
|
||||
|
@ -131,7 +131,7 @@ def update_sitemap(base_url):
|
|||
url = ET.SubElement(urlset, "url")
|
||||
# URL of the page. This URL must begin with the protocol (such as http)
|
||||
loc = ET.SubElement(url, "loc")
|
||||
loc.text = absolute_url("%s/info" % i.itemId)
|
||||
loc.text = absolute_url("%s/info" % i.public_id)
|
||||
# This date should be in W3C Datetime format, can be %Y-%m-%d
|
||||
lastmod = ET.SubElement(url, "lastmod")
|
||||
lastmod.text = i.modified.strftime("%Y-%m-%d")
|
||||
|
@ -144,14 +144,14 @@ def update_sitemap(base_url):
|
|||
if i.rendered:
|
||||
video = ET.SubElement(url, "video:video")
|
||||
#el = ET.SubElement(video, "video:content_loc")
|
||||
#el.text = absolute_url("%s/video" % i.itemId)
|
||||
#el.text = absolute_url("%s/video" % i.public_id)
|
||||
el = ET.SubElement(video, "video:player_loc")
|
||||
el.attrib['allow_embed'] = 'no'
|
||||
el.text = absolute_url("%s/player" % i.itemId)
|
||||
el.text = absolute_url("%s/player" % i.public_id)
|
||||
el = ET.SubElement(video, "video:title")
|
||||
el.text = i.get('title')
|
||||
el = ET.SubElement(video, "video:thumbnail_loc")
|
||||
el.text = absolute_url("%s/96p.jpg" % i.itemId)
|
||||
el.text = absolute_url("%s/96p.jpg" % i.public_id)
|
||||
description = i.get_item_description()
|
||||
if description:
|
||||
el = ET.SubElement(video, "video:description")
|
||||
|
|
|
@ -48,7 +48,7 @@ def _order_query(qs, sort, prefix='sort__'):
|
|||
if operator != '-':
|
||||
operator = ''
|
||||
key = {
|
||||
'id': 'itemId',
|
||||
'id': 'public_id',
|
||||
'index': 'listitem__index'
|
||||
}.get(e['key'], e['key'])
|
||||
if key not in ('listitem__index', ):
|
||||
|
@ -208,7 +208,7 @@ Positions
|
|||
response['data']['items'] = qs.count()
|
||||
elif 'position' in query:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
ids = [j['itemId'] for j in qs.values('itemId')]
|
||||
ids = [j['public_id'] for j in qs.values('public_id')]
|
||||
data['conditions'] = data['conditions'] + {
|
||||
'value': query['position'],
|
||||
'key': query['sort'][0]['key'],
|
||||
|
@ -217,10 +217,10 @@ Positions
|
|||
query = parse_query(data, request.user)
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in query:
|
||||
qs = _order_query(query['qs'], query['sort'])
|
||||
ids = [j['itemId'] for j in qs.values('itemId')]
|
||||
ids = [j['public_id'] for j in qs.values('public_id')]
|
||||
response['data']['positions'] = utils.get_positions(ids, query['positions'])
|
||||
elif 'keys' in query:
|
||||
response['data']['items'] = []
|
||||
|
@ -262,7 +262,7 @@ Positions
|
|||
for p in _p:
|
||||
r[p] = m.get(p, '')
|
||||
if 'clip_qs' in query:
|
||||
r['clips'] = get_clips(query['clip_qs'].filter(item__itemId=m['id']))
|
||||
r['clips'] = get_clips(query['clip_qs'].filter(item__public_id=m['id']))
|
||||
return r
|
||||
qs = qs[query['range'][0]:query['range'][1]]
|
||||
#response['data']['items'] = [m.get_json(_p) for m in qs]
|
||||
|
@ -383,7 +383,7 @@ def findId(request):
|
|||
response = json_response({})
|
||||
response['data']['items'] = []
|
||||
if 'id' in data:
|
||||
qs = models.Item.objects.filter(itemId=data['id'])
|
||||
qs = models.Item.objects.filter(public_id=data['id'])
|
||||
if qs.count() == 1:
|
||||
response['data']['items'] = [
|
||||
i.get_json(['title', 'director', 'year', 'id']) for i in qs
|
||||
|
@ -473,7 +473,7 @@ def get(request):
|
|||
response = json_response({})
|
||||
data = json.loads(request.POST['data'])
|
||||
data['keys'] = data.get('keys', [])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
if item.access(request.user):
|
||||
info = item.get_json(data['keys'])
|
||||
if not data['keys'] or 'stream' in data['keys']:
|
||||
|
@ -550,7 +550,7 @@ def edit(request):
|
|||
'''
|
||||
update_clips = False
|
||||
data = json.loads(request.POST['data'])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
if item.editable(request.user):
|
||||
item.log()
|
||||
response = json_response(status=200, text='ok')
|
||||
|
@ -572,7 +572,7 @@ def edit(request):
|
|||
if r:
|
||||
r.wait()
|
||||
if update_clips:
|
||||
tasks.update_clips.delay(item.itemId)
|
||||
tasks.update_clips.delay(item.public_id)
|
||||
response['data'] = item.get_json()
|
||||
else:
|
||||
response = json_response(status=403, text='permission denied')
|
||||
|
@ -592,7 +592,7 @@ def remove(request):
|
|||
'''
|
||||
response = json_response({})
|
||||
data = json.loads(request.POST['data'])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
user = request.user
|
||||
if user.get_profile().capability('canRemoveItems') == True or \
|
||||
user.is_staff or \
|
||||
|
@ -617,11 +617,11 @@ def setPosterFrame(request):
|
|||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
if item.editable(request.user):
|
||||
item.poster_frame = data['position']
|
||||
item.save()
|
||||
tasks.update_poster(item.itemId)
|
||||
tasks.update_poster(item.public_id)
|
||||
response = json_response()
|
||||
else:
|
||||
response = json_response(status=403, text='permissino denied')
|
||||
|
@ -644,7 +644,7 @@ def setPoster(request):
|
|||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
response = json_response()
|
||||
if item.editable(request.user):
|
||||
valid_sources = [p['source'] for p in item.get_posters()]
|
||||
|
@ -653,7 +653,7 @@ def setPoster(request):
|
|||
if item.poster:
|
||||
item.poster.delete()
|
||||
item.save()
|
||||
tasks.update_poster(item.itemId)
|
||||
tasks.update_poster(item.public_id)
|
||||
response = json_response()
|
||||
response['data']['posterAspect'] = item.poster_width/item.poster_height
|
||||
else:
|
||||
|
@ -672,7 +672,7 @@ def updateExternalData(request):
|
|||
}
|
||||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
item = get_object_or_404_json(models.Item, itemId=data['id'])
|
||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||
response = json_response()
|
||||
if item.editable(request.user):
|
||||
item.update_external()
|
||||
|
@ -698,8 +698,8 @@ def lookup(request):
|
|||
'''
|
||||
data = json.loads(request.POST['data'])
|
||||
if 'id' in data:
|
||||
i = models.Item.objects.get(itemId=data['id'])
|
||||
r = {'id': i.itemId}
|
||||
i = models.Item.objects.get(public_id=data['id'])
|
||||
r = {'id': i.public_id}
|
||||
for key in ('title', 'director', 'year'):
|
||||
r[key] = i.get(key)
|
||||
response = json_response(r)
|
||||
|
@ -710,7 +710,7 @@ actions.register(lookup)
|
|||
|
||||
|
||||
def frame(request, id, size, position=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
frame = None
|
||||
|
@ -741,7 +741,7 @@ def frame(request, id, size, position=None):
|
|||
return response
|
||||
|
||||
def poster_frame(request, id, position):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
position = int(position)
|
||||
|
@ -767,7 +767,7 @@ def image_to_response(image, size=None):
|
|||
return HttpFileResponse(path, content_type='image/jpeg')
|
||||
|
||||
def siteposter(request, id, size=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
poster = item.path('siteposter.jpg')
|
||||
|
@ -783,7 +783,7 @@ def siteposter(request, id, size=None):
|
|||
return HttpFileResponse(poster, content_type='image/jpeg')
|
||||
|
||||
def poster(request, id, size=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
if not item.poster:
|
||||
|
@ -808,7 +808,7 @@ def poster(request, id, size=None):
|
|||
return response
|
||||
|
||||
def icon(request, id, size=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
if item.icon:
|
||||
|
@ -820,7 +820,7 @@ def icon(request, id, size=None):
|
|||
return response
|
||||
|
||||
def timeline(request, id, size, position=-1, format='jpg', mode=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
|
||||
|
@ -849,7 +849,7 @@ def timeline(request, id, size, position=-1, format='jpg', mode=None):
|
|||
|
||||
def download(request, id, resolution=None, format='webm'):
|
||||
print 'download', id, resolution, format
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not resolution or int(resolution) not in settings.CONFIG['video']['resolutions']:
|
||||
resolution = max(settings.CONFIG['video']['resolutions'])
|
||||
else:
|
||||
|
@ -857,7 +857,7 @@ def download(request, id, resolution=None, format='webm'):
|
|||
if not item.access(request.user) or not item.rendered:
|
||||
return HttpResponseForbidden()
|
||||
ext = '.%s' % format
|
||||
parts = ['%s - %s ' % (item.get('title'), settings.SITENAME), item.itemId]
|
||||
parts = ['%s - %s ' % (item.get('title'), settings.SITENAME), item.public_id]
|
||||
if resolution != max(settings.CONFIG['video']['resolutions']):
|
||||
parts.append('.%dp' % resolution)
|
||||
parts.append(ext)
|
||||
|
@ -876,7 +876,7 @@ def download(request, id, resolution=None, format='webm'):
|
|||
return response
|
||||
|
||||
def torrent(request, id, filename=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
if not item.torrent:
|
||||
|
@ -902,7 +902,7 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
resolutions = sorted(settings.CONFIG['video']['resolutions'])
|
||||
if resolution not in resolutions:
|
||||
raise Http404
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
return HttpResponseForbidden()
|
||||
if index:
|
||||
|
@ -935,7 +935,7 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
ox.format_duration(t[0] * 1000).replace(':', '.')[:-4],
|
||||
ox.format_duration(t[1] * 1000).replace(':', '.')[:-4],
|
||||
settings.SITENAME,
|
||||
item.itemId,
|
||||
item.public_id,
|
||||
ext
|
||||
)
|
||||
response['Content-Disposition'] = "attachment; filename*=UTF-8''%s" % quote(filename.encode('utf-8'))
|
||||
|
@ -944,7 +944,7 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
filename = "%s - %s %s%s" % (
|
||||
item.get('title'),
|
||||
settings.SITENAME,
|
||||
item.itemId,
|
||||
item.public_id,
|
||||
ext
|
||||
)
|
||||
response = HttpFileResponse(path, content_type=content_type)
|
||||
|
@ -957,7 +957,7 @@ def video(request, id, resolution, format, index=None, track=None):
|
|||
return response
|
||||
|
||||
def srt(request, id, layer, language=None, index=None):
|
||||
item = get_object_or_404(models.Item, itemId=id)
|
||||
item = get_object_or_404(models.Item, public_id=id)
|
||||
if not item.access(request.user):
|
||||
response = HttpResponseForbidden()
|
||||
else:
|
||||
|
@ -1011,7 +1011,7 @@ def atom_xml(request):
|
|||
updated.text = item.modified.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
add_updated = False
|
||||
|
||||
page_link = request.build_absolute_uri('/%s' % item.itemId)
|
||||
page_link = request.build_absolute_uri('/%s' % item.public_id)
|
||||
|
||||
entry = ET.Element("entry")
|
||||
title = ET.SubElement(entry, "title")
|
||||
|
@ -1118,9 +1118,9 @@ def oembed(request):
|
|||
|
||||
url = request.GET['url']
|
||||
parts = urlparse(url).path.split('/')
|
||||
itemId = parts[1]
|
||||
item = get_object_or_404_json(models.Item, itemId=itemId)
|
||||
embed_url = request.build_absolute_uri('/%s' % itemId)
|
||||
public_id = parts[1]
|
||||
item = get_object_or_404_json(models.Item, public_id=public_id)
|
||||
embed_url = request.build_absolute_uri('/%s' % public_id)
|
||||
if url.startswith(embed_url):
|
||||
embed_url = url
|
||||
if not '#embed' in embed_url:
|
||||
|
@ -1148,7 +1148,7 @@ def oembed(request):
|
|||
thumbwidth -= thumbwidth % 2
|
||||
oembed['thumbnail_height'] = thumbheight
|
||||
oembed['thumbnail_width'] = thumbwidth
|
||||
oembed['thumbnail_url'] = request.build_absolute_uri('/%s/%sp.jpg' % (item.itemId, thumbheight))
|
||||
oembed['thumbnail_url'] = request.build_absolute_uri('/%s/%sp.jpg' % (item.public_id, thumbheight))
|
||||
if format == 'xml':
|
||||
oxml = ET.Element('oembed')
|
||||
for key in oembed:
|
||||
|
@ -1174,7 +1174,7 @@ def item_json(request, id):
|
|||
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
if not request.user.is_anonymous():
|
||||
level = request.user.get_profile().level
|
||||
qs = models.Item.objects.filter(itemId=id, level__lte=level)
|
||||
qs = models.Item.objects.filter(public_id=id, level__lte=level)
|
||||
if qs.count() == 0:
|
||||
response = json_response(status=404, text='not found')
|
||||
else:
|
||||
|
@ -1187,7 +1187,7 @@ def item_xml(request, id):
|
|||
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
if not request.user.is_anonymous():
|
||||
level = request.user.get_profile().level
|
||||
qs = models.Item.objects.filter(itemId=id, level__lte=level)
|
||||
qs = models.Item.objects.filter(public_id=id, level__lte=level)
|
||||
if qs.count() == 0:
|
||||
response = json_response(status=404, text='not found')
|
||||
response = render_to_json_response(response)
|
||||
|
@ -1226,7 +1226,7 @@ def item(request, id):
|
|||
level = settings.CONFIG['capabilities']['canSeeItem']['guest']
|
||||
if not request.user.is_anonymous():
|
||||
level = request.user.get_profile().level
|
||||
qs = models.Item.objects.filter(itemId=id, level__lte=level)
|
||||
qs = models.Item.objects.filter(public_id=id, level__lte=level)
|
||||
if qs.count() == 0:
|
||||
context = RequestContext(request, {
|
||||
'base_url': request.build_absolute_uri('/'),
|
||||
|
|
|
@ -92,7 +92,7 @@ class List(models.Model):
|
|||
if item:
|
||||
ListItem.objects.all().filter(item=item, list=self).delete()
|
||||
if items:
|
||||
ListItem.objects.all().filter(item__itemId__in=items, list=self).delete()
|
||||
ListItem.objects.all().filter(item__public_id__in=items, list=self).delete()
|
||||
|
||||
def __unicode__(self):
|
||||
return self.get_id()
|
||||
|
@ -231,14 +231,14 @@ class List(models.Model):
|
|||
poster_frames = []
|
||||
for i in range(0, items.count(), max(1, int(items.count()/4))):
|
||||
poster_frames.append({
|
||||
'item': items[int(i)].itemId,
|
||||
'item': items[int(i)].public_id,
|
||||
'position': items[int(i)].poster_frame
|
||||
})
|
||||
self.poster_frames = tuple(poster_frames)
|
||||
self.save()
|
||||
for i in self.poster_frames:
|
||||
from item.models import Item
|
||||
qs = Item.objects.filter(itemId=i['item'])
|
||||
qs = Item.objects.filter(public_id=i['item'])
|
||||
if qs.count() > 0:
|
||||
frame = qs[0].frame(i['position'])
|
||||
if frame:
|
||||
|
|
|
@ -159,7 +159,7 @@ def addListItems(request):
|
|||
if 'items' in data:
|
||||
if list.editable(request.user):
|
||||
with transaction.commit_on_success():
|
||||
for item in Item.objects.filter(itemId__in=data['items']):
|
||||
for item in Item.objects.filter(public_id__in=data['items']):
|
||||
list.add(item)
|
||||
response = json_response(status=200, text='items added')
|
||||
else:
|
||||
|
@ -216,7 +216,7 @@ def orderListItems(request):
|
|||
index = 0
|
||||
with transaction.commit_on_success():
|
||||
for i in data['ids']:
|
||||
models.ListItem.objects.filter(list=list, item__itemId=i).update(index=index)
|
||||
models.ListItem.objects.filter(list=list, item__public_id=i).update(index=index)
|
||||
index += 1
|
||||
else:
|
||||
response = json_response(status=403, text='permission denied')
|
||||
|
@ -265,7 +265,7 @@ def addList(request):
|
|||
update_numberoflists.delay(request.user.username)
|
||||
|
||||
if 'items' in data:
|
||||
for item in Item.objects.filter(itemId__in=data['items']):
|
||||
for item in Item.objects.filter(public_id__in=data['items']):
|
||||
list.add(item)
|
||||
|
||||
if list.status == 'featured':
|
||||
|
|
|
@ -128,7 +128,7 @@ def findLogs(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [ox.toAZ(i.id) for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
|
|
@ -16,4 +16,4 @@ def update_file_paths(id):
|
|||
from item.tasks import update_file_paths
|
||||
p = models.Person.objects.get(pk=id)
|
||||
for i in Item.objects.filter(find__value__icontains=p.name).distinct():
|
||||
update_file_paths(i.itemId)
|
||||
update_file_paths(i.public_id)
|
||||
|
|
|
@ -162,7 +162,7 @@ def findNames(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.get_id() for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
|
|
@ -296,7 +296,7 @@ Positions
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.get_id() for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
|
|
@ -46,9 +46,9 @@ def parseCondition(condition, user):
|
|||
return Q()
|
||||
|
||||
if k == 'id':
|
||||
itemId, points = v.split('/')
|
||||
public_id, points = v.split('/')
|
||||
points = [float('%0.03f'%float(p)) for p in points.split('-')]
|
||||
q = Q(sort__item__itemId=itemId, start=points[0], end=points[1])
|
||||
q = Q(sort__item__public_id=public_id, start=points[0], end=points[1])
|
||||
return exclude and ~q or q
|
||||
if k == 'hash':
|
||||
v = models.parse_hash(v)
|
||||
|
|
|
@ -38,7 +38,7 @@ class Sequence(models.Model):
|
|||
|
||||
@property
|
||||
def public_id(self):
|
||||
return u"%s/%0.03f-%0.03f" % (self.sort.item.itemId, float(self.start), float(self.end))
|
||||
return u"%s/%0.03f-%0.03f" % (self.sort.item.public_id, float(self.start), float(self.end))
|
||||
|
||||
def __unicode__(self):
|
||||
return self.public_id
|
||||
|
|
|
@ -8,8 +8,8 @@ import item.models
|
|||
import extract
|
||||
|
||||
@task(ignore_results=True, queue='encoding')
|
||||
def get_sequences(itemId):
|
||||
i = item.models.Item.objects.get(itemId=itemId)
|
||||
def get_sequences(public_id):
|
||||
i = item.models.Item.objects.get(public_id=public_id)
|
||||
models.Sequence.objects.filter(sort=i.sort).delete()
|
||||
position = 0
|
||||
for stream in i.streams():
|
||||
|
|
|
@ -81,7 +81,7 @@ def findSequences(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
qs = order_query(qs, query['sort'])
|
||||
ids = [i['public_id'] for i in qs.values('public_id')]
|
||||
|
@ -109,7 +109,7 @@ def getSequence(request):
|
|||
data = json.loads(request.POST['data'])
|
||||
response = json_response()
|
||||
position = float('%0.03f' % data['position'])
|
||||
i = Item.objects.get(itemId=data['id'])
|
||||
i = Item.objects.get(public_id=data['id'])
|
||||
qs = models.Sequence.objects.filter(
|
||||
sort_id=i.sort.pk,
|
||||
mode=models.Sequence.MODE[data['mode']],
|
||||
|
|
|
@ -229,14 +229,14 @@ class Text(models.Model):
|
|||
poster_frames = []
|
||||
for i in range(0, items.count(), max(1, int(items.count()/4))):
|
||||
poster_frames.append({
|
||||
'item': items[int(i)].itemId,
|
||||
'item': items[int(i)].public_id,
|
||||
'position': items[int(i)].poster_frame
|
||||
})
|
||||
self.poster_frames = tuple(poster_frames)
|
||||
self.save()
|
||||
for i in self.poster_frames:
|
||||
from item.models import Item
|
||||
qs = Item.objects.filter(itemId=i['item'])
|
||||
qs = Item.objects.filter(public_id=i['item'])
|
||||
if qs.count() > 0:
|
||||
frame = qs[0].frame(i['position'])
|
||||
if frame:
|
||||
|
|
|
@ -142,7 +142,7 @@ def findTitles(request):
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.get_id() for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
|
|
@ -85,7 +85,7 @@ class Program(models.Model):
|
|||
def json(self, user, current=False):
|
||||
item_json = self.item.get_json()
|
||||
r = {
|
||||
'item': self.item.itemId,
|
||||
'item': self.item.public_id,
|
||||
}
|
||||
for key in ('title', 'director', 'year', 'durations', 'parts', 'rightslevel'):
|
||||
r[key] = item_json.get(key, '')
|
||||
|
|
|
@ -537,7 +537,7 @@ Positions
|
|||
query = parse_query(data, request.user)
|
||||
qs = order_query(query['qs'], query['sort'])
|
||||
if qs.count() > 0:
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].itemId])[0]
|
||||
response['data']['position'] = utils.get_positions(ids, [qs[0].public_id])[0]
|
||||
elif 'positions' in data:
|
||||
ids = [i.get_id() for i in qs]
|
||||
response['data']['positions'] = utils.get_positions(ids, data['positions'])
|
||||
|
@ -788,7 +788,7 @@ def setUI(request):
|
|||
request.session['ui'] = json.dumps(ui)
|
||||
|
||||
if data.get('item'):
|
||||
item = get_object_or_404_json(Item, itemId=data['item'])
|
||||
item = get_object_or_404_json(Item, public_id=data['item'])
|
||||
if request.user.is_authenticated():
|
||||
access, created = Access.objects.get_or_create(item=item, user=request.user)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue