# HG changeset patch # User Alexandre Segura # Date 1495033567 -7200 # Node ID 1bae3da99830d1328272d61c52a0453994273737 # Parent 4e18e1f69db92ec23afd6279c1ca4257494fb29a Display bookmarked images. diff -r 4e18e1f69db9 -r 1bae3da99830 src/iconolab/models.py --- a/src/iconolab/models.py Wed May 17 16:38:08 2017 +0200 +++ b/src/iconolab/models.py Wed May 17 17:06:07 2017 +0200 @@ -192,6 +192,9 @@ for tag_infos in revision_tags if tag_infos.get('tag_label') is not None] # deal with return tag_list + def is_bookmarked_by(self, user): + return Bookmark.objects.filter(image=self, category__user=user).count() > 0 + class ImageStats(models.Model): """ diff -r 4e18e1f69db9 -r 1bae3da99830 src/iconolab/templates/iconolab/collection_home.html --- a/src/iconolab/templates/iconolab/collection_home.html Wed May 17 16:38:08 2017 +0200 +++ b/src/iconolab/templates/iconolab/collection_home.html Wed May 17 17:06:07 2017 +0200 @@ -208,6 +208,10 @@ var $target = $(e.currentTarget); + if ($target.hasClass('active')) { + return; + } + $modal.find('.bookmark-title').val($target.data('item')); $modal.find('.bookmark-image').val($target.data('image-id')); diff -r 4e18e1f69db9 -r 1bae3da99830 src/iconolab/templates/partials/item_images_preview.html --- a/src/iconolab/templates/partials/item_images_preview.html Wed May 17 16:38:08 2017 +0200 +++ b/src/iconolab/templates/partials/item_images_preview.html Wed May 17 17:06:07 2017 +0200 @@ -1,4 +1,5 @@ {% load thumbnail %} +{% load iconolab_tags %}
@@ -10,11 +11,16 @@ {% endthumbnail %} - + {% endif %}
{% if item.images.count > 1 %} diff -r 4e18e1f69db9 -r 1bae3da99830 src/iconolab/templatetags/iconolab_tags.py --- a/src/iconolab/templatetags/iconolab_tags.py Wed May 17 16:38:08 2017 +0200 +++ b/src/iconolab/templatetags/iconolab_tags.py Wed May 17 17:06:07 2017 +0200 @@ -73,3 +73,8 @@ if request.resolver_match.url_name in routes: return 'container-fluid' return 'container' + +@register.assignment_tag(takes_context=True) +def is_bookmarked(context, image): + request = context['request'] + return image.is_bookmarked_by(request.user) diff -r 4e18e1f69db9 -r 1bae3da99830 src_js/iconolab-bundle/src/iconolab.scss --- a/src_js/iconolab-bundle/src/iconolab.scss Wed May 17 16:38:08 2017 +0200 +++ b/src_js/iconolab-bundle/src/iconolab.scss Wed May 17 17:06:07 2017 +0200 @@ -53,6 +53,9 @@ &:active { color: darken(#E67E22, 10%); } + &.active { + color: #3498DB; + } } } .item-image-stats {