# HG changeset patch # User durandn # Date 1476359503 -7200 # Node ID b67ea0d6c621e0b416829f31ac0ad7865487124e # Parent b7e752e2e6694462c84ba88f685ca70095c97df5 search page design and item preview for multiple images #36 diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/models.py --- a/src/iconolab/models.py Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/models.py Thu Oct 13 13:51:43 2016 +0200 @@ -125,6 +125,10 @@ return str(self.image_guid)+":"+self.name @property + def wh_ratio(self): + return self.width / self.height + + @property def collection(self): return self.item.collection.name diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/search_indexes/forms.py --- a/src/iconolab/search_indexes/forms.py Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/search_indexes/forms.py Thu Oct 13 13:51:43 2016 +0200 @@ -1,16 +1,18 @@ from django import forms from haystack.forms import SearchForm -from iconolab.models import Item, Annotation +from iconolab.models import Item, Annotation, Collection class IconolabSearchForm(SearchForm): - model_type = forms.ChoiceField(required=False, choices=(("images","Image"), ("annotations","Annotation")) ) + model_type = forms.ChoiceField(required=False, choices=(("images","Images"), ("annotations","Annotations")) ) def __init__(self, *args, **kwargs): self.collection_name = kwargs.pop("collection_name") + if self.collection_name and Collection.objects.filter(name=self.collection_name).exists(): + self.collection = Collection.objects.get(name=self.collection_name) selected_model_type = kwargs.pop("model_type", None) if selected_model_type is not None: diff -r b7e752e2e669 -r b67ea0d6c621 src/iconolab/templates/iconolab/collection_home.html --- a/src/iconolab/templates/iconolab/collection_home.html Wed Oct 12 15:06:53 2016 +0200 +++ b/src/iconolab/templates/iconolab/collection_home.html Thu Oct 13 13:51:43 2016 +0200 @@ -186,67 +186,7 @@
- {% if item.images.count > 1 %} - {% with item.images.first as main_image %} - {% if main_image.height > main_image.width %} -