From bff8ff8102fe26b61205c444d29024cdf6c9f6e7 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 5 Jul 2012 16:05:07 +0200 Subject: [PATCH] nicer full url for cover --- apps/catalogue/models/book.py | 2 +- apps/cover/models.py | 4 ++++ apps/cover/templates/cover/image_detail.html | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 39f2d0f4..ca389987 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -343,7 +343,7 @@ class Book(models.Model): except: pass else: - if info.cover_source == image.get_absolute_url(): + if info.cover_source == image.get_full_url(): update['dc_cover_image'] = image Book.objects.filter(pk=self.pk).update(**update) diff --git a/apps/cover/models.py b/apps/cover/models.py index 87a70a80..14026ac7 100644 --- a/apps/cover/models.py +++ b/apps/cover/models.py @@ -12,6 +12,7 @@ from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.utils.translation import ugettext_lazy as _ +from django.contrib.sites.models import Site class Image(models.Model): @@ -34,6 +35,9 @@ class Image(models.Model): def get_absolute_url(self): return ('cover_image', [self.id]) + def get_full_url(self): + return "http://%s%s" % (Site.objects.get_current().domain, self.get_absolute_url()) + @receiver(post_save, sender=Image) def download_image(sender, instance, **kwargs): diff --git a/apps/cover/templates/cover/image_detail.html b/apps/cover/templates/cover/image_detail.html index 1509f445..5707b29e 100755 --- a/apps/cover/templates/cover/image_detail.html +++ b/apps/cover/templates/cover/image_detail.html @@ -49,6 +49,6 @@ {% endblock %} -- 2.20.1