Mercurial > public > sg101
comparison gpp/bio/badges.py @ 316:767cedc7d12a
Fixing #144; integrate with new Django logging support. Also added unit tests for Donations app.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 30 Jan 2011 20:02:32 +0000 |
parents | b4305e18d3af |
children | 47f4259ce511 |
comparison
equal
deleted
inserted
replaced
315:36373d995611 | 316:767cedc7d12a |
---|---|
1 """This module contains user profile badge-related functionality.""" | 1 """This module contains user profile badge-related functionality.""" |
2 import logging | |
2 | 3 |
3 from bio.models import Badge | 4 from bio.models import Badge |
4 from bio.models import BadgeOwnership | 5 from bio.models import BadgeOwnership |
5 | 6 |
6 | 7 |
12 def award_badge(badge_id, user): | 13 def award_badge(badge_id, user): |
13 """This function awards the badge specified by badge_id | 14 """This function awards the badge specified by badge_id |
14 to the given user. If the user already has the badge, | 15 to the given user. If the user already has the badge, |
15 the badge count is incremented by one. | 16 the badge count is incremented by one. |
16 """ | 17 """ |
17 import logging | |
18 try: | 18 try: |
19 badge = Badge.objects.get(numeric_id=badge_id) | 19 badge = Badge.objects.get(numeric_id=badge_id) |
20 except Badge.DoesNotExist: | 20 except Badge.DoesNotExist: |
21 logging.error("Can't award badge with numeric_id = %d" % badge_id) | 21 logging.error("Can't award badge with numeric_id = %d", badge_id) |
22 return | 22 return |
23 | 23 |
24 profile = user.get_profile() | 24 profile = user.get_profile() |
25 | 25 |
26 # Does the user already have badges of this type? | 26 # Does the user already have badges of this type? |