From 9a075e7d95c3b16c05011410de59196caaa86e66 Mon Sep 17 00:00:00 2001 From: javyer Date: Wed, 17 Oct 2012 17:24:51 +0000 Subject: [PATCH 1/1] Implemented 'report user' feature git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1279 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum/actions/user.py | 29 +++++++++++++++ .../notifications/user_reported.html | 37 +++++++++++++++++++ forum/skins/default/templates/users/info.html | 8 ++++ .../default/templates/users/report_user.html | 16 ++++++++ forum/urls.py | 1 + forum/views/users.py | 20 +++++++++- 6 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 forum/skins/default/templates/notifications/user_reported.html create mode 100644 forum/skins/default/templates/users/report_user.html diff --git a/forum/actions/user.py b/forum/actions/user.py index d9c6be9..7d636be 100644 --- a/forum/actions/user.py +++ b/forum/actions/user.py @@ -193,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") diff --git a/forum/skins/default/templates/notifications/user_reported.html b/forum/skins/default/templates/notifications/user_reported.html new file mode 100644 index 0000000..00e0b35 --- /dev/null +++ b/forum/skins/default/templates/notifications/user_reported.html @@ -0,0 +1,37 @@ +{% load i18n extra_tags email_tags %} + +{% declare %} + + reporter_author = html.mark_safe(smart_str(user.username)) + reported = html.mark_safe(smart_str(reported.username)) + + reported_link = html.objlink(reported, style=settings.EMAIL_ANCHOR_STYLE) + message = html.mark_safe(smart_str(message)) + +{% enddeclare %} + +{% email %} + {% subject %}{% blocktrans %}{{ prefix }} User reported: {{ reported }} by {{ reporter_author }}{% endblocktrans %}{% endsubject %} + + {% htmlcontent notifications/base.html %} +

+ {% blocktrans %} + User reported: {{ reported }} by {{ reporter_author }}.
+ Reporter Message: {{message}} + {% endblocktrans %} +

+ + + {% endhtmlcontent %} + +{% textcontent notifications/base_text.html %} +{% blocktrans %} + User reported: {{ reported }} by {{ reporter_author }}. + Reporter Message: {{message}} +{% endblocktrans %} + + +{% endtextcontent %} + +{% endemail %} + diff --git a/forum/skins/default/templates/users/info.html b/forum/skins/default/templates/users/info.html index 39f3b7d..a99691c 100644 --- a/forum/skins/default/templates/users/info.html +++ b/forum/skins/default/templates/users/info.html @@ -101,6 +101,14 @@ {% endif %} + + + + + Report user + + +