]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/user.py
Adds a couple of options to manage the "accepting answers" workflow.
[osqa.git] / forum / models / user.py
index 2e71868d8d1333f19a1a27bfd929d515606aeecc..cabaabbd156947e6456c3b82f999aa4d5920c18f 100644 (file)
@@ -276,7 +276,7 @@ class User(BaseModel, DjangoUser):
 
     @true_if_is_super_or_staff
     def can_accept_answer(self, answer):
-        return self == answer.question.author
+        return self == answer.question.author and (settings.USERS_CAN_ACCEPT_OWN or answer.author != answer.question.author)
 
     @true_if_is_super_or_staff
     def can_create_tags(self):
@@ -315,7 +315,7 @@ class User(BaseModel, DjangoUser):
             return self.can_delete_comment(post)
 
         return (self == post.author and (post.__class__.__name__ == "Answer" or
-        not post.answers.exclude(author=self).count()))
+        not post.answers.exclude(author__id=self.id).count()))
 
     @true_if_is_super_or_staff
     def can_upload_files(self):