Insert a divider between still-out dry hires and actually upcoming events on rigboard

This commit is contained in:
2020-08-27 17:38:26 +01:00
parent 828964ecb6
commit de04498517
2 changed files with 17 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
{% load next from filters %}
{% comment %}<div class="d-none d-md-block">{% endcomment %}
<div class="table-responsive">
<table class="table mb-0">
@@ -90,9 +91,13 @@
{% endif %}
</td>
</tr>
{# 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 %}<tr><td colspan="4"><hr></td><tr>{%endif%}
{% endwith %}
{% empty %}
<tr class="bg-warning">
<td colspan="6">No events found</td>
<td colspan="4">No events found</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -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