Permalink
Browse files

hook up giving a reason for one-off points

  • Loading branch information...
1 parent b97b83e commit 33f3b610a873fa8933ecdc50387289dbe7f89a61 @brosner brosner committed Nov 1, 2010
Showing with 7 additions and 3 deletions.
  1. +5 −1 agon/forms.py
  2. +2 −2 agon/models.py
View
@@ -8,6 +8,10 @@
class OneOffPointAwardForm(forms.Form):
user = forms.ModelChoiceField(User.objects.filter(is_active=True))
points = forms.IntegerField()
+ reason = forms.CharField(max_length=140)
def award(self):
- award_points(self.cleaned_data["user"], self.cleaned_data["points"])
+ user = self.cleaned_data["user"]
+ points = self.cleaned_data["points"]
+ reason = self.cleaned_data["reason"]
+ award_points(user, points, reason=reason)
View
@@ -140,7 +140,7 @@ def source(self):
return self.source_object
-def award_points(target, key, source=None):
+def award_points(target, key, reason="", source=None):
"""
Awards target the point value for key. If key is an integer then it's a
one off assignment and should be interpreted as the actual point value.
@@ -162,7 +162,7 @@ def award_points(target, key, source=None):
" a PointValue or an integer amount of points to award."
)
- apv = AwardedPointValue(points=points, value=point_value)
+ apv = AwardedPointValue(points=points, value=point_value, reason=reason)
if isinstance(target, User):
apv.target_user = target
lookup_params = {

0 comments on commit 33f3b61

Please sign in to comment.