2
2
from django.contrib.comments.models import Comment, FreeComment
3
3
from threadedcomments.models import ThreadedComment, FreeThreadedComment
5
6
class Command(BaseCommand):
6
7
help = "Migrates Django's built-in django.contrib.comments data to threadedcomments data"
8
9
output_transaction = True
10
11
def handle(self, *args, **options):
12
Converts all legacy ``Comment`` and ``FreeComment`` objects into
13
``ThreadedComment`` and ``FreeThreadedComment`` objects, respectively.
12
"""Converts all legacy ``Comment`` and ``FreeComment`` objects into
13
``ThreadedComment`` and ``FreeThreadedComment`` objects,
15
15
self.handle_free_comments()
16
16
self.handle_comments()
18
18
def handle_free_comments(self):
20
Converts all legacy ``FreeComment`` objects into ``FreeThreadedComment``
19
"""Converts all legacy ``FreeComment`` objects into
20
``FreeThreadedComment`` objects."""
23
21
comments = FreeComment.objects.all()
25
23
new = FreeThreadedComment(
26
content_type = c.content_type,
27
object_id = c.object_id,
32
date_submitted = c.submit_date,
33
date_modified = c.submit_date,
34
date_approved = c.submit_date,
35
is_public = c.is_public,
36
ip_address = c.ip_address,
37
is_approved = c.approved
24
content_type=c.content_type,
25
object_id=c.object_id,
30
date_submitted=c.submit_date,
31
date_modified=c.submit_date,
32
date_approved=c.submit_date,
33
is_public=c.is_public,
34
ip_address=c.ip_address,
35
is_approved=c.approved
41
39
def handle_comments(self):
43
Converts all legacy ``Comment`` objects into ``ThreadedComment`` objects.
40
"""Converts all legacy ``Comment`` objects into ``ThreadedComment``
45
42
comments = Comment.objects.all()
47
44
new = ThreadedComment(
48
content_type = c.content_type,
49
object_id = c.object_id,
52
date_submitted = c.submit_date,
53
date_modified = c.submit_date,
54
date_approved = c.submit_date,
55
is_public = c.is_public,
56
ip_address = c.ip_address,
57
is_approved = not c.is_removed
45
content_type=c.content_type,
46
object_id=c.object_id,
49
date_submitted=c.submit_date,
50
date_modified=c.submit_date,
51
date_approved=c.submit_date,
52
is_public=c.is_public,
53
ip_address=c.ip_address,
54
is_approved=not c.is_removed
b'\\ No newline at end of file'