From 30dceff1d37ddb178a8d5d0457b5878e0d561538 Mon Sep 17 00:00:00 2001
From: Helge Jung <hej@c3pb.de>
Date: Tue, 14 Nov 2023 20:25:52 +0100
Subject: [PATCH] housekeeping: import wiki namespaces from upstream

---
 src/core/management/commands/housekeeping.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/core/management/commands/housekeeping.py b/src/core/management/commands/housekeeping.py
index b9b5c9bf2..90e081ff6 100644
--- a/src/core/management/commands/housekeeping.py
+++ b/src/core/management/commands/housekeeping.py
@@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand, CommandError
 from django.db.models import Max
 from django.utils import timezone
 
+from ...models import StaticPageNamespace
 from ...models.conference import Conference, ConferenceExportCache
 from ...models.messages import DirectMessage
 from ...models.schedules import ScheduleSource, ScheduleSourceImport
@@ -20,6 +21,7 @@ class Command(BaseCommand):
         self._housekeeping_vouchers()
         self._housekeeping_scheduleimports()
         self._housekeeping_exportcache()
+        self._housekeeping_wikimports()
 
     def _housekeeping_directmessages(self):
         # clear all direct messages which are after their expiry date
@@ -99,6 +101,12 @@ class Command(BaseCommand):
 
         print('Flagged', changed, 'out of', total, 'cached exports for regeneration.')
 
+    def _housekeeping_wikimports(self):
+        for c in Conference.objects.all():
+            for ns in StaticPageNamespace.objects.filter(conference=c).exclude(upstream_url__isnull=True).all():
+                print(f'Importing "{c.slug}" wiki namespace "{ns.prefix}" ...')
+                ns.fetch_upstream()
+
     def handle(self, *args, **options):
         # call _do_housekeeping repeatedly (unless --forever is not set)
         forever = options.get('forever')
-- 
GitLab