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)
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):
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):
<textarea style="width:100%" rows="5">
<dc:relation.coverImage.url xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.file.url|build_absolute_uri:request }}</dc:relation.coverImage.url>
<dc:relation.coverImage.attribution xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.author }}, {{ object.license_name }}</dc:relation.coverImage.attribution>
-<dc:relation.coverImage.source xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.get_absolute_url|build_absolute_uri:request }}</dc:relation.coverImage.source>
+<dc:relation.coverImage.source xmlns:dc="http://purl.org/dc/elements/1.1/">{{ object.get_full_url }}</dc:relation.coverImage.source>
</textarea>
{% endblock %}