update to django 1.2.x, local urls, add suggested path

This commit is contained in:
j 2010-08-07 18:48:10 +02:00
parent 38fe412cb5
commit 7b74c5f2ec
4 changed files with 32 additions and 2 deletions

View file

@ -8,6 +8,7 @@ from django.db.models import Q, Max
from django.contrib.auth.models import User
import ox
from ox.normalize import canonicalName
from ox import stripTags
import ox.web.imdb
import ox.web.wikipedia
@ -107,6 +108,18 @@ class MovieId(models.Model):
self.oxdb_id = u"0x" + oxid
self.save()
def suggested_path(self):
if self.series_title:
title = self.series_title
return os.path.join('S', 'Series', title)
else:
directors = '; '.join(map(canonicalName, self.director.split(', ')))
if not directors: directors = "Unknown Director"
title = self.title
if self.year:
title += ' (%s)' % self.year
return os.path.join(directors[0], directors, title)
def json(self):
json = {}
keys = [
@ -128,7 +141,11 @@ class MovieId(models.Model):
json[key] = value
if 'director' in json:
json['directors'] = json.pop('director').split(', ')
if 'year' in json and json['year']: json['year'] = int(json['year'])
if 'year' in json and json['year']:
json['year'] = int(json['year'])
json['suggested_path'] = self.suggested_path()
return json

View file

@ -13,6 +13,12 @@ from oxdata.lookup.models import MovieId
import models
def get_movie_id(request):
if 'movieId' in request.GET:
movieId = request.GET['movieId']
if len(movieId) == 7:
movie_id = MovieId.objects.get(imdb_id=imdbId)
else:
movie_id = MovieId.objects.get(oxdb_id=oxdbId)
if 'imdb' in request.GET:
imdbId = request.GET['imdb']
movie_id = MovieId.objects.get(imdb_id=imdbId)

View file

@ -24,3 +24,10 @@ if settings.DEBUG:
)
#load local urls if present
try:
from local_urls import urlpatterns
except ImportError:
pass

View file

@ -1,4 +1,4 @@
-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.1.X/#egg=django
-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.2.X/#egg=django
South==0.6.1
-e bzr+http://code.0x2620.org/python-oxdjango/#egg=python-oxdjango
-e bzr+http://code.0x2620.org/python-ox/#egg=python-ox