From 4c379693c52688489ed1133a0ebcd330a346e8f0 Mon Sep 17 00:00:00 2001
From: George Katsikas <giorgakis.katsikas@gmail.com>
Date: Wed, 24 Apr 2024 12:05:11 +0200
Subject: [PATCH] add absolute urls in formatted tex files

---
 .../management/commands/advance_git_repos.py     | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/scipost_django/production/management/commands/advance_git_repos.py b/scipost_django/production/management/commands/advance_git_repos.py
index d7734b624..9d8efe67a 100644
--- a/scipost_django/production/management/commands/advance_git_repos.py
+++ b/scipost_django/production/management/commands/advance_git_repos.py
@@ -368,6 +368,12 @@ class Command(BaseCommand):
             """
             return date.strftime("%d-%m-%Y")
 
+        def format_relative_url(url: str) -> str:
+            """
+            Format a relative URL to an absolute one by adding the domain.
+            """
+            return f"https://{get_current_domain()}{url}"
+
         project = self.GL.projects.get(repo.git_path)
         project_filenames = list(
             map(lambda x: x["path"], project.repository_tree(get_all=True))
@@ -412,10 +418,16 @@ class Command(BaseCommand):
 
             collection_replacements_dict = {
                 "<|COLLECTION_NAME|>": (lambda _: collection.name, None),
-                "<|COLLECTION_URL|>": (lambda _: collection.get_absolute_url(), None),
+                "<|COLLECTION_URL|>": (
+                    format_relative_url,
+                    collection.get_absolute_url(),
+                ),
                 "<|EVENT_DETAILS|>": (lambda _: collection.event_details, None),
                 "<|SERIES_NAME|>": (lambda _: series.name, None),
-                "<|SERIES_URL|>": (lambda _: series.get_absolute_url(), None),
+                "<|SERIES_URL|>": (
+                    format_relative_url,
+                    series.get_absolute_url(),
+                ),
             }
 
             replacements_dict.update(collection_replacements_dict)
-- 
GitLab