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 ++++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 archaeological_finds/templates/ishtar/blocks/window_find_nav.html (limited to 'archaeological_finds') 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) -- cgit v1.2.3