summaryrefslogtreecommitdiff
path: root/app/utils/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'app/utils/widgets.py')
-rw-r--r--app/utils/widgets.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/app/utils/widgets.py b/app/utils/widgets.py
index 290c7ab..83ac256 100644
--- a/app/utils/widgets.py
+++ b/app/utils/widgets.py
@@ -109,3 +109,41 @@ class OLAdminBase(OSMGeoAdmin):
map_height = 425
map_template = 'gis/admin/osm.html'
openlayers_url = '/static/admin/js/OpenLayers.js'
+
+
+from bs4 import BeautifulSoup
+from photos.models import LuxImage
+from django.template.loader import render_to_string
+from django.template import Context
+
+
+def parse_image(s):
+ soup = BeautifulSoup(s.group(), "lxml")
+ for img in soup.find_all('img'):
+ src = img['src'].split("images/")[1]
+ i = LuxImage.objects.get(image__icontains=src)
+ cl = img['class']
+ caption = False
+ exif = False
+ cluster_class = None
+ if len(cl) > 1:
+ css_class = cl[0]
+ if css_class == 'cluster':
+ cluster_class = cl[1]
+ if cl[1] == 'caption':
+ caption = True
+ if cl[1] == 'exif':
+ exif = True
+ if len(cl) > 2:
+ css_class = cl[0]
+ if cl[1] == 'caption':
+ caption = True
+ if cl[2] == 'exif':
+ exif = True
+ print('caption'+str(caption))
+ else:
+ css_class = cl[0]
+ c = Context({'image': i, 'caption': caption, 'exif': exif, 'cluster_class': cluster_class})
+ return render_to_string("lib/img_%s.html" % css_class, c)
+
+