Mercurial > public > sg101
comparison gpp/bio/badges.py @ 400:47f4259ce511
Fixing #197; add a badge for photo of the day.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 26 Mar 2011 21:29:27 +0000 |
parents | 767cedc7d12a |
children |
comparison
equal
deleted
inserted
replaced
399:24f1230f3ee3 | 400:47f4259ce511 |
---|---|
5 from bio.models import BadgeOwnership | 5 from bio.models import BadgeOwnership |
6 | 6 |
7 | 7 |
8 # Numeric ID's for badges that are awarded for user actions: | 8 # Numeric ID's for badges that are awarded for user actions: |
9 (CONTRIBUTOR_PIN, CALENDAR_PIN, NEWS_PIN, LINK_PIN, DOWNLOAD_PIN, | 9 (CONTRIBUTOR_PIN, CALENDAR_PIN, NEWS_PIN, LINK_PIN, DOWNLOAD_PIN, |
10 SECURITY_PIN) = range(6) | 10 SECURITY_PIN, POTD_PIN) = range(7) |
11 | 11 |
12 | 12 |
13 def award_badge(badge_id, user): | 13 def award_badge(badge_id, user): |
14 """This function awards the badge specified by badge_id | 14 """This function awards the badge specified by badge_id |
15 to the given user. If the user already has the badge, | 15 to the given user. If the user already has the badge, |
31 bo = BadgeOwnership(profile=profile, badge=badge, count=1) | 31 bo = BadgeOwnership(profile=profile, badge=badge, count=1) |
32 else: | 32 else: |
33 # Already have this badge | 33 # Already have this badge |
34 bo.count += 1 | 34 bo.count += 1 |
35 bo.save() | 35 bo.save() |
36 | |
37 logging.info('Awarded %s with the badge: %s', user.username, badge.name) |