]> git.openstreetmap.org Git - osqa.git/commitdiff
Implemented 'report user' feature
authorjavyer <javyer@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 17 Oct 2012 17:24:51 +0000 (17:24 +0000)
committerjavyer <javyer@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Wed, 17 Oct 2012 17:24:51 +0000 (17:24 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1279 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/actions/user.py
forum/skins/default/templates/notifications/user_reported.html [new file with mode: 0644]
forum/skins/default/templates/users/info.html
forum/skins/default/templates/users/report_user.html [new file with mode: 0644]
forum/urls.py
forum/views/users.py

index d9c6be920e9411fc592666dd08e25db1ff1dbe38..7d636be0fcce12e4a78976bc7cfca4b7dc098478 100644 (file)
@@ -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 (file)
index 0000000..00e0b35
--- /dev/null
@@ -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 %}
+        <p style="{{ p_style }}">
+            {% blocktrans %}
+                       User reported: {{ reported }} by {{ reporter_author }}.<br/>
+                       Reporter Message: {{message}}
+            {% endblocktrans %}
+        </p>
+
+
+    {% endhtmlcontent %}
+
+{% textcontent notifications/base_text.html %}
+{% blocktrans %}
+                       User reported: {{ reported }} by {{ reporter_author }}.
+                       Reporter Message: {{message}}
+{% endblocktrans %}
+
+
+{% endtextcontent %}
+
+{% endemail %}
+
index 39f3b7d869d17d4f576ff9a4e1f6dc18c02ef5e0..a99691cd56a29af6071870c02de9dfb799c9a788 100644 (file)
                     </td>
                 </tr>
                 {% endif %}
+
+                <tr>
+                    <td colspan="2" style="text-align:right">
+                        <a href="{% url user_report user.pk %}" class="ajax-command withprompt">
+                        Report user
+                        </a>
+                    </td>
+                </tr>
                                <!--
                 {% if votes_today_left %}
                 <tr>
diff --git a/forum/skins/default/templates/users/report_user.html b/forum/skins/default/templates/users/report_user.html
new file mode 100644 (file)
index 0000000..fcfbf73
--- /dev/null
@@ -0,0 +1,16 @@
+{% load i18n %}
+
+<table>
+    <caption><h2>{% trans "Report user" %}</h2></caption>
+    <tr>
+        <td>
+            <p><b>{% trans "Public message" %}:</b></p>
+        </td>
+    </tr>
+    <tr>
+        <td>
+            <textarea rows="3" name="publicmsg" cols="35"></textarea><br />
+            <small>{% trans "This message will be visible through the user activity log."  %}</small>
+        </td>
+    </tr>
+</table>
index fd82f7f7707e213f933024032d95c6afbfee14eb..380d6b36fda33b771aea5cacfb19ce438a4a2a4e 100644 (file)
@@ -103,6 +103,7 @@ core_urls = (
     url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'),
     url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('award/')), app.users.award_points, name='user_award_points'),
     url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('suspend/')), app.users.suspend, name='user_suspend'),
+    url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('report/')), app.users.report_user, name='user_report'),
     url(r'^%s(?P<id>\d+)/%s(?P<action>[a-z]+)/(?P<status>[a-z]+)/$' % (_('users/'), _('powers/')), app.users.user_powers, name='user_powers'),
     url((core_user_urls_prefix + '/%s$') % (_('users/'), _('subscriptions/')), app.users.user_subscriptions, name='user_subscriptions'),
     url(r'^%s(?P<id>\d+)/(?P<slug>.*)/%s$' % (_('users/'), _('preferences/')), app.users.user_preferences, name='user_preferences'),
index 84f1cdf2ad222e182161a658a620d8f01953cc46..dc865a236ed3e8824903419c78b88fdb609ce9ba 100644 (file)
@@ -18,7 +18,7 @@ from forum.forms import *
 from forum.utils.html import sanitize_html\r
 from forum.modules import decorate, ReturnImediatelyException\r
 from datetime import datetime, date\r
-from forum.actions import EditProfileAction, FavoriteAction, BonusRepAction, SuspendAction\r
+from forum.actions import EditProfileAction, FavoriteAction, BonusRepAction, SuspendAction, ReportAction\r
 from forum.modules import ui\r
 from forum.utils import pagination\r
 from forum.views.readers import QuestionListPaginatorContext, AnswerPaginatorContext\r
@@ -252,6 +252,24 @@ def suspend(request, id):
 \r
     return decorators.RefreshPageCommand()\r
 \r
+@decorate.withfn(decorators.command)\r
+def report_user(request, id):\r
+    user = get_object_or_404(User, id=id)\r
+\r
+    if not request.POST.get('publicmsg', None):\r
+        return render_to_response('users/report_user.html')\r
+\r
+    data = {\r
+        'publicmsg': request.POST.get('publicmsg', _('N/A')),\r
+        'reported': user\r
+    }\r
+\r
+    ReportAction(user=request.user, ip=request.META['REMOTE_ADDR']).save(data=data)\r
+\r
+\r
+    return decorators.RefreshPageCommand()\r
+\r
+\r
 \r
 def user_view(template, tab_name, tab_title, tab_description, private=False, tabbed=True, render_to=None, weight=500):\r
     def decorator(fn):\r