summaryrefslogtreecommitdiffstats
path: root/askbot/auth.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-08-03 23:30:56 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-08-03 23:30:56 -0400
commitcedfb1fdd686441dbb0ae41bfbe96fb3a275c4a5 (patch)
tree5b0009c18699303beda328e45f90ee8610a460e7 /askbot/auth.py
parent9a02ed5693fc2e7f5872cd3eadaee066ea5f835b (diff)
downloadaskbot-cedfb1fdd686441dbb0ae41bfbe96fb3a275c4a5.tar.gz
askbot-cedfb1fdd686441dbb0ae41bfbe96fb3a275c4a5.tar.bz2
askbot-cedfb1fdd686441dbb0ae41bfbe96fb3a275c4a5.zip
moderation rules apply to posting comments, fixed login prompt links
Diffstat (limited to 'askbot/auth.py')
-rw-r--r--askbot/auth.py35
1 files changed, 4 insertions, 31 deletions
diff --git a/askbot/auth.py b/askbot/auth.py
index 6a92b005..1ab24f52 100644
--- a/askbot/auth.py
+++ b/askbot/auth.py
@@ -18,26 +18,6 @@ import logging
from askbot.conf import settings as askbot_settings
-def can_flag_offensive(user):
- """Determines if a User can flag Questions and Answers as offensive."""
- return user.is_authenticated() and (
- user.reputation >= askbot_settings.MIN_REP_TO_FLAG_OFFENSIVE or
- user.is_superuser)
-
-def can_add_comments(user, subject):
- """Determines if a User can add comments to Questions and Answers."""
- if user.is_authenticated():
- if user.id == subject.author.id:
- return True
- if user.reputation >= askbot_settings.MIN_REP_TO_LEAVE_COMMENTS:
- return True
- if user.is_superuser:
- return True
- if isinstance(subject, Answer):
- if subject.question.author.id == user.id:
- return True
- return False
-
def can_retag_questions(user):
"""Determines if a User can retag Questions."""
if user.is_authenticated():
@@ -65,18 +45,11 @@ def can_edit_post(user, post):
return True
return False
-def can_delete_comment(user, comment):
- """Determines if a User can delete the given Comment."""
- return user.is_authenticated() and (
- user.id == comment.user_id or
- user.reputation >= askbot_settings.MIN_REP_TO_DELETE_OTHERS_COMMENTS or
- user.is_superuser)
-
def can_view_offensive_flags(user):
"""Determines if a User can view offensive flag counts."""
return user.is_authenticated() and (
user.reputation >= askbot_settings.MIN_REP_TO_VIEW_OFFENSIVE_FLAGS or
- user.is_superuser)
+ user.is_superuser or user.is_moderator())
def can_close_question(user, question):
"""Determines if a User can close the given Question."""
@@ -150,7 +123,7 @@ def onFlaggedItem(item, post, user, timestamp=None):
post.author.reputation = calculate_reputation(
post.author.reputation,
- askbot_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE
+ askbot_settings.REP_LOSS_FOR_RECEIVING_FLAG
)
post.author.save()
@@ -160,7 +133,7 @@ def onFlaggedItem(item, post, user, timestamp=None):
reputation = Repute(
user=post.author,
- negative=askbot_settings.REP_LOSS_FOR_RECEIVING_DOWNVOTE,
+ negative=askbot_settings.REP_LOSS_FOR_RECEIVING_FLAG,
question=question, reputed_at=timestamp,
reputation_type=-4,
reputation=post.author.reputation
@@ -212,7 +185,7 @@ def onFlaggedItem(item, post, user, timestamp=None):
#post.deleted_at = timestamp
#post.deleted_by = Admin
post.save()
- signals.mark_offensive.send(
+ signals.flag_offensive.send(
sender=post.__class__,
instance=post,
mark_by=user