X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/be26ac9493b40e87e07c773a8d7c79ef1e8b7b48..5cced8510af03eec1438cfefcf9f44e2e7a49087:/forum/models/user.py diff --git a/forum/models/user.py b/forum/models/user.py index 6f7613a..339c02d 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -61,6 +61,9 @@ 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 @@ -155,7 +158,7 @@ class User(BaseModel, DjangoUser): def get_vote_count_today(self): today = datetime.date.today() return self.actions.filter(canceled=False, action_type__in=("voteup", "votedown"), - action_date__range=(today - datetime.timedelta(days=1), today)).count() + action_date__gte=(today - datetime.timedelta(days=1))).count() def get_reputation_by_upvoted_today(self): today = datetime.datetime.now() @@ -167,7 +170,7 @@ class User(BaseModel, DjangoUser): def get_flagged_items_count_today(self): today = datetime.date.today() return self.actions.filter(canceled=False, action_type="flag", - action_date__range=(today - datetime.timedelta(days=1), today)).count() + action_date__gte=(today - datetime.timedelta(days=1))).count() @true_if_is_super_or_staff def can_view_deleted_post(self, post): @@ -217,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 @@ -255,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'