add links

This commit is contained in:
j 2011-10-30 13:31:04 +01:00
parent 35e44c1041
commit 4d958067fe
2 changed files with 21 additions and 0 deletions

View file

@ -119,6 +119,19 @@ class MovieId(models.Model):
folder = stripAccents(directors[0].upper())[0] folder = stripAccents(directors[0].upper())[0]
return os.path.join(folder, normalizePath(directors), normalizePath(title)) return os.path.join(folder, normalizePath(directors), normalizePath(title))
def links(self):
links = []
if self.imdb_id:
links.append({'source': 'IMDb',
'url': ox.web.imdb.getUrl(self.imdb_id)})
if self.wikipedia_id:
links.append({'source': 'Wikipedia',
'url': ox.web.wikipedia.getUrl(self.wikipedia_id)})
if self.criterion_id:
links.append({'source': 'Criterion',
'url': ox.web.criterion.getUrl(self.criterion_id)})
return links
def json(self): def json(self):
json = {} json = {}
keys = [ keys = [

View file

@ -20,6 +20,13 @@ def posters(request, imdbId):
movie_id = getMovieIdByImdbId(imdb_id=imdbId) movie_id = getMovieIdByImdbId(imdb_id=imdbId)
return getPosters(movie_id, request.build_absolute_uri('/')) return getPosters(movie_id, request.build_absolute_uri('/'))
def links(request, imdbId):
movie_id = getMovieIdByImdbId(imdb_id=imdbId)
links = []
if movie_id:
links = movie_id.links()
return links
def getId(request): def getId(request):
data = json.loads(request.POST['data']) data = json.loads(request.POST['data'])
response = json_response() response = json_response()
@ -73,6 +80,7 @@ def getData(request):
del data['reviews'] del data['reviews']
data['posters'] = posters(request, id) data['posters'] = posters(request, id)
data['links'] = links(request, id)
response['data'] = data response['data'] = data
else: else: