migrate to django 1.9
This commit is contained in:
parent
f7855147ce
commit
e5dd8aaab7
48 changed files with 659 additions and 848 deletions
|
|
@ -5,10 +5,7 @@ from __future__ import division
|
|||
import os.path
|
||||
import hashlib
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.files.base import ContentFile
|
||||
|
||||
from lookup.models import MovieId
|
||||
|
|
@ -43,6 +40,9 @@ def cover_path(url, filename):
|
|||
name = "%s.%s" % (h, ext)
|
||||
return os.path.join('covers', h[:2], h[2:4], h[4:6], name)
|
||||
|
||||
def covercache_image_path(i, f):
|
||||
return cover_path(i.url.encode('utf-8'), f)
|
||||
|
||||
class CoverCache(models.Model):
|
||||
class Meta:
|
||||
unique_together = ("isbn", "url")
|
||||
|
|
@ -54,7 +54,7 @@ class CoverCache(models.Model):
|
|||
url = models.CharField(max_length=1024)
|
||||
site = models.CharField(max_length=255)
|
||||
site_id = models.CharField(max_length=42)
|
||||
image = models.ImageField(max_length=255, upload_to=lambda i, f: cover_path(i.url.encode('utf-8'), f))
|
||||
image = models.ImageField(max_length=255, upload_to=covercache_image_path)
|
||||
status = models.CharField(max_length=1024, default='200')
|
||||
failed = models.BooleanField(default=False)
|
||||
|
||||
|
|
@ -89,10 +89,13 @@ class CoverCache(models.Model):
|
|||
self.image.delete()
|
||||
return self.image
|
||||
|
||||
def cover_image_path(i, f):
|
||||
return cover_path('upload/%s' % i.id, f)
|
||||
|
||||
class Cover(models.Model):
|
||||
created = models.DateTimeField(auto_now_add=True)
|
||||
modified = models.DateTimeField(auto_now=True)
|
||||
|
||||
isbn = models.ForeignKey(MovieId, related_name='cover')
|
||||
cover = models.ImageField(max_length=255, upload_to=lambda i, f: cover_path('upload/%s' % i.id, f))
|
||||
cover = models.ImageField(max_length=255, upload_to=cover_image_path)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue