From c955215c1786853ece84aed588691015b10396ee Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 23 Nov 2010 10:53:12 +0100 Subject: [PATCH] use ox.django, drop python-oxdjango, add Bin/Event/Place --- pandora/api/views.py | 6 +- pandora/app/views.py | 2 +- pandora/archive/migrations/0002_volume.py | 10 +- pandora/archive/migrations/0003_file_time.py | 8 +- pandora/archive/migrations/0004_file_name.py | 8 +- .../archive/migrations/0005_oshash_unique.py | 8 +- .../migrations/0006_addFileContents.py | 8 +- pandora/archive/migrations/0007_stream.py | 8 +- pandora/archive/migrations/0008_available.py | 8 +- .../archive/migrations/0009_rename_movie.py | 8 +- pandora/archive/models.py | 2 +- pandora/archive/views.py | 6 +- pandora/item/models.py | 124 +++++++++++++----- pandora/item/views.py | 6 +- pandora/settings.py | 4 +- pandora/urls.py | 2 +- pandora/user/views.py | 4 +- requirements.txt | 1 - 18 files changed, 140 insertions(+), 83 deletions(-) diff --git a/pandora/api/views.py b/pandora/api/views.py index 68c440ff..b9e68a90 100644 --- a/pandora/api/views.py +++ b/pandora/api/views.py @@ -22,9 +22,9 @@ try: except ImportError: from django.utils import simplejson as json -from oxdjango.decorators import login_required_json -from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response -from oxdjango.http import HttpFileResponse +from ox.django.decorators import login_required_json +from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response +from ox.django.http import HttpFileResponse import ox import models diff --git a/pandora/app/views.py b/pandora/app/views.py index 202a09bf..7c14357f 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -4,7 +4,7 @@ from django.shortcuts import render_to_response, get_object_or_404, get_list_or_ from django.template import RequestContext from django.conf import settings -from oxdjango.shortcuts import json_response, render_to_json_response, get_object_or_404_json +from ox.django.shortcuts import json_response, render_to_json_response, get_object_or_404_json import models diff --git a/pandora/archive/migrations/0002_volume.py b/pandora/archive/migrations/0002_volume.py index 96c8a838..dc6d1ef4 100644 --- a/pandora/archive/migrations/0002_volume.py +++ b/pandora/archive/migrations/0002_volume.py @@ -56,7 +56,7 @@ class Migration(SchemaMigration): db.add_column('archive_file', 'available', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) # Changing field 'File.info' - db.alter_column('archive_file', 'info', self.gf('oxdjango.fields.DictField')()) + db.alter_column('archive_file', 'info', self.gf('ox.django.fields.DictField')()) # Deleting field 'fileinstance.published' db.delete_column('archive_fileinstance', 'published') @@ -184,7 +184,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -281,9 +281,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0003_file_time.py b/pandora/archive/migrations/0003_file_time.py index a3e56fcd..a76174c6 100644 --- a/pandora/archive/migrations/0003_file_time.py +++ b/pandora/archive/migrations/0003_file_time.py @@ -47,7 +47,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -144,9 +144,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0004_file_name.py b/pandora/archive/migrations/0004_file_name.py index ceb624ca..c1e5db26 100644 --- a/pandora/archive/migrations/0004_file_name.py +++ b/pandora/archive/migrations/0004_file_name.py @@ -50,7 +50,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -147,9 +147,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0005_oshash_unique.py b/pandora/archive/migrations/0005_oshash_unique.py index a203a2b9..fa6a0ce0 100644 --- a/pandora/archive/migrations/0005_oshash_unique.py +++ b/pandora/archive/migrations/0005_oshash_unique.py @@ -32,7 +32,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -129,9 +129,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0006_addFileContents.py b/pandora/archive/migrations/0006_addFileContents.py index a083f98c..b1be59e1 100644 --- a/pandora/archive/migrations/0006_addFileContents.py +++ b/pandora/archive/migrations/0006_addFileContents.py @@ -45,7 +45,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -150,9 +150,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0007_stream.py b/pandora/archive/migrations/0007_stream.py index 27ef24f1..882c4e3f 100644 --- a/pandora/archive/migrations/0007_stream.py +++ b/pandora/archive/migrations/0007_stream.py @@ -72,7 +72,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -162,9 +162,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0008_available.py b/pandora/archive/migrations/0008_available.py index 71f068ba..4e56f392 100644 --- a/pandora/archive/migrations/0008_available.py +++ b/pandora/archive/migrations/0008_available.py @@ -33,7 +33,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -122,9 +122,9 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'movieId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), diff --git a/pandora/archive/migrations/0009_rename_movie.py b/pandora/archive/migrations/0009_rename_movie.py index d772cf7a..fd521dfb 100644 --- a/pandora/archive/migrations/0009_rename_movie.py +++ b/pandora/archive/migrations/0009_rename_movie.py @@ -31,7 +31,7 @@ class Migration(SchemaMigration): 'framerate': ('django.db.models.fields.CharField', [], {'max_length': '255'}), 'height': ('django.db.models.fields.IntegerField', [], {'default': '0'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'info': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'info': ('ox.django.fields.DictField', [], {'default': '{}'}), 'is_audio': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_extra': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), 'is_main': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -120,10 +120,10 @@ class Migration(SchemaMigration): 'available': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}), 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'imdb': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'imdb': ('ox.django.fields.DictField', [], {'default': '{}'}), 'itemId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '128', 'blank': 'True'}), - 'json': ('oxdjango.fields.DictField', [], {'default': '{}'}), - 'metadata': ('oxdjango.fields.DictField', [], {'default': '{}'}), + 'json': ('ox.django.fields.DictField', [], {'default': '{}'}), + 'metadata': ('ox.django.fields.DictField', [], {'default': '{}'}), 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), 'oxdbId': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '42', 'blank': 'True'}), 'poster': ('django.db.models.fields.files.ImageField', [], {'default': 'None', 'max_length': '100', 'blank': 'True'}), diff --git a/pandora/archive/models.py b/pandora/archive/models.py index a55f3d38..894b2468 100644 --- a/pandora/archive/models.py +++ b/pandora/archive/models.py @@ -15,7 +15,7 @@ from django.core.files.base import ContentFile from django.utils import simplejson as json from django.conf import settings -from oxdjango import fields +from ox.django import fields import ox from ox import stripTags from ox.normalize import canonicalTitle, canonicalName diff --git a/pandora/archive/views.py b/pandora/archive/views.py index c0777318..7268701d 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -22,9 +22,9 @@ try: except ImportError: from django.utils import simplejson as json -from oxdjango.decorators import login_required_json -from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response -from oxdjango.http import HttpFileResponse +from ox.django.decorators import login_required_json +from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response +from ox.django.http import HttpFileResponse import ox import models diff --git a/pandora/item/models.py b/pandora/item/models.py index faff2828..ec628655 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -18,7 +18,7 @@ from django.core.files.base import ContentFile from django.utils import simplejson as json from django.conf import settings -from oxdjango import fields +from ox.django import fields import ox from ox import stripTags from ox.normalize import canonicalTitle, canonicalName @@ -30,36 +30,19 @@ import utils from archive import extract -class Property(models.Model): +class Bin(models.Model): name = models.CharField(null=True, max_length=255, unique=True) title = models.CharField(null=True, max_length=255) - #types: string, person, role, location, date, array - type = models.CharField(null=True, max_length=255) - array = models.BooleanField(default=False) - position = models.IntegerField(default=0) - - #sort values: title, string, integer, float, date - sort = models.CharField(null=True, max_length=255) - - totals = models.BooleanField(default=False) - admin = models.BooleanField(default=False) - - def json(self): - j = {} - for key in ('type', 'sort', 'title', 'array', 'totals', 'admin'): - value = getattr(self, key) - if value: - j[key] = value - return j - -class Bin(models.Model): - name = models.CharField(null=True, max_length=255, unique=True) - title = models.CharField(null=True, max_length=255) - #types: keyword, location, text + #text, string, string from list(fixme), event, place, person type = models.CharField(null=True, max_length=255) position = models.IntegerField(default=0) overlapping = models.BooleanField(default=True) + enabled = models.BooleanField(default=True) + + enabled = models.BooleanField(default=True) + public = models.BooleanField(default=True) #false=users only see there own bins + subtitle = models.BooleanField(default=True) #bis can be displayed as subtitle, only one bin find = models.BooleanField(default=True) #words / item duration(wpm), total words, cuts per minute, cuts, number of layers, number of layers/duration @@ -263,6 +246,28 @@ def getItem(info): item.save() return item +class ItemProperty(models.Model): + name = models.CharField(null=True, max_length=255, unique=True) + title = models.CharField(null=True, max_length=255) + #text, string, string from list(fixme), event, place, person + type = models.CharField(null=True, max_length=255) + array = models.BooleanField(default=False) + position = models.IntegerField(default=0) + + #sort values: title, string, integer, float, date + sort = models.CharField(null=True, max_length=255) + + totals = models.BooleanField(default=False) + admin = models.BooleanField(default=False) + + def json(self): + j = {} + for key in ('type', 'sort', 'title', 'array', 'totals', 'admin'): + value = getattr(self, key) + if value: + j[key] = value + return j + class Item(models.Model): person_keys = ('director', 'writer', 'producer', 'editor', 'cinematographer', 'actor', 'character') facet_keys = person_keys + ('country', 'language', 'genre', 'keyword') @@ -896,9 +901,14 @@ def getPersonSort(name): class Person(models.Model): name = models.CharField(max_length=200) - imdbId = models.CharField(max_length=7, blank=True) name_sort = models.CharField(max_length=200) + #FIXME: how to deal with aliases + aliases = fields.TupleField(default=[]) + + + imdbId = models.CharField(max_length=7, blank=True) + class Meta: ordering = ('name_sort', ) @@ -928,12 +938,20 @@ class Person(models.Model): def json(self): return self.name -class Location(models.Model): - name = models.CharField(max_length=200, unique=True) - manual = models.BooleanField(default=False) - items = models.ManyToManyField(Item, related_name='locations_all') - #fixme: geo data +class Place(models.Model): + ''' + Places are named locations, they should have geographical information attached to them. + ''' + name = models.CharField(max_length=200, unique=True) + name_sort = models.CharField(max_length=200) + manual = models.BooleanField(default=False) + items = models.ManyToManyField(Item, related_name='places') + + #FIXME: how to deal with aliases + aliases = fields.TupleField(default=[]) + + #FIXME: geo data, is this good enough? lat_sw = models.FloatField(default=0) lng_sw = models.FloatField(default=0) lat_ne = models.FloatField(default=0) @@ -943,7 +961,7 @@ class Location(models.Model): area = models.FloatField(default=-1) class Meta: - ordering = ('name', ) + ordering = ('name_sort', ) def __unicode__(self): return self.name @@ -951,6 +969,46 @@ class Location(models.Model): def json(self): return self.name + def save(self, *args, **kwargs): + if not self.name_sort: + self.name_sort = self.name + + #update center + self.lat_center = ox.location.center(self.lat_sw, self.lat_ne) + self.lng_center = ox.location.center(self.lng_sw, self.lng_ne) + + #update area + self.area = location.area(self.lat_sw, self.lng_sw, self.lat_ne, self.lng_ne) + + super(Place, self).save(*args, **kwargs) + +class Event(models.Model): + ''' + Events are events in time that can be once or recurring, + From Mondays to Spring to 1989 to Roman Empire + ''' + name = models.CharField(null=True, max_length=255, unique=True) + name_sort = models.CharField(null=True, max_length=255, unique=True) + + class Meta: + ordering = ('name_sort', ) + + #FIXME: how to deal with aliases + aliases = fields.TupleField(default=[]) + + #once|year|week|day + recurring = models.IntegerField(default=0) + + #start yyyy-mm-dd|mm-dd|dow 00:00|00:00 + #end yyyy-mm-dd|mm-dd|dow 00:00|00:01 + start = models.CharField(null=True, max_length=255) + end = models.CharField(null=True, max_length=255) + + def save(self, *args, **kwargs): + if not self.name_sort: + self.name_sort = self.name + super(Event, self).save(*args, **kwargs) + class ReviewWhitelist(models.Model): name = models.CharField(max_length=255, unique=True) url = models.CharField(max_length=255, unique=True) @@ -1005,7 +1063,7 @@ class Layer(models.Model): type = models.CharField(blank=True, max_length=255) value = models.TextField() - + #FIXME: relational layers, Locations, clips etc #location = models.ForeignKey('Location', default=None) diff --git a/pandora/item/views.py b/pandora/item/views.py index 6dc469cf..41877d90 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -22,9 +22,9 @@ try: except ImportError: from django.utils import simplejson as json -from oxdjango.decorators import login_required_json -from oxdjango.shortcuts import render_to_json_response, get_object_or_404_json, json_response -from oxdjango.http import HttpFileResponse +from ox.django.decorators import login_required_json +from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response +from ox.django.http import HttpFileResponse import ox import models diff --git a/pandora/settings.py b/pandora/settings.py index 7a423481..f1e4bf63 100644 --- a/pandora/settings.py +++ b/pandora/settings.py @@ -94,8 +94,8 @@ MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'oxdjango.middleware.ExceptionMiddleware', - 'oxdjango.middleware.ChromeFrameMiddleware', + 'ox.django.middleware.ExceptionMiddleware', + 'ox.django.middleware.ChromeFrameMiddleware', ) ROOT_URLCONF = 'pandora.urls' diff --git a/pandora/urls.py b/pandora/urls.py index b2a39754..486c7840 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -3,7 +3,7 @@ import os from django.conf.urls.defaults import * -from oxdjango.http import HttpFileResponse +from ox.django.http import HttpFileResponse from django.conf import settings diff --git a/pandora/user/views.py b/pandora/user/views.py index a8f78a5f..1fadba86 100644 --- a/pandora/user/views.py +++ b/pandora/user/views.py @@ -12,8 +12,8 @@ from django.utils import simplejson as json from django.conf import settings from django.core.mail import send_mail, BadHeaderError -from oxdjango.shortcuts import render_to_json_response, json_response -from oxdjango.decorators import login_required_json +from ox.django.shortcuts import render_to_json_response, json_response +from ox.django.decorators import login_required_json import models diff --git a/requirements.txt b/requirements.txt index eb4ee854..244eddcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,6 @@ South chardet -e bzr+http://code.0x2620.org/python-ox/#egg=python-ox --e bzr+http://code.0x2620.org/python-oxdjango/#egg=python-oxdjango -e bzr+http://code.0x2620.org/oxtimeline/#egg=oxtimeline simplejson #-e hg+https://django-ajax-filtered-fields.googlecode.com/hg/#egg=django-ajax-filtered-fields