From cf523df2eb6e7b696c693e68b449a2c541bbaa67 Mon Sep 17 00:00:00 2001 From: jordan Date: Wed, 6 Jul 2011 08:56:06 +0000 Subject: [PATCH] OSQA-497, adding a new settings that allows to specify whether the permissions to close and reopen question (by the author) should be unified or not. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1104 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/models/user.py | 12 +++++++++++- forum/settings/minrep.py | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/forum/models/user.py b/forum/models/user.py index 6ee7f66..84801fb 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -362,7 +362,17 @@ class User(BaseModel, DjangoUser): @true_if_is_super_or_staff def can_reopen_question(self, question): - return self == question.author and self.reputation >= int(settings.REP_TO_REOPEN_OWN) + # Check whether the setting to Unify close and reopen permissions has been activated + if bool(settings.UNIFY_PERMISSIONS_TO_CLOSE_AND_REOPEN): + # If we unify close to reopen check whether the user has permissions to close. + # If he has -- he can reopen his question too. + can_reopen = ( + self == question.author and self.reputation >= int(settings.REP_TO_CLOSE_OWN) + ) or self.reputation >= int(settings.REP_TO_CLOSE_OTHERS) + else: + # Check whether the user is the author and has the required permissions to reopen + can_reopen = self == question.author and self.reputation >= int(settings.REP_TO_REOPEN_OWN) + return can_reopen @true_if_is_super_or_staff def can_delete_post(self, post): diff --git a/forum/settings/minrep.py b/forum/settings/minrep.py index 8206823..1c9e17d 100644 --- a/forum/settings/minrep.py +++ b/forum/settings/minrep.py @@ -39,6 +39,11 @@ REP_TO_CLOSE_OWN = Setting('REP_TO_CLOSE_OWN', 250, MIN_REP_SET, dict( label = _("Minimum reputation to close own question"), help_text = _("The minimum reputation an user must have to be allowed to close his own question."))) +UNIFY_PERMISSIONS_TO_CLOSE_AND_REOPEN = Setting('UNIFY_PERMISSIONS_TO_CLOSE_AND_REOPEN', True, MIN_REP_SET, dict( +label = _("Unify close and reopen permissions"), +help_text = _("If checked the same permissions as the ones to close question will be required to reopen it."), +required=False)) + REP_TO_REOPEN_OWN = Setting('REP_TO_REOPEN_OWN', 500, MIN_REP_SET, dict( label = _("Minimum reputation to reopen own question"), help_text = _("The minimum reputation an user must have to be allowed to reopen his own question."))) -- 2.39.5