X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/9c07479eba71589011aec0ed120b6a1bdd78459c..ec62bc84aa89b5e946104bc4dcdf78f382c90165:/forum/actions/user.py diff --git a/forum/actions/user.py b/forum/actions/user.py index 3366a6c..7d636be 100644 --- a/forum/actions/user.py +++ b/forum/actions/user.py @@ -1,4 +1,5 @@ from django.utils.translation import ungettext, ugettext as _ +from django.core.urlresolvers import reverse from django.db.models import F from forum.models.action import ActionProxy from forum.models import Award, Badge, ValidationHash, User @@ -46,7 +47,7 @@ class EmailValidationAction(ActionProxy): return _("%(user)s %(have_has)s validated the e-mail %(email)s") % { 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)), 'have_has': self.viewer_or_user_verb(viewer, self.user, _('have'), _('has')), - 'email' : self.user.email + 'email' : self.user.email if viewer.is_superuser or viewer.is_staff or viewer == self.user else "" } class EditProfileAction(ActionProxy): @@ -163,9 +164,10 @@ class AwardAction(ActionProxy): self.user.save() self.user.message_set.create(message=_( - """Congratulations, you have received a badge '%(badge_name)s'. Check out your profile.""" - ) % - dict(badge_name=award.badge.name, profile_url=self.user.get_profile_url())) + """Congratulations, you have received a badge '%(badge_name)s'. Find out who has it, too.""" + ) % dict( + badge_name=award.badge.name, + badge_url=award.badge.get_absolute_url())) def cancel_action(self): award = self.award @@ -191,6 +193,35 @@ class AwardAction(ActionProxy): '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_profile_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")