summaryrefslogtreecommitdiff
path: root/archaeological_finds
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-12-02 18:21:22 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-12-02 18:22:49 +0100
commit07935c570053e6a4cefe07de3967c53c038f4fe3 (patch)
tree4c4068c6c37f9abd19f5220d9f793e37a21fd8b3 /archaeological_finds
parentad8bc7234067d65751892005973def88d12bcc2c (diff)
downloadIshtar-07935c570053e6a4cefe07de3967c53c038f4fe3.tar.bz2
Ishtar-07935c570053e6a4cefe07de3967c53c038f4fe3.zip
Sheet find: link to baskets
Diffstat (limited to 'archaeological_finds')
-rw-r--r--archaeological_finds/templates/ishtar/blocks/window_find_nav.html19
-rw-r--r--archaeological_finds/templates/ishtar/sheet_find.html2
-rw-r--r--archaeological_finds/views.py13
3 files changed, 32 insertions, 2 deletions
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 %}
+<div class="dropdown btn-secondary">
+ <button class="btn btn-sm btn-secondary dropdown-toggle" type="button"
+ id="dropdownMenuButton" data-toggle="dropdown"aria-haspopup="true" aria-expanded="false">
+ <i class="fa fa-shopping-basket"></i> {% trans "Baskets" %}
+ </button>
+ <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+ {% for basket_id, lbl in baskets %}
+ <a class="dropdown-item" href="#"
+ onclick="load_window('{% url 'show-findbasket' basket_id %}')">
+ <i class="fa fa-info-circle display_details" aria-hidden="true"></i>
+ {{lbl}}
+ </a>
+ {% endfor %}
+ </div>
+</div>
+{% 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 %}<strong>{% trans "Find" %}</strong>{% 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)