From 07935c570053e6a4cefe07de3967c53c038f4fe3 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Sun, 2 Dec 2018 18:21:22 +0100 Subject: Sheet find: link to baskets --- .../templates/ishtar/blocks/window_find_nav.html | 19 +++++++++++++++++++ archaeological_finds/templates/ishtar/sheet_find.html | 2 +- archaeological_finds/views.py | 13 ++++++++++++- ishtar_common/models.py | 4 ++++ ishtar_common/templates/ishtar/blocks/window_nav.html | 6 ++++-- ishtar_common/templatetags/window_header.py | 12 ++++++++++++ 6 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 archaeological_finds/templates/ishtar/blocks/window_find_nav.html diff --git a/archaeological_finds/templates/ishtar/blocks/window_find_nav.html b/archaeological_finds/templates/ishtar/blocks/window_find_nav.html new file mode 100644 index 000000000..5ecaa35f0 --- /dev/null +++ b/archaeological_finds/templates/ishtar/blocks/window_find_nav.html @@ -0,0 +1,19 @@ +{% extends "ishtar/blocks/window_nav.html" %} +{% load i18n link_to_window %} +{% block post_pin %}{% if baskets %} + +{% endif %}{% endblock %} diff --git a/archaeological_finds/templates/ishtar/sheet_find.html b/archaeological_finds/templates/ishtar/sheet_find.html index 1aa5220bf..ceda2a563 100644 --- a/archaeological_finds/templates/ishtar/sheet_find.html +++ b/archaeological_finds/templates/ishtar/sheet_find.html @@ -4,7 +4,7 @@ {% block head_title %}{% trans "Find" %}{% if item.denomination %} - {{item.denomination|default:""}}{% endif %} - {{item.label|default:""}}{% endblock %} {% block toolbar %} -{% window_nav item window_id 'show-find' 'find_modify' 'show-historized-find' 'revert-find' previous next 1 %} +{% window_find_nav item window_id 'show-find' 'find_modify' 'show-historized-find' 'revert-find' previous next 1 baskets %} {% endblock %} {% block content %} diff --git a/archaeological_finds/views.py b/archaeological_finds/views.py index 620f33ef4..a04d7fe2f 100644 --- a/archaeological_finds/views.py +++ b/archaeological_finds/views.py @@ -112,7 +112,18 @@ def autocomplete_treatmentfile(request): return HttpResponse(data, content_type='text/plain') -show_find = show_item(models.Find, 'find') +def show_find_extra(request, find): + if not request.user or not request.user.ishtaruser: + return {} + user = request.user.ishtaruser + q = models.FindBasket.objects.filter(items__pk=find.pk).filter( + Q(user=user) | Q(shared_with__pk=user.pk) | + Q(shared_write_with__pk=user.pk) + ) + return {"baskets": [(basket.pk, basket.full_label) for basket in q.all()]} + + +show_find = show_item(models.Find, 'find', extra_dct=show_find_extra) display_find = display_item(models.Find) revert_find = revert_item(models.Find) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index b6c8fbb3d..70f65fd68 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3477,6 +3477,10 @@ class Basket(FullSearch, OwnPerms): def cached_label(self): return unicode(self) + @property + def full_label(self): + return u"{} - {}".format(self.label, self.user) + @classmethod def get_short_menu_class(cls, pk): return 'basket' diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html index 6cd4bff40..90d58d605 100644 --- a/ishtar_common/templates/ishtar/blocks/window_nav.html +++ b/ishtar_common/templates/ishtar/blocks/window_nav.html @@ -27,9 +27,9 @@ {% endif %} -
+
{% else %} -
+
{% endif %} {% if pin_action and item.SLUG %}
+ {% block post_pin %} + {% endblock %}
{% endif %}
diff --git a/ishtar_common/templatetags/window_header.py b/ishtar_common/templatetags/window_header.py index f6fc27082..e6325d3fb 100644 --- a/ishtar_common/templatetags/window_header.py +++ b/ishtar_common/templatetags/window_header.py @@ -32,6 +32,18 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='', 'pin_action': pin_action} +@register.inclusion_tag('ishtar/blocks/window_find_nav.html', + takes_context=True) +def window_find_nav(context, item, window_id, show_url, modify_url='', + histo_url='', revert_url='', previous=None, nxt=None, + pin_action=False, baskets=None): + dct = window_nav(context, item, window_id, show_url, modify_url=modify_url, + histo_url=histo_url, revert_url=revert_url, + previous=previous, nxt=nxt, pin_action=pin_action) + dct['baskets'] = baskets + return dct + + @register.inclusion_tag('ishtar/blocks/window_file_nav.html', takes_context=True) def window_file_nav(context, item, window_id, previous=None, nxt=None): -- cgit v1.2.3