From e65a63795cfc918b3565593571625e47ebbd17f2 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Sat, 29 Jul 2017 08:26:21 +0200
Subject: [PATCH] Slight edits

---
 comments/factories.py | 8 ++++----
 comments/models.py    | 8 +++++++-
 comments/views.py     | 7 -------
 3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/comments/factories.py b/comments/factories.py
index d74370a13..1f76cf6a4 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 b87966c4a..5a2a4a644 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 6f7ba0632..fba5791ba 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)
-- 
GitLab