diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-07-17 21:22:51 -0400 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-07-17 21:22:51 -0400 |
commit | d051346759d2248620a7329290188ea69814b5c4 (patch) | |
tree | f7cc971a5970c531f1b4cb5e71ac1e514c7a48e6 | |
parent | 44a6e0e527c034ef9054160bed241261bea35afa (diff) | |
download | askbot-d051346759d2248620a7329290188ea69814b5c4.tar.gz askbot-d051346759d2248620a7329290188ea69814b5c4.tar.bz2 askbot-d051346759d2248620a7329290188ea69814b5c4.zip |
fixed a small bug
-rw-r--r-- | askbot/auth.py | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/askbot/auth.py b/askbot/auth.py index 0b2bd23b..f1d8b5a2 100644 --- a/askbot/auth.py +++ b/askbot/auth.py @@ -17,9 +17,15 @@ from askbot.conf import settings as askbot_settings def can_vote_up(user): """Determines if a User can vote Questions and Answers up.""" - return user.is_authenticated() and ( - user.reputation >= askbot_settings.MIN_REP_TO_VOTE_UP or - user.is_superuser) + if user.is_authenticated(): + if user.reputation >= askbot_settings.MIN_REP_TO_VOTE_UP: + if user.is_blocked(): + return False + else: + return True + if user.is_administrator() or user.is_moderator(): + return True + return False def can_flag_offensive(user): """Determines if a User can flag Questions and Answers as offensive.""" @@ -64,13 +70,16 @@ def can_edit_post(user, post): """Determines if a User can edit the given Question or Answer.""" if user.is_authenticated(): if user.id == post.author_id: - return True + if user.is_blocked(): + return False + else: + return True if post.wiki: if user.reputation >= askbot_settings.MIN_REP_TO_EDIT_WIKI: return True if user.reputation >= askbot_settings.MIN_REP_TO_EDIT_OTHERS_POSTS: return True - if user.is_superuser: + if user.is_administrator() or user.is_moderator(): return True return False @@ -156,9 +165,15 @@ def can_view_user_edit(request_user, target_user): return (request_user.is_authenticated() and request_user == target_user) def can_upload_files(request_user): - if request_user.is_superuser: - return True if request_user.is_authenticated(): + if request_user.is_suspended(): + return False + elif request_user.is_blocked(): + return False + elif request_user.is_moderator(): + return True + elif request_user.is_administrator(): + return True if request_user.reputation >= askbot_settings.MIN_REP_TO_UPLOAD_FILES: return True return False |