Skip to content

Commit

Permalink
update taggeditems of Forum migrated into Document
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 25, 2024
1 parent 4f84325 commit b99f60b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import sys

from django.contrib.contenttypes.models import ContentType
from django.core.management.base import BaseCommand
from taggit.models import TaggedItem

from lacommunaute.documentation.models import Category, Document
from lacommunaute.forum.models import Forum
Expand All @@ -26,8 +28,10 @@ def create_categories_from_catforums():
def create_document_from_forums(category_transpo_dict):
# TODO next :
# add redirections when get_absolute_url is setup
# migrate UpVotes and TaggedItems
# migrate UpVotes

forum_content_type = ContentType.objects.get_for_model(Forum)
document_content_type = ContentType.objects.get_for_model(Document)
transpo_dict = {}

for forum in Forum.objects.filter(parent__type=1):
Expand All @@ -40,6 +44,9 @@ def create_document_from_forums(category_transpo_dict):
partner=forum.partner,
certified=forum.certified,
)
TaggedItem.objects.filter(content_type=forum_content_type, object_id=forum.id).update(
content_type=document_content_type, object_id=document.id
)
transpo_dict[forum] = document

return transpo_dict
Expand Down

0 comments on commit b99f60b

Please sign in to comment.