except Exception, e:
return ''
+class AwardPointsAction(ActionProxy):
+ verb = _("gave reputation points")
+
+ def process_data(self, value, affected):
+ self._value = value
+ self._affected = affected
+
+
+ def repute_users(self):
+ self.repute(self._affected, self._value)
+
+ if self._value > 0:
+ self._affected.message_set.create(
+ message=_("Congratulations, you have been awarded an extra %s reputation points.") % self._value +
+ '<br />%s' % self.extra.get('message', _('Thank you')))
+ else:
+ self._affected.message_set.create(
+ message=_("You gave %s reputation points.") % self._value +
+ '<br />%s' % self.extra.get('message', ''))
+
+ def describe(self, viewer=None):
+ value = self.extra.get('value', _('unknown'))
+
+ try:
+ if int(value) > 0:
+ return _("%(user)s awarded an extra %(value)s reputation points to %(users)s") % {
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+ 'value': value, 'users':self.affected_links(viewer),
+ }
+ else:
+ return _("%(user)s penalised %(users)s in %(value)s reputation points") % {
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+ 'value': value, 'users':self.affected_links(viewer),
+ }
+ except Exception, e:
+ return ''
+
class AwardAction(ActionProxy):
verb = _("was awarded")
extra = dict(message=request.POST.get('message', ''), awarding_user=request.user.id, value=points)
# We take points from the awarding user
- BonusRepAction(user=request.user, extra=extra).save(data=dict(value=-points, affected=user))
+ AwardPointsAction(user=request.user, extra=extra).save(data=dict(value=-points, affected=user))
# And give them to the awarded one
- BonusRepAction(user=request.user, extra=extra).save(data=dict(value=points, affected=awarded_user))
+ AwardPointsAction(user=request.user, extra=extra).save(data=dict(value=points, affected=awarded_user))
return { 'message' : _("You have awarded %s with %d points") % (awarded_user, points) }