summaryrefslogtreecommitdiffstats
path: root/askbot/management/commands/askbot_award_badges.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2014-08-25 16:26:58 +0700
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2014-08-25 16:26:58 +0700
commit7fa1eb17f907fe5c3878a331960cdd59217db43c (patch)
treedbbb030efcc3e3e8a42f98149bc8a3f577070797 /askbot/management/commands/askbot_award_badges.py
parentc11627a6386f0b3568dea83f98f423194efb835c (diff)
downloadaskbot-7fa1eb17f907fe5c3878a331960cdd59217db43c.tar.gz
askbot-7fa1eb17f907fe5c3878a331960cdd59217db43c.tar.bz2
askbot-7fa1eb17f907fe5c3878a331960cdd59217db43c.zip
fixed correctness issue in the CivicDuty badge awards and allowed to edit comments by high reputation users
Diffstat (limited to 'askbot/management/commands/askbot_award_badges.py')
-rw-r--r--askbot/management/commands/askbot_award_badges.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/askbot/management/commands/askbot_award_badges.py b/askbot/management/commands/askbot_award_badges.py
new file mode 100644
index 00000000..3f8132b7
--- /dev/null
+++ b/askbot/management/commands/askbot_award_badges.py
@@ -0,0 +1,28 @@
+"""WARNING:
+This command is incomplete, current awards only
+Civic Duty badge
+"""
+
+from askbot.models import badges
+from askbot.models import User
+from askbot.models import Vote
+import datetime
+from django.core.management.base import NoArgsCommand
+
+class Command(NoArgsCommand):
+ def handle_noargs(self, *args, **kwargs):
+ now = datetime.datetime.now()
+ for user in User.objects.all():
+ try:
+ #get last vote
+ vote = Vote.objects.filter(user=user).order_by('-id')[0]
+ except IndexError:
+ #user did not vote
+ continue
+ else:
+ cd = badges.CivicDuty()
+ cd.consider_award(
+ actor=user,
+ context_object=vote.voted_post,
+ timestamp=now
+ )