diff options
Diffstat (limited to 'app/jrnl')
-rw-r--r-- | app/jrnl/models.py | 12 | ||||
-rw-r--r-- | app/jrnl/views.py | 5 |
2 files changed, 12 insertions, 5 deletions
diff --git a/app/jrnl/models.py b/app/jrnl/models.py index ceaefa6..2fc775e 100644 --- a/app/jrnl/models.py +++ b/app/jrnl/models.py @@ -37,15 +37,16 @@ def image_url_replace(s): def parse_image(s): soup = BeautifulSoup(s.group(), "lxml") for img in soup.find_all('img'): - print(img) src = img['src'].split("images/")[1] - print(src) 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': @@ -59,7 +60,7 @@ def parse_image(s): print('caption'+str(caption)) else: css_class = cl[0] - c = Context({'image': i, 'caption': caption, 'exif': exif}) + c = Context({'image': i, 'caption': caption, 'exif': exif, 'cluster_class': cluster_class}) return render_to_string("lib/img_%s.html" % css_class, c) @@ -72,7 +73,10 @@ def extract_images(s): soup = BeautifulSoup(s, "lxml") imgs = [] for img in soup.find_all('img'): - imgs.append(img['src']) + try: + imgs.append(img['src']) + except: + pass return imgs diff --git a/app/jrnl/views.py b/app/jrnl/views.py index c68625d..6d0e85b 100644 --- a/app/jrnl/views.py +++ b/app/jrnl/views.py @@ -7,6 +7,7 @@ from django.conf import settings from utils.views import PaginatedListView from .models import Entry, HomepageCurrator +from daily.models import CheckIn from locations.models import Country, Region @@ -84,7 +85,8 @@ class HomepageList(ListView): Return a main entry and list of Entries in reverse chronological order """ context_object_name = 'recent' - queryset = Entry.objects.filter(status__exact=1)[:5] + exclude = HomepageCurrator.objects.get(pk=1) + queryset = Entry.objects.filter(status__exact=1).exclude(pk=exclude.featured.pk)[:8] def get_template_names(self): obj = HomepageCurrator.objects.get(pk=1) @@ -94,6 +96,7 @@ class HomepageList(ListView): # Call the base implementation first to get a context context = super(HomepageList, self).get_context_data(**kwargs) context['homepage'] = HomepageCurrator.objects.get(pk=1) + context['location'] = CheckIn.objects.get(pk=1) context['IMAGES_URL'] = settings.IMAGES_URL return context |