add static files, allow title/director lookup, update to python-ox

This commit is contained in:
j 2011-04-06 17:49:33 +02:00
parent f9745b38f3
commit ce32be91a6
9 changed files with 38 additions and 11 deletions

View File

@ -7,7 +7,7 @@ from django.contrib.auth.models import User
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
from oxdjango.shortcuts import render_to_json_response
from ox.django.shortcuts import render_to_json_response
import models

View File

@ -63,7 +63,7 @@ class MovieId(models.Model):
id = self.imdb_id
if not id:
id = self.id
return '%s (%s)' % (self.title, id)
return u'%s (%s)' % (self.title, id)
def updateFromWikipedia(self):
if self.wikipedia_id:
@ -84,7 +84,7 @@ class MovieId(models.Model):
setattr(self, key, data.get(key, ''))
directors = data.get('directors', [])
self.director = ', '.join(directors)
self.director = u', '.join(directors)
if not self.wikipedia_id:
self.wikipedia_id = ox.web.wikipedia.getId(ox.web.wikipedia.getUrlByImdb(self.imdb_id))
if not self.wikipedia_id:
@ -153,4 +153,3 @@ class MovieId(models.Model):
return json

View File

@ -5,7 +5,7 @@ from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User
from oxdjango.shortcuts import render_to_json_response
from ox.django.shortcuts import render_to_json_response
import models
@ -39,9 +39,21 @@ def get_movie_id(request):
def ids(request):
json = {}
movie = get_movie_id(request)
if movie:
json = movie.json()
if 'title' in request.GET:
title = request.GET['title']
director = request.GET.get('director', '')
year = request.GET.get('year', '')
movies = models.MovieId.objects.filter(title=title)
if director:
movies = movies.filter(director=director)
if year:
movies = movies.filter(year=year)
if movies.count() == 1:
json = movies[0].json()
else:
movie = get_movie_id(request)
if movie:
json = movie.json()
return render_to_json_response(json)
def urls(request):

0
oxdata/manage.py Normal file → Executable file
View File

View File

@ -7,7 +7,7 @@ from django.contrib.auth.models import User
from django.shortcuts import render_to_response, get_object_or_404, get_list_or_404
from django.template import RequestContext
from oxdjango.shortcuts import render_to_json_response
from ox.django.shortcuts import render_to_json_response
from oxdata.lookup.models import MovieId
from oxdata.lookup.views import get_movie_id

BIN
oxdata/static/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

2
oxdata/static/robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

View File

@ -1,16 +1,31 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
from django.conf.urls.defaults import *
from ox.django.http import HttpFileResponse
from django.conf import settings
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
def serve_static_file(path, location, content_type):
return HttpFileResponse(location, content_type=content_type)
urlpatterns = patterns('',
(r'^$', 'oxdata.views.index'),
(r'^poster/', include('oxdata.poster.urls')),
(r'^still/$', 'oxdata.poster.views.still'),
(r'^id/', include('oxdata.lookup.urls')),
(r'^robots.txt$', serve_static_file, {
'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'),
'content_type': 'text/plain'
}),
(r'^favicon.ico$', serve_static_file, {
'location': os.path.join(settings.STATIC_ROOT, 'favicon.ico'),
'content_type': 'image/x-icon'}),
# Uncomment the next line to enable the admin:
(r'^admin/(.*)', admin.site.root),
)

View File

@ -1,6 +1,5 @@
-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.2.X/#egg=django
-e svn+http://code.djangoproject.com/svn/django/branches/releases/1.3.X/#egg=django
South
-e bzr+http://code.0x2620.org/python-oxdjango/#egg=python-oxdjango
-e bzr+http://code.0x2620.org/python-ox/#egg=python-ox
chardet
django-celery