From bb34923aaeba933001fd377d4f7df7f48dfc3f0b Mon Sep 17 00:00:00 2001
From: Geert Kapteijns <ghkapteijns@gmail.com>
Date: Sat, 25 Feb 2017 20:44:44 +0100
Subject: [PATCH] Do not allow a comment to be created when ThesisLink is not
 open for commenting

---
 comments/views.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/comments/views.py b/comments/views.py
index 4b32e734f..48495af77 100644
--- a/comments/views.py
+++ b/comments/views.py
@@ -37,6 +37,8 @@ def new_comment(request, **kwargs):
                 date_submitted=timezone.now(),
             )
             if type_of_object == "thesislink":
+                if not thesislink.open_for_commenting:
+                    raise PermissionDenied
                 thesislink = ThesisLink.objects.get(id=object_id)
                 new_comment.thesislink = thesislink
                 redirect_link = reverse('theses:thesis', kwargs={"thesislink_id":thesislink.id})
@@ -44,7 +46,6 @@ def new_comment(request, **kwargs):
                 submission = Submission.objects.get(id=object_id)
                 if not submission.open_for_commenting:
                     raise PermissionDenied
-                    
                 new_comment.submission = submission
                 redirect_link = reverse(
                     'submissions:submission',
-- 
GitLab