diff --git a/comments/factories.py b/comments/factories.py index d74370a136d4a140fd82e8f6d060acf6497526b4..1f76cf6a460001cb60077d1d5e73bdf075dd2c6a 100644 --- a/comments/factories.py +++ b/comments/factories.py @@ -31,16 +31,16 @@ class CommentFactory(factory.django.DjangoModelFactory): class CommentaryCommentFactory(CommentFactory): - commentary = factory.SubFactory(VettedCommentaryFactory) + content_object = factory.SubFactory(VettedCommentaryFactory) class SubmissionCommentFactory(CommentFactory): - submission = factory.SubFactory(EICassignedSubmissionFactory) + content_object = factory.SubFactory(EICassignedSubmissionFactory) class ThesislinkCommentFactory(CommentFactory): - thesislink = factory.SubFactory(VettedThesisLinkFactory) + content_object = factory.SubFactory(VettedThesisLinkFactory) class ReplyCommentFactory(CommentFactory): - in_reply_to_comment = factory.SubFactory(SubmissionCommentFactory) + content_object = factory.SubFactory(SubmissionCommentFactory) diff --git a/comments/models.py b/comments/models.py index b87966c4a1fde9da681d26bec6b8cb30cd6c0169..5a2a4a6443366e04ccee9b8571f57ad837fd98e9 100644 --- a/comments/models.py +++ b/comments/models.py @@ -38,6 +38,9 @@ class Comment(TimeStampedModel): nested_comments = GenericRelation('comments.Comment', related_query_name='comments') + # -- U/S + # These fields will be removed in the future. + # They still exists only to prevent possible data loss. commentary = models.ForeignKey('commentaries.Commentary', blank=True, null=True, on_delete=models.CASCADE, help_text=US_NOTICE) submission = models.ForeignKey('submissions.Submission', blank=True, null=True, @@ -45,12 +48,15 @@ class Comment(TimeStampedModel): help_text=US_NOTICE) thesislink = models.ForeignKey('theses.ThesisLink', blank=True, null=True, on_delete=models.CASCADE, help_text=US_NOTICE) - is_author_reply = models.BooleanField(default=False) in_reply_to_comment = models.ForeignKey('self', blank=True, null=True, related_name="nested_comments_old", on_delete=models.CASCADE, help_text=US_NOTICE) in_reply_to_report = models.ForeignKey('submissions.Report', blank=True, null=True, on_delete=models.CASCADE, help_text=US_NOTICE) + # -- End U/S + + # Author info + is_author_reply = models.BooleanField(default=False) author = models.ForeignKey('scipost.Contributor', on_delete=models.CASCADE) anonymous = models.BooleanField(default=False, verbose_name='Publish anonymously') diff --git a/comments/views.py b/comments/views.py index 6f7ba06328944714a463bf18079d627f261e7af9..fba5791ba8e8a1b212eee8660dc77d77b7f32bb0 100644 --- a/comments/views.py +++ b/comments/views.py @@ -131,13 +131,6 @@ def reply_to_comment(request, comment_id): # ThesisLink is_author = comment.content_object.author == request.user.contributor - # if comment.submission and not is_author: - # is_author = comment.submission.authors.filter(id=request.user.contributor.id).exists() - # if comment.commentary and not is_author: - # is_author = comment.commentary.authors.filter(id=request.user.contributor.id).exists() - # if comment.thesislink and not is_author: - # is_author = comment.thesislink.author == request.user.contributor - form = CommentForm(request.POST or None, request.FILES or None) if form.is_valid(): newcomment = form.save(commit=False)