X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/293ecbd0f64bcdf5e89ab05c7000a8cea772e1f6..50218f3c76fc43de83da77dda0501b5aabffa4d4:/forum/models/user.py diff --git a/forum/models/user.py b/forum/models/user.py index a3714ae..62eeac3 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -61,12 +61,18 @@ class AnonymousUser(DjangoAnonymousUser): def can_accept_answer(self, answer): return False + def can_create_tags(self): + return False + def can_edit_post(self, post): return False def can_wikify(self, post): return False + def can_cancel_wiki(self, post): + return False + def can_retag_questions(self): return False @@ -214,6 +220,10 @@ class User(BaseModel, DjangoUser): def can_accept_answer(self, answer): return self == answer.question.author + @true_if_is_super_or_staff + def can_create_tags(self): + return self.reputation >= int(settings.REP_TO_CREATE_TAGS) + @true_if_is_super_or_staff def can_edit_post(self, post): return self == post.author or self.reputation >= int(settings.REP_TO_EDIT_OTHERS @@ -223,6 +233,10 @@ class User(BaseModel, DjangoUser): def can_wikify(self, post): return self == post.author or self.reputation >= int(settings.REP_TO_WIKIFY) + @true_if_is_super_or_staff + def can_cancel_wiki(self, post): + return self == post.author + @true_if_is_super_or_staff def can_retag_questions(self): return self.reputation >= int(settings.REP_TO_RETAG) @@ -248,6 +262,11 @@ class User(BaseModel, DjangoUser): def can_upload_files(self): return self.reputation >= int(settings.REP_TO_UPLOAD) + def check_password(self, old_passwd): + self.__dict__.update(self.__class__.objects.filter(id=self.id).values('password')[0]) + return DjangoUser.check_password(self, old_passwd) + + class Meta: app_label = 'forum'