datetime handled by ox.django now, set default posterframe
This commit is contained in:
parent
228c612fff
commit
7fa5bb309a
4 changed files with 12 additions and 48 deletions
|
@ -108,8 +108,8 @@ class Annotation(models.Model):
|
|||
'in': self.start,
|
||||
'out': self.end,
|
||||
'value': self.value,
|
||||
'created': self.created.strftime('%Y-%m-%dT%H:%M:%SZ'),
|
||||
'modified': self.modified.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
'created': self.created,
|
||||
'modified': self.modified
|
||||
}
|
||||
|
||||
def __unicode__(self):
|
||||
|
|
|
@ -225,8 +225,18 @@ class Item(models.Model):
|
|||
self.update_find()
|
||||
self.update_sort()
|
||||
self.update_facets()
|
||||
update_poster = False
|
||||
if not settings.USE_IMDB:
|
||||
if self.poster_frame == -1 and self.sort.duration:
|
||||
self.poster_frame = self.sort.duration/2
|
||||
update_poster = True
|
||||
if not self.get('runtime', None) and self.sort.duration:
|
||||
self.data['runtime'] = self.sort.duration
|
||||
self.update_sort()
|
||||
self.json = self.get_json()
|
||||
super(Item, self).save(*args, **kwargs)
|
||||
if update_poster:
|
||||
tasks.update_poster.delay(self.itemId)
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
self.delete_poster()
|
||||
|
@ -258,40 +268,6 @@ class Item(models.Model):
|
|||
self.delete()
|
||||
other.save()
|
||||
|
||||
'''
|
||||
JSON cache related functions
|
||||
'''
|
||||
#FIXME: this should not be used
|
||||
_public_fields = {
|
||||
'itemId': 'id',
|
||||
'title': 'title',
|
||||
'year': 'year',
|
||||
|
||||
'runtime': 'runtime',
|
||||
'releasedate': 'releasedate',
|
||||
|
||||
'country': 'country',
|
||||
'director': 'director',
|
||||
'writer': 'writer',
|
||||
'editor': 'editor',
|
||||
'producer': 'producer',
|
||||
'cinematographer': 'cinematographer',
|
||||
'language': 'language',
|
||||
'genre': 'genre',
|
||||
'keyword': 'keyword',
|
||||
'cast': 'cast',
|
||||
'series_title': 'series_title',
|
||||
'episode_title': 'episode_title',
|
||||
'season': 'season',
|
||||
'episode': 'episode',
|
||||
'reviews': 'reviews',
|
||||
'trivia': 'trivia',
|
||||
'rating': 'rating',
|
||||
'votes': 'votes',
|
||||
'alternative_titles': 'alternative_titles',
|
||||
'connections_json': 'connections',
|
||||
}
|
||||
|
||||
def get_poster(self):
|
||||
poster = {}
|
||||
poster['width'] = self.poster_width
|
||||
|
@ -374,12 +350,6 @@ class Item(models.Model):
|
|||
if value:
|
||||
i[key] = value
|
||||
|
||||
#format datetime values
|
||||
# #FIXME: do this in render_tojson
|
||||
for key in i:
|
||||
if isinstance(i[key], datetime):
|
||||
i[key] = i[key].strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
i['poster'] = self.get_poster()
|
||||
i['posters'] = self.get_posters()
|
||||
return i
|
||||
|
|
|
@ -206,8 +206,6 @@ Positions
|
|||
r[p] = m.sort.popularity
|
||||
else:
|
||||
r[p] = m.json.get(p, '')
|
||||
if isinstance(r[p], datetime):
|
||||
r[p] = r[p].strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
return r
|
||||
def only_p(m):
|
||||
r = {}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from __future__ import division, with_statement
|
||||
from datetime import datetime
|
||||
from django.db import models
|
||||
|
||||
import ox
|
||||
|
@ -62,9 +61,6 @@ class Place(models.Model):
|
|||
'south', 'west', 'north', 'east',
|
||||
'lat', 'lng', 'size'):
|
||||
j[key] = getattr(self, key)
|
||||
|
||||
if isinstance(j[key], datetime):
|
||||
j[key] = j[key].strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||
return j
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
|
Loading…
Reference in a new issue