diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-11-08 00:39:32 -0500 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2010-11-08 00:39:32 -0500 |
commit | 96a7854e151235bbc553cf3ffa26cd2b21e32dfa (patch) | |
tree | ecdf330b91d6aa71ed6ee8b07e49b40d5e14377a /askbot/api.py | |
parent | ae53fef954ff88a3b594c14a84639a679b6d6dc1 (diff) | |
download | askbot-96a7854e151235bbc553cf3ffa26cd2b21e32dfa.tar.gz askbot-96a7854e151235bbc553cf3ffa26cd2b21e32dfa.tar.bz2 askbot-96a7854e151235bbc553cf3ffa26cd2b21e32dfa.zip |
inbox with persistent responses and flags sort of works, but neds testing on correctness
Diffstat (limited to 'askbot/api.py')
-rw-r--r-- | askbot/api.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/askbot/api.py b/askbot/api.py new file mode 100644 index 00000000..c79f29dd --- /dev/null +++ b/askbot/api.py @@ -0,0 +1,34 @@ +"""place for the API calls into askbot +at this point most of the useful functions are still +in the askbot.models module, but +api must become a place to manupulate the data in the askbot application +so that other implementations of the data storage could be possible +""" +from askbot import models +from askbot import const + +def get_info_on_moderation_items(user): + """returns a dictionary with + counts of new and seen moderation items for a given user + if user is not a moderator or admin, returns None + """ + if user.is_anonymous(): + return None + if not(user.is_moderator() or user.is_administrator()): + return None + + messages = models.ActivityAuditStatus.objects.filter( + activity__activity_type = const.TYPE_ACTIVITY_MARK_OFFENSIVE, + user = user + ) + + seen_count = messages.filter( + status = models.ActivityAuditStatus.STATUS_SEEN + ).count() + new_count = messages.filter( + status = models.ActivityAuditStatus.STATUS_NEW + ).count() + return { + 'seen_count': seen_count, + 'new_count': new_count + } |