summaryrefslogtreecommitdiff
path: root/ishtar_common/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/views.py')
-rw-r--r--ishtar_common/views.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index ba9be495a..a49dc7aee 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -1181,16 +1181,22 @@ class ChangelogView(IshtarMixin, LoginRequiredMixin, TemplateView):
page_number = int(kwargs.get("page", 0) or 0) or 1
if page_number == 1:
self.update_read_version()
- changelog_file = os.path.join(changelog_dir, f"changelog_{page_number}.md")
- if not os.path.exists(changelog_file):
+ list_dir = list([fle for fle in os.listdir(changelog_dir)
+ if fle.startswith("changelog_") and fle.endswith(".md")])
+ current_file = ""
+ for idx, fle in enumerate(reversed(sorted(list_dir))):
+ if (idx + 1) == page_number:
+ current_file = fle
+ break
+ if not current_file:
raise Http404()
+ changelog_file = os.path.join(changelog_dir, current_file)
with open(changelog_file, "r") as changelog:
context["changelog"] = markdown(changelog.read())
if page_number > 1:
context["next"] = page_number - 1
- changelog_file_next = os.path.join(changelog_dir, f"changelog_{page_number + 1}.md")
- if os.path.exists(changelog_file_next):
+ if len(list_dir) > page_number:
context["previous"] = page_number + 1
return context