]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/user.py
OSQA-497, adding a new settings that allows to specify whether the permissions to...
[osqa.git] / forum / models / user.py
index 6ee7f663918b84674ad10ae7e7d46ad860adb261..84801fb0e0acd12879cec4c7b8726f0ce098ffa1 100644 (file)
@@ -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):