+ 'user': self.hyperlink(self.user.get_absolute_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 ReportAction(ActionProxy):
+ verb = _("suspended")
+
+ def process_data(self, **kwargs):
+ self.extra = kwargs
+ # message here?
+
+
+ def process_action(self):
+
+ all_superusers = User.objects.filter(is_superuser=True)
+
+
+ send_template_email(all_superusers, "notifications/user_reported.html", {
+ 'reported': self.extra['reported'],
+ 'user':self.user,
+ 'message': self.extra['publicmsg']
+ }
+ )
+
+ def describe(self, viewer=None):
+
+ return _("%(user)s reported %(reported) : %(msg)s") % {
+ 'user': self.hyperlink(self.user.get_absolute_url(), self.friendly_username(viewer, self.user)),
+ 'reporter': self.extra.get('reported').username,
+ 'msg': self.extra.get('publicmsg', _('N/A'))
+ }
+
+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_absolute_url(), self.friendly_username(viewer, self.user)),
+ 'users': self.affected_links(viewer), 'suspension': suspension, 'msg': self.extra.get('publicmsg', _('Bad behaviour'))
+ }