get_json -> json

This commit is contained in:
j 2018-06-20 00:03:01 +02:00
parent 910d95f9b2
commit 0d0770802c
4 changed files with 15 additions and 15 deletions

View file

@ -584,7 +584,7 @@ class Document(models.Model):
def referenced(self): def referenced(self):
result = {} result = {}
result['items'] = [ result['items'] = [
i.get_json(keys=['id', 'title']) i.json(keys=['id', 'title'])
for i in self.items.all().order_by('sort__title') for i in self.items.all().order_by('sort__title')
] ]
result['annotations'] = [ result['annotations'] = [

View file

@ -425,7 +425,7 @@ class Item(models.Model):
self.poster_width = 80 self.poster_width = 80
self.update_sort() self.update_sort()
self.update_languages() self.update_languages()
self.cache = self.get_json() self.cache = self.json()
self.cache['modified'] = datetime.now() self.cache['modified'] = datetime.now()
super(Item, self).save(*args, **kwargs) super(Item, self).save(*args, **kwargs)
self.update_find() self.update_find()
@ -582,7 +582,7 @@ class Item(models.Model):
documents = [d.json(item=self) for d in qs] documents = [d.json(item=self) for d in qs]
return sorted(documents, key=lambda d: d['index']) return sorted(documents, key=lambda d: d['index'])
def get_json(self, keys=None): def json(self, keys=None):
i = { i = {
'id': self.public_id, 'id': self.public_id,
'rendered': self.rendered, 'rendered': self.rendered,
@ -700,7 +700,7 @@ class Item(models.Model):
def get_item_description_html(self): def get_item_description_html(self):
description = '' description = ''
data = self.get_json() data = self.json()
info = [] info = []
for key in [ for key in [
'director', 'writer', 'producer', 'director', 'writer', 'producer',
@ -1360,7 +1360,7 @@ class Item(models.Model):
if offset: if offset:
self.data['volume'] /= offset self.data['volume'] /= offset
# extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8]) # extract.timeline_strip(self, self.data['cuts'], stream.info, self.timeline_prefix[:-8])
self.cache = self.get_json() self.cache = self.json()
self.update_sort() self.update_sort()
self.select_frame() self.select_frame()
self.make_poster() self.make_poster()
@ -1376,7 +1376,7 @@ class Item(models.Model):
tasks.load_subtitles.delay(self.public_id) tasks.load_subtitles.delay(self.public_id)
def update_cache(self, **kwargs): def update_cache(self, **kwargs):
self.cache = self.get_json() self.cache = self.json()
Item.objects.filter(id=self.id).update(cache=self.cache, **kwargs) Item.objects.filter(id=self.id).update(cache=self.cache, **kwargs)
def save_poster(self, data): def save_poster(self, data):

View file

@ -207,7 +207,7 @@ def get_items(request, query):
items = [] items = []
qs = _order_query(query['qs'], query['sort']) qs = _order_query(query['qs'], query['sort'])
qs = qs[query['range'][0]:query['range'][1]] qs = qs[query['range'][0]:query['range'][1]]
# items = [m.get_json(_p) for m in qs] # items = [m.json(_p) for m in qs]
if any(p for p in query['keys'] if p in item_sort_keys): if any(p for p in query['keys'] if p in item_sort_keys):
qs = qs.select_related() qs = qs.select_related()
items = [only_p_sums(request, query, m) for m in qs] items = [only_p_sums(request, query, m) for m in qs]
@ -415,7 +415,7 @@ def findId(request, data):
qs = models.Item.objects.filter(public_id=data['id']) qs = models.Item.objects.filter(public_id=data['id'])
if qs.count() == 1: if qs.count() == 1:
response['data']['items'] = [ response['data']['items'] = [
i.get_json(['title', 'director', 'year', 'id']) for i in qs i.json(['title', 'director', 'year', 'id']) for i in qs
] ]
if not response['data']['items'] \ if not response['data']['items'] \
@ -509,7 +509,7 @@ def get(request, data):
data['keys'] = data.get('keys', []) data['keys'] = data.get('keys', [])
item = get_object_or_404_json(models.Item, public_id=data['id']) item = get_object_or_404_json(models.Item, public_id=data['id'])
if item.access(request.user): if item.access(request.user):
info = item.get_json(data['keys']) info = item.json(data['keys'])
if not data['keys'] or 'stream' in data['keys']: if not data['keys'] or 'stream' in data['keys']:
info['stream'] = item.get_stream() info['stream'] = item.get_stream()
if not data['keys'] or 'streams' in data['keys']: if not data['keys'] or 'streams' in data['keys']:
@ -602,7 +602,7 @@ def add(request, data):
del data['title'] del data['title']
if data: if data:
response = edit_item(request, item, data) response = edit_item(request, item, data)
response['data'] = item.get_json() response['data'] = item.json()
add_changelog(request, request_data, item.public_id) add_changelog(request, request_data, item.public_id)
return render_to_json_response(response) return render_to_json_response(response)
actions.register(add, cache=False) actions.register(add, cache=False)
@ -626,7 +626,7 @@ def edit(request, data):
if item.editable(request.user): if item.editable(request.user):
request_data = data.copy() request_data = data.copy()
response = edit_item(request, item, data) response = edit_item(request, item, data)
response['data'] = item.get_json() response['data'] = item.json()
add_changelog(request, request_data) add_changelog(request, request_data)
else: else:
response = json_response(status=403, text='permission denied') response = json_response(status=403, text='permission denied')
@ -881,7 +881,7 @@ def poster(request, id, size=None):
poster_height=item.poster_height, poster_height=item.poster_height,
poster_width=item.poster_width, poster_width=item.poster_width,
icon=item.icon.name, icon=item.icon.name,
json=item.get_json() json=item.json()
) )
if item.poster and os.path.exists(item.poster.path): if item.poster and os.path.exists(item.poster.path):
return image_to_response(item.poster, size) return image_to_response(item.poster, size)
@ -1304,7 +1304,7 @@ def item_json(request, id):
response = json_response(status=404, text='not found') response = json_response(status=404, text='not found')
else: else:
item = qs[0] item = qs[0]
response = item.get_json() response = item.json()
response['layers'] = item.get_layers(request.user) response['layers'] = item.get_layers(request.user)
return render_to_json_response(response) return render_to_json_response(response)
@ -1318,7 +1318,7 @@ def item_xml(request, id):
response = render_to_json_response(response) response = render_to_json_response(response)
else: else:
item = qs[0] item = qs[0]
j = item.get_json() j = item.json()
j['layers'] = item.get_layers(request.user) j['layers'] = item.get_layers(request.user)
if 'resolution' in j: if 'resolution' in j:
j['resolution'] = {'width': j['resolution'][0], 'height': j['resolution'][1]} j['resolution'] = {'width': j['resolution'][0], 'height': j['resolution'][1]}

View file

@ -87,7 +87,7 @@ class Program(models.Model):
return u"%s %s" % (self.item, self.start) return u"%s %s" % (self.item, self.start)
def json(self, user, current=False): def json(self, user, current=False):
item_json = self.item.get_json() item_json = self.item.json()
r = { r = {
'item': self.item.public_id, 'item': self.item.public_id,
} }