From f7269d8df2038b33f81fe6eb56ccd7f4bd36c60b Mon Sep 17 00:00:00 2001 From: Ozzieisaacs <ozzie.fernandez.isaacs@googlemail.com> Date: Tue, 12 May 2020 14:39:13 +0200 Subject: [PATCH] Fix for #1385 (Private shelves are listed twice in the "Add to shelf" dropdown menu) --- cps/templates/detail.html | 4 ++-- cps/templates/search.html | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/cps/templates/detail.html b/cps/templates/detail.html index 8315a8f2..32b215f9 100644 --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -240,7 +240,7 @@ data-remove-href="{{ url_for('shelf.remove_from_shelf', book_id=entry.id, shelf_id=shelf.id) }}" data-shelf-action="add" > - {{shelf.name}} + {{shelf.name}}{% if shelf.is_public == 1 %} {{_('(Public)')}}{% endif %} </a> </li> {% endif %} @@ -257,7 +257,7 @@ > <span {% if not shelf.is_public or g.user.role_edit_shelfs() %} class="glyphicon glyphicon-remove" - {% endif %}></span> {{shelf.name}} + {% endif %}></span> {{shelf.name}}{% if shelf.is_public == 1 %} {{_('(Public)')}}{% endif %} </a> {% endif %} {%endfor%} diff --git a/cps/templates/search.html b/cps/templates/search.html index 28eaf184..fa8176e9 100644 --- a/cps/templates/search.html +++ b/cps/templates/search.html @@ -15,14 +15,11 @@ <span class="caret"></span> </button> <ul id="add-to-shelves" class="dropdown-menu" aria-labelledby="add-to-shelf"> - {% for shelf in g.user.shelf %} - {% if shelf.is_public != 1 %} - <li><a href="{{ url_for('shelf.search_to_shelf', shelf_id=shelf.id) }}"> {{shelf.name}}</a></li> - {% endif %} - {% endfor %} {% for shelf in g.shelves_access %} - <li><a href="{{ url_for('shelf.search_to_shelf', shelf_id=shelf.id) }}">{{shelf.name}}</a></li> - {% endfor %} + {% if not shelf.id in books_shelfs and ( not shelf.is_public or g.user.role_edit_shelfs() ) %} + <li><a href="{{ url_for('shelf.search_to_shelf', shelf_id=shelf.id) }}"> {{shelf.name}}{% if shelf.is_public == 1 %} {{_('(Public)')}}{% endif %}</a></li> + {% endif %} + {%endfor%} </ul> </div> </div> -- 2.18.1