From de044985170e4c677684f1d46ceab304488782d2 Mon Sep 17 00:00:00 2001 From: FreneticScribbler Date: Thu, 27 Aug 2020 17:38:26 +0100 Subject: [PATCH] Insert a divider between still-out dry hires and actually upcoming events on rigboard --- RIGS/templates/event_table.html | 7 ++++++- RIGS/templatetags/filters.py | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/RIGS/templates/event_table.html b/RIGS/templates/event_table.html index 94968fae..5fe01a2c 100644 --- a/RIGS/templates/event_table.html +++ b/RIGS/templates/event_table.html @@ -1,3 +1,4 @@ +{% load next from filters %} {% comment %}
{% endcomment %}
@@ -90,9 +91,13 @@ {% endif %} + {# Insert a divider between still-out dry hires and actually upcoming events #} + {% with next_element=events|next:forloop.counter0 %} + {% if event.dry_hire == True and next_element.dry_hire == False %}{%endif%} + {% endwith %} {% empty %} - + {% endfor %} diff --git a/RIGS/templatetags/filters.py b/RIGS/templatetags/filters.py index aaa6ac3c..f95ff0f6 100644 --- a/RIGS/templatetags/filters.py +++ b/RIGS/templatetags/filters.py @@ -149,3 +149,14 @@ def get_json_element(value, element): def get_item(dictionary, key): if(type(dictionary) is dict): return dictionary.get(key) + +@register.filter +def next(alist, current_index): + """ + Returns the next element of the list using the current index if it exists. + Otherwise returns an empty string. + """ + try: + return alist[int(current_index) + 1] # access the next element + except: + return '' # return empty string in case of exception

No events foundNo events found