nicer full url for cover
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 5 Jul 2012 14:05:07 +0000 (16:05 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 5 Jul 2012 14:05:07 +0000 (16:05 +0200)
apps/catalogue/models/book.py
apps/cover/models.py
apps/cover/templates/cover/image_detail.html

index 39f2d0f..ca38998 100755 (executable)
@@ -343,7 +343,7 @@ class Book(models.Model):
                 except:
                     pass
                 else:
                 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)
 
                         update['dc_cover_image'] = image
         Book.objects.filter(pk=self.pk).update(**update)
 
index 87a70a8..14026ac 100644 (file)
@@ -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.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):
 
 
 class Image(models.Model):
@@ -34,6 +35,9 @@ class Image(models.Model):
     def get_absolute_url(self):
         return ('cover_image', [self.id])
 
     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):
 
 @receiver(post_save, sender=Image)
 def download_image(sender, instance, **kwargs):
index 1509f44..5707b29 100755 (executable)
@@ -49,6 +49,6 @@
 <textarea style="width:100%" rows="5">
 &lt;dc:relation.coverImage.url xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.file.url|build_absolute_uri:request }}&lt;/dc:relation.coverImage.url>
 &lt;dc:relation.coverImage.attribution xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.author }}, {{ object.license_name }}&lt;/dc:relation.coverImage.attribution>
 <textarea style="width:100%" rows="5">
 &lt;dc:relation.coverImage.url xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.file.url|build_absolute_uri:request }}&lt;/dc:relation.coverImage.url>
 &lt;dc:relation.coverImage.attribution xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.author }}, {{ object.license_name }}&lt;/dc:relation.coverImage.attribution>
-&lt;dc:relation.coverImage.source xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.get_absolute_url|build_absolute_uri:request }}&lt;/dc:relation.coverImage.source>
+&lt;dc:relation.coverImage.source xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.get_full_url }}&lt;/dc:relation.coverImage.source>
 </textarea>
 {% endblock %}
 </textarea>
 {% endblock %}