mirror of
https://github.com/suitenumerique/docs.git
synced 2026-10-18 22:13:44 +02:00
✨(migration) export management command also exports mentions
Export mentions of users in documents, and whether they've already been notified by email Signed-off-by: Mathieu Agopian <mathieu@agopian.info>
This commit is contained in:
@@ -49,6 +49,13 @@ try:
|
||||
except ImportError:
|
||||
_HAS_RECONCILIATION = False
|
||||
|
||||
try:
|
||||
from core.models import Mention
|
||||
|
||||
_HAS_MENTION = True
|
||||
except ImportError:
|
||||
_HAS_MENTION = False
|
||||
|
||||
try:
|
||||
from zoneinfo import ZoneInfo as _ZoneInfo
|
||||
except ImportError:
|
||||
@@ -105,6 +112,8 @@ class Command(BaseCommand):
|
||||
self._export_threads(stream)
|
||||
self._export_comments(stream)
|
||||
self._export_reactions(stream)
|
||||
if _HAS_MENTION:
|
||||
self._export_mentions(stream)
|
||||
|
||||
def _progress(self, label, count, done=False):
|
||||
"""Overwrite the current stderr line with an incrementing count."""
|
||||
@@ -279,3 +288,14 @@ class Command(BaseCommand):
|
||||
count += 1
|
||||
self._progress("reaction users", count)
|
||||
self._progress("reaction users", count, done=True)
|
||||
|
||||
def _export_mentions(self, stream):
|
||||
"""Export all concrete Mention fields."""
|
||||
self.stderr.write("Exporting mentions...")
|
||||
count = 0
|
||||
for mention in Mention.objects.order_by("created_at").values().iterator():
|
||||
pk = mention.pop("id")
|
||||
_write(stream, "core.mention", pk, mention)
|
||||
count += 1
|
||||
self._progress("mentions", count)
|
||||
self._progress("mentions", count, done=True)
|
||||
|
||||
Reference in New Issue
Block a user