From f8849ee3937e64946da58c4165192f3b49c1cfce Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Tue, 11 Feb 2014 10:47:14 +0100 Subject: [PATCH] allow restriction of comments to certain types via type option 'organize.allowcomments' --- organize/comment/browser.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/organize/comment/browser.py b/organize/comment/browser.py index 2179c76..0c576bb 100644 --- a/organize/comment/browser.py +++ b/organize/comment/browser.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2012 Helmut Merz helmutm@cy55.de +# Copyright (c) 2014 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -50,10 +50,17 @@ class CommentsView(NodeView): @Lazy def allowed(self): - if self.isAnonymous: + if self.virtualTargetObject is None: return False - return (self.virtualTargetObject is not None and - self.globalOptions('organize.allowComments')) + opts = (self.globalOptions('organize.allowComments') or + self.typeOptions('organize.allowComments')) + if not opts: + return False + if opts is True: + opts = [] + if self.isAnonymous and not 'all' in opts: + return False + return True @Lazy def addUrl(self):