From 6e9110eb4293a3e30c036953b393ddaf2da79436 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 9 Aug 2010 18:51:24 +0200 Subject: [PATCH] poster url is unique --- .../migrations/0003_poster_url_unique.py | 64 +++++++++++++++++++ oxdata/poster/models.py | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 oxdata/poster/migrations/0003_poster_url_unique.py diff --git a/oxdata/poster/migrations/0003_poster_url_unique.py b/oxdata/poster/migrations/0003_poster_url_unique.py new file mode 100644 index 0000000..c087fbb --- /dev/null +++ b/oxdata/poster/migrations/0003_poster_url_unique.py @@ -0,0 +1,64 @@ +# encoding: utf-8 +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + +class Migration(SchemaMigration): + + def forwards(self, orm): + + # Adding unique constraint on 'PosterCache', fields ['url'] + db.create_unique('poster_postercache', ['url']) + + + def backwards(self, orm): + + # Removing unique constraint on 'PosterCache', fields ['url'] + db.delete_unique('poster_postercache', ['url']) + + + models = { + 'lookup.movieid': { + 'Meta': {'object_name': 'MovieId'}, + 'amg_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'criterion_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'director': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}), + 'episode': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), + 'episode_title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'imdb_id': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '7', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'impawards_id': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'oxdb_id': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '42', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'season': ('django.db.models.fields.IntegerField', [], {'default': '-1'}), + 'series_title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1000', 'blank': 'True'}), + 'wikipedia_id': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'unique': 'True', 'null': 'True', 'blank': 'True'}), + 'year': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '4', 'blank': 'True'}) + }, + 'poster.poster': { + 'Meta': {'object_name': 'Poster'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'movie_id': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'poster'", 'to': "orm['lookup.MovieId']"}), + 'poster': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}) + }, + 'poster.postercache': { + 'Meta': {'object_name': 'PosterCache'}, + 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}), + 'failed': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '255'}), + 'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}), + 'movie_id': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'postercache'", 'to': "orm['lookup.MovieId']"}), + 'site': ('django.db.models.fields.CharField', [], {'max_length': '255'}), + 'site_id': ('django.db.models.fields.CharField', [], {'max_length': '42'}), + 'status': ('django.db.models.fields.CharField', [], {'default': "'200'", 'max_length': '1024'}), + 'url': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '1024'}) + } + } + + complete_apps = ['poster'] diff --git a/oxdata/poster/models.py b/oxdata/poster/models.py index e495a18..b3ab891 100644 --- a/oxdata/poster/models.py +++ b/oxdata/poster/models.py @@ -52,7 +52,7 @@ class PosterCache(models.Model): modified = models.DateTimeField(auto_now=True) movie_id = models.ForeignKey(MovieId, related_name='postercache') - url = models.CharField(max_length=1024) + url = models.CharField(max_length=1024, unique=True) site = models.CharField(max_length=255) site_id = models.CharField(max_length=42) image = models.ImageField(max_length=255, upload_to=lambda i, f: poster_path(i.url.encode('utf-8'), f))