diff options
| -rw-r--r-- | archaeological_finds/templates/ishtar/blocks/window_find_nav.html | 19 | ||||
| -rw-r--r-- | archaeological_finds/templates/ishtar/sheet_find.html | 2 | ||||
| -rw-r--r-- | archaeological_finds/views.py | 13 | ||||
| -rw-r--r-- | ishtar_common/models.py | 4 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/blocks/window_nav.html | 6 | ||||
| -rw-r--r-- | ishtar_common/templatetags/window_header.py | 12 | 
6 files changed, 52 insertions, 4 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) 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 %}      </div>    </div> -  <div class='offset-md-6 col-md-4 text-right'> +  <div class='offset-md-4 col-md-6 text-right'>    {% else %} -  <div class='offset-md-8 col-md-4 text-right'> +  <div class='offset-md-6 col-md-6 text-right'>    {% endif %}        {% if pin_action and item.SLUG %}        <div class="btn-group btn-group-sm" role="group" @@ -38,6 +38,8 @@               onclick='$.get("{% url "pin" item.SLUG item.pk %}", function(){load_shortcut_menu(); display_info("{% trans 'Item pined in your shortcut menu.' %}")});' title="{% trans 'Pin' %}">                <i class="fa fa-thumb-tack"></i>            </a> +          {% block post_pin %} +          {% endblock %}        </div>        {% endif %}        <div class="btn-group btn-group-sm" role="group" aria-label="{% trans 'Actions' %}"> 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): | 
