poster url is unique
This commit is contained in:
parent
f6c44a68a7
commit
6e9110eb42
2 changed files with 65 additions and 1 deletions
64
oxdata/poster/migrations/0003_poster_url_unique.py
Normal file
64
oxdata/poster/migrations/0003_poster_url_unique.py
Normal file
|
@ -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']
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue