use __str__ no need for u'' anymore
This commit is contained in:
parent
a569629373
commit
2f5f0dc864
6 changed files with 24 additions and 24 deletions
|
@ -63,11 +63,11 @@ class MovieId(models.Model):
|
||||||
|
|
||||||
#movieposterdb can be mapped via imdbid and does not need to be saved here
|
#movieposterdb can be mapped via imdbid and does not need to be saved here
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
id = self.imdb_id
|
id = self.imdb_id
|
||||||
if not id:
|
if not id:
|
||||||
id = self.id
|
id = self.id
|
||||||
return u'%s (%s)' % (self.title, id)
|
return '%s (%s)' % (self.title, id)
|
||||||
|
|
||||||
def updateFromWikipedia(self):
|
def updateFromWikipedia(self):
|
||||||
if self.wikipedia_id:
|
if self.wikipedia_id:
|
||||||
|
@ -91,7 +91,7 @@ class MovieId(models.Model):
|
||||||
}.get(key, key), data.get(key, ''))
|
}.get(key, key), data.get(key, ''))
|
||||||
|
|
||||||
directors = data.get('director', [])
|
directors = data.get('director', [])
|
||||||
self.director = u', '.join(directors)
|
self.director = ', '.join(directors)
|
||||||
if not self.wikipedia_id:
|
if not self.wikipedia_id:
|
||||||
self.wikipedia_id = ox.web.wikipedia.get_id(ox.web.wikipedia.get_url(imdb=self.imdb_id))
|
self.wikipedia_id = ox.web.wikipedia.get_id(ox.web.wikipedia.get_url(imdb=self.imdb_id))
|
||||||
if not self.wikipedia_id:
|
if not self.wikipedia_id:
|
||||||
|
@ -168,7 +168,7 @@ class MovieId(models.Model):
|
||||||
'source': 'Internet Archive',
|
'source': 'Internet Archive',
|
||||||
'url': ox.web.archive.get_url(self.archiveorg_id).replace('http://', 'https://')
|
'url': ox.web.archive.get_url(self.archiveorg_id).replace('http://', 'https://')
|
||||||
})
|
})
|
||||||
qs = u'"%s (%s)"'%(self.title, self.year)
|
qs = '"%s (%s)"' % (self.title, self.year)
|
||||||
links.append({
|
links.append({
|
||||||
'source': 'Google',
|
'source': 'Google',
|
||||||
'url': 'https://google.com/search?q=%s' % quote(qs.encode('utf-8'))
|
'url': 'https://google.com/search?q=%s' % quote(qs.encode('utf-8'))
|
||||||
|
|
|
@ -45,7 +45,7 @@ def find(info, guess=True):
|
||||||
fkey = key
|
fkey = key
|
||||||
if isinstance(info[key], list):
|
if isinstance(info[key], list):
|
||||||
fkey = '%s__iexact'%key
|
fkey = '%s__iexact'%key
|
||||||
value = normalize_value(u'\n'.join(info[key]) + '\n')
|
value = normalize_value('\n'.join(info[key]) + '\n')
|
||||||
else:
|
else:
|
||||||
value = normalize_value(info[key])
|
value = normalize_value(info[key])
|
||||||
q = q.filter(**{fkey:value})
|
q = q.filter(**{fkey:value})
|
||||||
|
@ -83,8 +83,8 @@ class Imdb(models.Model):
|
||||||
invalid = models.BooleanField(default=False)
|
invalid = models.BooleanField(default=False)
|
||||||
patch = DictField(default=None, blank=True, null=True)
|
patch = DictField(default=None, blank=True, null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return u"[%s] %s%s" % (self.imdb, self.title, self.year and ' (%s)' % self.year or '')
|
return "[%s] %s%s" % (self.imdb, self.title, self.year and ' (%s)' % self.year or '')
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
super(Imdb, self).save(*args, **kwargs)
|
super(Imdb, self).save(*args, **kwargs)
|
||||||
|
@ -120,7 +120,7 @@ class Imdb(models.Model):
|
||||||
if key in info:
|
if key in info:
|
||||||
value = info[key]
|
value = info[key]
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
value = u'\n'.join(value) + '\n'
|
value = '\n'.join(value) + '\n'
|
||||||
if isinstance(value, string_types):
|
if isinstance(value, string_types):
|
||||||
value = normalize_value(value)
|
value = normalize_value(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
@ -285,7 +285,7 @@ class Match(models.Model):
|
||||||
key = models.CharField(max_length=28, db_index=True)
|
key = models.CharField(max_length=28, db_index=True)
|
||||||
item = models.ForeignKey(Imdb, related_name='matches')
|
item = models.ForeignKey(Imdb, related_name='matches')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return '%s(%s)' % (self.hexdigest(), self.item.imdb)
|
return '%s(%s)' % (self.hexdigest(), self.item.imdb)
|
||||||
|
|
||||||
def json(self):
|
def json(self):
|
||||||
|
|
|
@ -110,7 +110,7 @@ class ApiActions(dict):
|
||||||
fc = filter(lambda c: hasattr(c.cell_contents, '__call__'), f.func_closure)
|
fc = filter(lambda c: hasattr(c.cell_contents, '__call__'), f.func_closure)
|
||||||
f = fc[len(fc)-1].cell_contents
|
f = fc[len(fc)-1].cell_contents
|
||||||
info = f.func_code.co_filename[len(settings.PROJECT_ROOT)+1:]
|
info = f.func_code.co_filename[len(settings.PROJECT_ROOT)+1:]
|
||||||
info = u'%s:%s' % (info, f.func_code.co_firstlineno)
|
info = '%s:%s' % (info, f.func_code.co_firstlineno)
|
||||||
return info, trim(inspect.getsource(f))
|
return info, trim(inspect.getsource(f))
|
||||||
|
|
||||||
def register(self, method, action=None, cache=True, version=None):
|
def register(self, method, action=None, cache=True, version=None):
|
||||||
|
|
|
@ -24,7 +24,7 @@ def _to_json(python_object):
|
||||||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||||
if isinstance(python_object, datetime_safe.datetime):
|
if isinstance(python_object, datetime_safe.datetime):
|
||||||
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
return python_object.strftime('%Y-%m-%dT%H:%M:%SZ')
|
||||||
raise TypeError(u'%s %s is not JSON serializable' % (repr(python_object), type(python_object)))
|
raise TypeError('%s %s is not JSON serializable' % (repr(python_object), type(python_object)))
|
||||||
|
|
||||||
def render_to_json_response(dictionary, content_type="text/json", status=200):
|
def render_to_json_response(dictionary, content_type="text/json", status=200):
|
||||||
indent = None
|
indent = None
|
||||||
|
|
|
@ -76,8 +76,8 @@ class PosterCache(models.Model):
|
||||||
status = models.CharField(max_length=1024, default='200')
|
status = models.CharField(max_length=1024, default='200')
|
||||||
failed = models.BooleanField(default=False)
|
failed = models.BooleanField(default=False)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __str__(self):
|
||||||
return u'%s' % self.url
|
return '%s' % self.url
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
if not self.image and not self.failed:
|
if not self.image and not self.failed:
|
||||||
|
|
|
@ -147,17 +147,17 @@ BROKER_URL = 'amqp://oxdata:ox@localhost:5672//odata'
|
||||||
|
|
||||||
#Movie related settings
|
#Movie related settings
|
||||||
REVIEW_WHITELIST = {
|
REVIEW_WHITELIST = {
|
||||||
u'.filmcritic.com': u'Filmcritic',
|
'.filmcritic.com': 'Filmcritic',
|
||||||
u'metacritic.com': u'Metacritic',
|
'metacritic.com': 'Metacritic',
|
||||||
u'nytimes.com': u'New York Times',
|
'nytimes.com': 'New York Times',
|
||||||
u'rottentomatoes.com': u'Rotten Tomatoes',
|
'rottentomatoes.com': 'Rotten Tomatoes',
|
||||||
u'salon.com': u'Salon.com',
|
'salon.com': 'Salon.com',
|
||||||
u'sensesofcinema.com': u'Senses of Cinema',
|
'sensesofcinema.com': 'Senses of Cinema',
|
||||||
u'villagevoice.com': u'Village Voice',
|
'villagevoice.com': 'Village Voice',
|
||||||
u'washingtonpost.com': u'Washington Post',
|
'washingtonpost.com': 'Washington Post',
|
||||||
u'rogerebert.suntimes.com': u'Chicago Sun-Times',
|
'rogerebert.suntimes.com': 'Chicago Sun-Times',
|
||||||
u'sfgate.com': u'San Francisco Chronicle',
|
'sfgate.com': 'San Francisco Chronicle',
|
||||||
u'rollingstone.com': u'Rolling Stone'
|
'rollingstone.com': 'Rolling Stone'
|
||||||
}
|
}
|
||||||
|
|
||||||
#overwrite default settings with local settings
|
#overwrite default settings with local settings
|
||||||
|
|
Loading…
Reference in a new issue