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
|
|
@ -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('/'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue