summaryrefslogtreecommitdiff
path: root/app/lib
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-08-07 21:50:48 -0400
committerluxagraf <sng@luxagraf.net>2020-08-07 21:50:48 -0400
commitd456f97a4e00605b13150b8e02467013fd84f33c (patch)
tree6a13ea82fccba282a379d58e2a963297dcdbd635 /app/lib
parentfe912293dcd912cac7f24a488b4faf8f5b275de7 (diff)
added a class name to pad fieldnotes amidst photos
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/templatetags/templatetags/get_next.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/lib/templatetags/templatetags/get_next.py b/app/lib/templatetags/templatetags/get_next.py
new file mode 100644
index 0000000..97159f5
--- /dev/null
+++ b/app/lib/templatetags/templatetags/get_next.py
@@ -0,0 +1,25 @@
+from django import template
+
+register = template.Library()
+
+@register.filter
+def next(some_list, current_index):
+ """
+ Returns the next element of the list using the current index if it exists.
+ Otherwise returns an empty string.
+ """
+ try:
+ return some_list[int(current_index) + 1] # access the next element
+ except:
+ return '' # return empty string in case of exception
+
+@register.filter
+def previous(some_list, current_index):
+ """
+ Returns the previous element of the list using the current index if it exists.
+ Otherwise returns an empty string.
+ """
+ try:
+ return some_list[int(current_index) - 1] # access the previous element
+ except:
+ return '' # return empty string in case of exception