- if host:
- gallery_url = u'%s%s%s%s/' % (host, settings.MEDIA_URL, settings.IMAGE_DIR, self.slug)
- gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.slug)
- if os.path.isdir(gallery_dir):
- data['gallery_url'] = gallery_url
- attachments = os.listdir(gallery_dir)
- else:
- attachments = []
- data['attachments'] = json.dumps(attachments)
+
+ if not host:
+ host = 'https://' + Site.objects.get_current().domain
+ gallery_url = u'%s%s%s%s/' % (host, settings.MEDIA_URL, settings.IMAGE_DIR, self.gallery)
+ gallery_dir = os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, self.gallery)
+ if os.path.isdir(gallery_dir):
+ data['gallery_url'] = gallery_url
+ attachments = os.listdir(gallery_dir)
+ else:
+ attachments = []
+ data['attachments'] = json.dumps(attachments)
+