- 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
- 'were_was': self.viewer_or_user_verb(viewer, self.user, _('were'), _('was')),
- 'badge_name': self.award.badge.name,
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+ 'were_was': self.viewer_or_user_verb(viewer, self.user, _('were'), _('was')),
+ 'badge_name': self.award.badge.name,
+ }
+
+class SuspendAction(ActionProxy):
+ verb = _("suspended")
+
+ def process_data(self, **kwargs):
+ self._suspended = kwargs.pop('suspended')
+ self.extra = kwargs
+
+ def repute_users(self):
+ self.repute(self._suspended, 0)
+
+ def process_action(self):
+ self._suspended.is_active = False
+ self._suspended.save()
+
+ def cancel_action(self):
+ for u in User.objects.filter(reputes__action=self).distinct():
+ u.is_active = True
+ u._pop_suspension_cache()
+ u.save()
+ u.message_set.create(message=_("Your suspension has been removed."))
+
+ def describe(self, viewer=None):
+ if self.extra.get('bantype', 'indefinitely') == 'forxdays' and self.extra.get('forxdays', None):
+ suspension = _("for %s days") % self.extra['forxdays']
+ else:
+ suspension = _("indefinetely")
+
+ return _("%(user)s suspended %(users)s %(suspension)s: %(msg)s") % {
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+ 'users': self.affected_links(viewer), 'suspension': suspension, 'msg': self.extra.get('publicmsg', _('Bad behaviour'))