From 1b1df7455173f9aba451e32c0410df669a50fce3 Mon Sep 17 00:00:00 2001
From: Jorran de Wit <jorrandewit@outlook.com>
Date: Fri, 13 Oct 2017 08:12:20 +0200
Subject: [PATCH] Fix comment on Report wrongly assigned as author reply

---
 comments/views.py | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/comments/views.py b/comments/views.py
index 021b7f730..e4c909d39 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -129,12 +129,18 @@ def reply_to_comment(request, comment_id):
     comment = get_object_or_404(Comment, pk=comment_id)
 
     # Verify if this is from an author:
-    try:
-        # Submission/Commentary
-        is_author = comment.content_object.authors.filter(id=request.user.contributor.id).exists()
-    except AttributeError:
+    related_object = comment.content_object
+    if isinstance(related_object, Submission) or isinstance(related_object, Commentary):
+        is_author = related_object.authors.filter(id=request.user.contributor.id).exists()
+    elif isinstance(related_object, Report):
+        is_author = related_object.submission.authors.filter(
+            id=request.user.contributor.id).exists()
+    elif isinstance(related_object, ThesisLink):
         # ThesisLink
-        is_author = comment.content_object.author == request.user.contributor
+        is_author = related_object.author == request.user.contributor
+    else:
+        # No idea what this could be, but just to be sure
+        is_author = related_object.author == request.user.contributor
 
     form = CommentForm(request.POST or None, request.FILES or None)
     if form.is_valid():
-- 
GitLab