1 #-------------------------------------------------------------------------------
2 # Name: Award badges command
3 # Purpose: This is a command file croning in background process regularly to
4 # query database and award badges for user's special acitivities.
9 # Copyright: (c) Mike 2009
11 #-------------------------------------------------------------------------------
14 from django.core.management.base import NoArgsCommand
15 from django.db import connection
16 from django.shortcuts import get_object_or_404
17 from django.contrib.contenttypes.models import ContentType
19 from forum.models import *
21 class Command(NoArgsCommand):
22 def handle_noargs(self, **options):
31 def clean_awards(self):
32 Award.objects.all().delete()
34 award_type =ContentType.objects.get_for_model(Award)
35 Activity.objects.filter(content_type=award_type).delete()
37 for user in User.objects.all():
43 for badge in Badge.objects.all():
44 badge.awarded_count = 0
47 query = "UPDATE activity SET is_auditted = 0"
48 cursor = connection.cursor()
58 if __name__ == '__main__':