At this point, I am very close to done with this code! I made one big change at
authortilly-Q <nattilypigeonfowl@gmail.com>
Mon, 23 Sep 2013 17:20:18 +0000 (13:20 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Mon, 23 Sep 2013 17:20:18 +0000 (13:20 -0400)
paroneayea's request, which was to make to possible to turn off user's ability
to file reports through a mediagoblin.ini setting. Aside from this, I had to
make it possible for the Moderation User Panel to display more than 10 users.
And aside from that, I just had to fix some errors which cropped up with my
most recent additions. I also fixed some tests that were broken because I had
changed the checks for whether or not a user is active. Nearing the end!

===============================================================================
    Made it possible to turn off reports through a mediagoblin.ini setting
===============================================================================
--\ mediagoblin.ini
--\ mediagoblin/config_spec.ini
--\ mediagoblin/decorators.py
--\ mediagoblin/moderation/views.py
--\ mediagoblin/templates/mediagoblin/user_pages/media.html
--\ mediagoblin/user_pages/views.py

===============================================================================
    Made User Panel capable of showing more than 1 page of users
===============================================================================
--\ mediagoblin/moderation/forms.py
--\ mediagoblin/moderation/views.py
--\ mediagoblin/templates/mediagoblin/moderation/user_panel.html

===============================================================================
        Fixed Broken Tests
===============================================================================
--\ mediagoblin/tests/test_notifications.py
--\ mediagoblin/tests/test_openid.py
--\ mediagoblin/tests/test_persona.py
--\ mediagoblin/tests/test_reporting.py

===============================================================================
        Fixed errors in code
===============================================================================
--\ mediagoblin/db/migrations.py
--| Set nullable to True for MediaReports' and CommentReports' content foreign
  |keys

--\ mediagoblin/db/models.py
--| Got rid of cascading rules for MediaReports' and CommentReports' content
  |foreign keys. This makes it possible for the Reports to continue to exist
  |after the content is deleted.

--\ mediagoblin/moderation/tools.py
--| Fixed formatting of Report Resolution Methods
--| Took out pieces of code used in debugging

--\ mediagoblin/templates/mediagoblin/base.html
--\ mediagoblin/templates/mediagoblin/moderation/report.html
--| Made reports details page able to tell what is a deleted archived report.

--\ mediagoblin/templates/mediagoblin/moderation/report_panel.html
--\ mediagoblin/templates/mediagoblin/utils/report.html

19 files changed:
mediagoblin.ini
mediagoblin/config_spec.ini
mediagoblin/db/migrations.py
mediagoblin/db/models.py
mediagoblin/decorators.py
mediagoblin/moderation/forms.py
mediagoblin/moderation/tools.py
mediagoblin/moderation/views.py
mediagoblin/templates/mediagoblin/base.html
mediagoblin/templates/mediagoblin/moderation/report.html
mediagoblin/templates/mediagoblin/moderation/report_panel.html
mediagoblin/templates/mediagoblin/moderation/user_panel.html
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/utils/report.html
mediagoblin/tests/test_notifications.py
mediagoblin/tests/test_openid.py
mediagoblin/tests/test_persona.py
mediagoblin/tests/test_reporting.py
mediagoblin/user_pages/views.py

index 30dacadf3ec30d3b966d4918691a634ae816cac9..874ebcbdaf8e4463dc84a66b5d7643cc18e3ef70 100644 (file)
@@ -20,6 +20,9 @@ email_debug_mode = true
 # Set to false to disable registrations
 allow_registration = true
 
+# Set to false to disable the ability for users to report offensive content
+allow_reporting = true
+
 ## Uncomment this to put some user-overriding templates here
 # local_templates = %(here)s/user_dev/templates/
 
index 43e1898cae29b76489ca858b7614c3e0220a7d00..0e2245035d3bdcb6a7b1f0b925f75e1ff235171b 100644 (file)
@@ -42,6 +42,9 @@ allow_comments = boolean(default=True)
 # Whether comments are ascending or descending
 comments_ascending = boolean(default=True)
 
+# Enable/disable reporting
+allow_reporting = boolean(default=True)
+
 # By default not set, but you might want something like:
 # "%(here)s/user_dev/templates/"
 local_templates = string()
index 2e05bf2ade26cc7cf222d06246f374047fc6321b..ff74aa309a5c950dfa78d34c60293d0b4acfc33f 100644 (file)
@@ -494,7 +494,7 @@ class CommentReport_v0(ReportBase_v0):
 
     id = Column('id',Integer, ForeignKey('core__reports.id'),
                                                 primary_key=True)
-    comment_id = Column(Integer, ForeignKey(MediaComment.id), nullable=False)
+    comment_id = Column(Integer, ForeignKey(MediaComment.id), nullable=True)
 
 
 
@@ -503,7 +503,7 @@ class MediaReport_v0(ReportBase_v0):
     __mapper_args__ = {'polymorphic_identity': 'media_report'}
 
     id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
-    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
+    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=True)
 
 class UserBan_v0(declarative_base()):
     __tablename__ = 'core__user_bans'
index cec311f2aeb9bfc169d356e513d2973b2bbcc635..466f31b8930fed005b5c68763ac2f47f4933a9f1 100644 (file)
@@ -764,8 +764,7 @@ class CommentReport(ReportBase):
     comment_id = Column(Integer, ForeignKey(MediaComment.id), nullable=True)
     comment = relationship(
         MediaComment, backref=backref("reports_filed_on",
-            lazy="dynamic",
-            cascade="all, delete-orphan"))
+            lazy="dynamic"))
 
 
 class MediaReport(ReportBase):
@@ -782,9 +781,8 @@ class MediaReport(ReportBase):
     media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=True)
     media_entry = relationship(
         MediaEntry,
-        backref=backref("reports_filed_onmod/reports/1/",
-            lazy="dynamic",
-            cascade="all, delete-orphan"))
+        backref=backref("reports_filed_on",
+            lazy="dynamic"))
 
 class UserBan(Base):
     """
index d5a10db1d284c70fdf608652563b8a6691b2fc15..d0b5ad336804fcb30a2faa7ac2df3ece0b33b42d 100644 (file)
@@ -304,6 +304,21 @@ def allow_registration(controller):
 
     return wrapper
 
+def allow_reporting(controller):
+    """ Decorator for if reporting is enabled"""
+    @wraps(controller)
+    def wrapper(request, *args, **kwargs):
+        if not mgg.app_config["allow_reporting"]:
+            messages.add_message(
+                request,
+                messages.WARNING,
+                _('Sorry, reporting is disabled on this instance.'))
+            return redirect(request, 'index')
+
+        return controller(request, *args, **kwargs)
+
+    return wrapper
+
 def get_optional_media_comment_by_id(controller):
     """
     Pass in a MediaComment based off of a url component. Because of this decor-
index 78e9fcdce4a2ada4313e6834c421f3bd8b848152..5582abdda8a99c72fc62a52fb38e1f835cbaba28 100644 (file)
@@ -139,3 +139,10 @@ class ReportPanelSortingForm(wtforms.Form):
         validators=[wtforms.validators.optional()])
     reporter = wtforms.IntegerField(
         validators=[wtforms.validators.optional()])
+
+class UserPanelSortingForm(wtforms.Form):
+    """
+    This form is used for sorting different reports.
+    """
+    p = wtforms.IntegerField(
+        validators=[wtforms.validators.optional()])
index 109f3d8f328a97d3f41241246340664f82654bd0..224a0c736719f4aa4e794659f01444daff562a61 100644 (file)
@@ -25,90 +25,79 @@ import sys, traceback
 
 def take_punitive_actions(request, form, report, user):
     message_body =''
-    try:
-
-        # The bulk of this action is running through all of the different
-        # punitive actions that a moderator could take.
-        if u'takeaway' in form.action_to_resolve.data:
-            for privilege_name in form.take_away_privileges.data:
-                take_away_privileges(user.username, privilege_name)
-                form.resolution_content.data += \
-                    u"\n{mod} took away {user}\'{privilege} privileges.".format(
-                        mod=request.user.username,
-                        user=user.username,
-                        privilege=privilege_name)
-
-        # If the moderator elects to ban the user, a new instance of user_ban
-        # will be created.
-        if u'userban' in form.action_to_resolve.data:
-            user_ban = ban_user(form.targeted_user.data,
-                expiration_date=form.user_banned_until.data,
-                reason=form.why_user_was_banned.data)
-            Session.add(user_ban)
+
+    # The bulk of this action is running through all of the different
+    # punitive actions that a moderator could take.
+    if u'takeaway' in form.action_to_resolve.data:
+        for privilege_name in form.take_away_privileges.data:
+            take_away_privileges(user.username, privilege_name)
             form.resolution_content.data += \
-                u"\n{mod} banned user {user} until {expiration_date}.".format(
+                u"\n{mod} took away {user}\'{privilege} privileges.".format(
                     mod=request.user.username,
                     user=user.username,
-                    expiration_date = (
-                    "until {date}".format(date=form.user_banned_until.data)
-                        if form.user_banned_until.data
-                        else "indefinitely"
-                        )
-                )
-
-        # If the moderator elects to send a warning message. An email will be
-        # sent to the email address given at sign up
-        if u'sendmessage' in form.action_to_resolve.data:
-            message_body = form.message_to_user.data
+                    privilege=privilege_name)
+
+    # If the moderator elects to ban the user, a new instance of user_ban
+    # will be created.
+    if u'userban' in form.action_to_resolve.data:
+        user_ban = ban_user(form.targeted_user.data,
+            expiration_date=form.user_banned_until.data,
+            reason=form.why_user_was_banned.data)
+        Session.add(user_ban)
+        form.resolution_content.data += \
+            u"\n{mod} banned user {user} {expiration_date}.".format(
+                mod=request.user.username,
+                user=user.username,
+                expiration_date = (
+                "until {date}".format(date=form.user_banned_until.data)
+                    if form.user_banned_until.data
+                    else "indefinitely"
+                    )
+            )
+
+    # If the moderator elects to send a warning message. An email will be
+    # sent to the email address given at sign up
+    if u'sendmessage' in form.action_to_resolve.data:
+        message_body = form.message_to_user.data
+        form.resolution_content.data += \
+            u"\n{mod} sent a warning email to the {user}.".format(
+                mod=request.user.username,
+                user=user.username)
+
+    if u'delete' in form.action_to_resolve.data and \
+        report.is_comment_report():
+            deleted_comment = report.comment
+            Session.delete(deleted_comment)
             form.resolution_content.data += \
-                u"\n{mod} sent a warning email to the {user}.".format(
-                    mod=request.user.username,
-                    user=user.username)
-
-        if u'delete' in form.action_to_resolve.data and \
-            report.is_comment_report():
-                deleted_comment = report.comment
-                Session.delete(deleted_comment)
-                form.resolution_content.data += \
-                    u"\n{mod} deleted the comment.".format(
-                        mod=request.user.username)
-        elif u'delete' in form.action_to_resolve.data and \
-            report.is_media_entry_report():
-                deleted_media = report.media_entry
-                Session.delete(deleted_media)
-                form.resolution_content.data += \
-                    u"\n{mod} deleted the media entry.".format(
-                        mod=request.user.username)
-        report.archive(
-            resolver_id=request.user.id,
-            resolved=datetime.now(),
-            result=form.resolution_content.data)
-
-        Session.add(report)
-        Session.commit()
-        if message_body:
-            send_email(
-                mg_globals.app_config['email_sender_address'],
-                [user.email],
-                _('Warning from')+ '- {moderator} '.format(
-                    moderator=request.user.username),
-                message_body)
-
-        return redirect(
-            request,
-            'mediagoblin.moderation.users_detail',
-            user=user.username)
-    except:
-#TODO make a more effective and specific try except statement. To account for
-# incorrect value addition my moderators
-        print sys.exc_info()[0]
-        print sys.exc_info()[1]
-        traceback.print_tb(sys.exc_info()[2])
-        Session.rollback()
-        return redirect(
-            request,
-            'mediagoblin.moderation.reports_detail',
-            report_id=report.id)
+                u"\n{mod} deleted the comment.".format(
+                    mod=request.user.username)
+    elif u'delete' in form.action_to_resolve.data and \
+        report.is_media_entry_report():
+            deleted_media = report.media_entry
+            Session.delete(deleted_media)
+            form.resolution_content.data += \
+                u"\n{mod} deleted the media entry.".format(
+                    mod=request.user.username)
+    report.archive(
+        resolver_id=request.user.id,
+        resolved=datetime.now(),
+        result=form.resolution_content.data)
+
+    Session.add(report)
+    Session.commit()
+    if message_body:
+        send_email(
+            mg_globals.app_config['email_sender_address'],
+            [user.email],
+            _('Warning from')+ '- {moderator} '.format(
+                moderator=request.user.username),
+            message_body)
+
+    return redirect(
+        request,
+        'mediagoblin.moderation.users_detail',
+        user=user.username)
+
 
 def take_away_privileges(user,*privileges):
     """
index 45edff1dc3f7ae7add65feb7aebcaa7ef463c028..4721834a395a0b3abf901a2b29420589fb933002 100644 (file)
@@ -19,8 +19,9 @@ from werkzeug.exceptions import Forbidden
 from mediagoblin.db.models import (MediaEntry, User, MediaComment, \
                                    CommentReport, ReportBase, Privilege, \
                                    UserBan)
-from mediagoblin.decorators import (require_admin_or_moderator_login, \
-                                    active_user_from_url, user_has_privilege)
+from mediagoblin.decorators import (require_admin_or_moderator_login, 
+                                    active_user_from_url, user_has_privilege,
+                                    allow_reporting)
 from mediagoblin.tools.response import render_to_response, redirect
 from mediagoblin.moderation import forms as moderation_forms
 from mediagoblin.moderation.tools import (take_punitive_actions, \
@@ -58,12 +59,24 @@ def moderation_users_panel(request):
     '''
     Show the global panel for monitoring users in this instance
     '''
-    user_list = User.query
+    current_page = 1
+    if len(request.args) > 0:
+        form = moderation_forms.UserPanelSortingForm(request.args)
+        if form.validate():
+            current_page = form.p.data or 1
+
+    all_user_list = User.query
+    user_list = all_user_list.order_by(
+        User.created.desc()).offset(
+            (current_page-1)*10).limit(10)
+    last_page = int(ceil(all_user_list.count()/10.))
 
     return render_to_response(
         request,
         'mediagoblin/moderation/user_panel.html',
-        {'user_list': user_list})
+        {'user_list': user_list,
+         'current_page':current_page,
+         'last_page':last_page})
 
 @require_admin_or_moderator_login
 def moderation_users_detail(request):
@@ -89,6 +102,7 @@ def moderation_users_detail(request):
          'ban_form':ban_form})
 
 @require_admin_or_moderator_login
+@allow_reporting
 def moderation_reports_panel(request):
     '''
     Show the global panel for monitoring reports filed against comments or
@@ -135,6 +149,7 @@ def moderation_reports_panel(request):
          'closed_settings':closed_settings})
 
 @require_admin_or_moderator_login
+@allow_reporting
 def moderation_reports_detail(request):
     """
     This is the page an admin or moderator goes to see the details of a report.
index 945d5ee3867f9dddfaf110903bb3110f5e708bd5..94ca7aa54f6d53afd46267208e90f8ba264f3284 100644 (file)
                  "javascript:;"
                {% endif %}
                >{% trans %}log out{% endtrans %}</a>
-              <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.collection') }}">
-                {%- trans %}Create new collection{% endtrans -%}
-              </a>
                 <p class="fine_print">
-                  <a href="{{ request.urlgen('terms_of_service') }}">Terms of Service</a>
+                  <a href="{{ request.urlgen('terms_of_service') }}">
+                    {%- trans %}Terms of Service{%- endtrans %}
+                  </a>
                 </p>
               {% endif %}
             {%- elif auth %}
               <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.start') }}">
                 {%- trans %}Add media{% endtrans -%}
               </a>
+              <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.collection') }}">
+                {%- trans %}Create new collection{% endtrans -%}
+              </a>
               {% if request.user.has_privilege('admin','moderator') %}
                 <p>
                   <span class="dropdown_title">Moderation powers:</span>
                   </a>
                 </p>
               {% endif %}
-              <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.collection') }}">
-                {%- trans %}Create new collection{% endtrans -%}
-              </a>
                 <p class="fine_print">
                   <a href="{{ request.urlgen('terms_of_service') }}">Terms of Service</a>
                 </p>
index 062ec24a10a54c5443c0defaffacf5bb83d1d901..cb717cde94c8b1bfde0823aae70851dda8cbfe22 100644 (file)
@@ -30,7 +30,7 @@
        title="Return to Reports Panel">
       {% trans %}Return to Reports Panel{% endtrans %}</a>
   <h2>{% trans %}Report{% endtrans %} #{{ report.id }}</h2>
-  {% if report.comment %}
+  {% if report.is_comment_report() and report.comment %}
 
     {% trans %}Reported comment{% endtrans %}:
     {% set comment = report.comment %}
@@ -62,7 +62,7 @@
         {% endautoescape %}
       </div>
     </div>
-  {% elif report.media_entry %}
+  {% elif report.is_media_entry_report() and report.media_entry %}
 
     {% set media_entry = report.media_entry %}
     <div class="media_thumbnail">
index 988dd2921c7b9af1d9e6df71da224539dc670f03..4eb16b2ba90d55f6e3a913382ed1a9ce4ad8da0a 100644 (file)
@@ -33,6 +33,7 @@
 </p>
 
 <h2>{% trans %}Active Reports Filed{% endtrans %}</h2>
+{% if report_list.count() %}
   {% if not active_settings.last_page == 1 %}
   {% if 'active_p='~active_settings.current_page in request.query_string %}
     {% set query_string = request.query_string %}{% else %}
@@ -70,7 +71,6 @@ curr_page !=p %}
     {% endif %}
   </div>
   {% endif %}
-{% if report_list.count() %}
   <table class="admin_panel processing">
     <tr>
       <th></th>
@@ -121,6 +121,7 @@ curr_page !=p %}
   <p><em>{% trans %}No open reports found.{% endtrans %}</em></p>
 {% endif %}
 <h2>{% trans %}Closed Reports{% endtrans %}</h2>
+{% if closed_report_list.count() %}
   {% if not closed_settings.last_page == 1 %}
   {% if 'closed_p='~closed_settings.current_page in request.query_string %}
     {% set query_string = request.query_string %}{% else %}
@@ -161,7 +162,6 @@ curr_page !=p %}
     {% endif %}
   </div>
   {% endif %}
-{% if closed_report_list.count() %}
   <table class="media_panel processing">
     <tr>
       <th></th>
index 54ef7c110d1f850095e4b503addbbae6e522a53d..4949960eaaf948592d7b8e5c07c938849b0d9c7a 100644 (file)
 <h2>{% trans %}Active Users{% endtrans %}</h2>
 
 {% if user_list.count() %}
+  {% if not last_page == 1 %}
+  {% if 'p='~current_page in request.query_string %}
+    {% set query_string = request.query_string %}{% else %}
+    {% set query_string =
+'p='~current_page~"&"+request.query_string %}
+  {% endif %}
+  <div class="right_align">
+    {% set first_vis = current_page-3  %}
+    {% set last_vis = current_page+3 %}
+    {% if 1 == current_page %}<b>1</b>{% else %}
+    <a href ="?{{ query_string.replace(
+                    'p='~current_page,
+                    'p='~1) }}">
+        1</a>{% endif %}
+    {% if first_vis > 1 %}...{% endif %}
+    {% for p in range(first_vis,last_vis+1) %}
+      {% if p > 1 and p < last_page and
+current_page !=p %}
+        <a href="?{{ query_string.replace(
+                    'p='~current_page,
+                    'p='~p) }}">
+          {{ p }}</a>
+      {% elif p > 1 and p < last_page %}
+        <b>{{ p }}</b>
+      {% endif  %}
+    {% endfor %}
+    {% if last_vis < last_page %}...{% endif %}
+    {% if last_page != current_page %}
+    <a href ="?{{ query_string.replace(
+                    'p='~current_page,
+                    'p='~last_page) }}">
+      {{ last_page }}</a>
+    {% else %}<b>{{ last_page }}</b>
+    {% endif %}
+  </div>
+  {% endif %}
   <table class="admin_panel processing">
     <tr>
       <th>{% trans %}ID{% endtrans %}</th>
index 62c2a48c59f05a3e5a5bca38a18ac4130ec0c0cc..81e5013e88e812ab04caa2d696e168e4a7f1a4d6 100644 (file)
             {%- endautoescape %}
           </div>
           <div>
-                <a {% if not request.user -%}
-                    href="{{ request.urlgen('mediagoblin.auth.login') }}"
-                  {%- else %}
-                    href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_comment',
+            {% if app_config.allow_reporting %}
+                <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_comment',
                             user=media.get_uploader.username,
                              media=media.slug_or_id,
-                             comment=comment.id) }}"
-                  {%- endif %}>
-                    {% trans %} Report {% endtrans %}</a>
+                             comment=comment.id) }}">
+                    {% trans %}Report{% endtrans %}</a>
+            {% endif %}
           </div>
         </li>
       {% endfor %}
 
     {% include "mediagoblin/utils/collections.html" %}
 
-    {% include "mediagoblin/utils/report.html" %}
+    {% if app_config.allow_reporting %}
+      {% include "mediagoblin/utils/report.html" %}
+    {% endif %}
 
     {% include "mediagoblin/utils/license.html" %}
 
index 2fa4f959a7e8beeaa77e6b96616b40799daf210c..3829de977771473ec5c537664e8f21b9a759a232 100644 (file)
 
 {% block report_content -%}
   <p>
-    <a
-      {% if not request.user -%}
-        href="{{ request.urlgen('mediagoblin.auth.login') }}"
-      {% else %}
-            href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_media',
+    <a href="{{ request.urlgen('mediagoblin.user_pages.media_home.report_media',
                             user=media.get_uploader.username,
                              media=media.slug_or_id) }}"
-      {% endif %}
         class="button_action" id="button_reportmedia" title="Report media">
         {% trans %}Report media{% endtrans %}
     </a>
index 0908cb3417cee3152a3f8d67cc8e0f567c6ad742..3bf36f5f7cd40f21855d8d007f17d99ffeacc956 100644 (file)
@@ -157,7 +157,8 @@ otherperson@example.com\n\nSGkgb3RoZXJwZXJzb24sCmNocmlzIGNvbW1lbnRlZCBvbiB5b3VyI
     def test_mark_all_comment_notifications_seen(self):
         """ Test that mark_all_comments_seen works"""
 
-        user = fixture_add_user('otherperson', password='nosreprehto')
+        user = fixture_add_user('otherperson', password='nosreprehto',
+                        privileges=[u'active'])
 
         media_entry = fixture_media_entry(uploader=user.id, state=u'processed')
 
index 23a2290e669d40d15aa95ce4e5ab6870b6b20cfc..3aea79822db0d25f77bd4ff9e82a25dbaa29f007 100644 (file)
@@ -237,7 +237,7 @@ class TestOpenIDPlugin(object):
     def test_add_delete(self, openid_plugin_app):
         """Test adding and deleting openids"""
         # Add user
-        test_user = fixture_add_user(password='')
+        test_user = fixture_add_user(password='', privileges=[u'active'])
         openid = OpenIDUserURL()
         openid.openid_url = 'http://real.myopenid.com'
         openid.user_id = test_user.id
index 3e9bf22fa338cb73c8936a60ab9233b7e65a38c6..a696858d2a44fbe401c9bda5f4b5aae69d8787fc 100644 (file)
@@ -22,6 +22,7 @@ pytest.importorskip("requests")
 
 from mediagoblin import mg_globals
 from mediagoblin.db.base import Session
+from mediagoblin.db.models import Privilege
 from mediagoblin.tests.tools import get_app
 from mediagoblin.tools import template
 
@@ -112,6 +113,9 @@ class TestPersonaPlugin(object):
             # Get user and detach from session
             test_user = mg_globals.database.User.query.filter_by(
                 username=u'chris').first()
+            active_privilege = Privilege.query.filter(
+                Privilege.privilege_name==u'active').first()
+            test_user.all_privileges.append(active_privilege)
             test_user.save()
             test_user = mg_globals.database.User.query.filter_by(
                 username=u'chris').first()
index b414a5802dfa9cd24011e85bc9e33e05d49adc50..a154a061d12a2899387a4adf8d4ff190875fd990 100644 (file)
@@ -160,7 +160,8 @@ class TestReportFiling:
         assert archived_report.reported_user_id == allie_id
         assert archived_report.created is not None
         assert archived_report.resolved is not None
-        assert archived_report.result == u'This is a test of archiving reports\
-.<br>natalie banned user allie indefinitely.<br>natalie deleted the comment.'
+        assert archived_report.result == u'''This is a test of archiving reports.
+natalie banned user allie indefinitely.
+natalie deleted the comment.'''
         assert archived_report.discriminator == 'comment_report'
 
index 4f55588496edc55f3d66bd8be114206fcf509011..e895e63489ea860004c9bcaeaa3519bf150b67ca 100644 (file)
@@ -37,7 +37,7 @@ from mediagoblin.decorators import (uses_pagination, get_user_media_entry,
     get_media_entry_by_id, user_has_privilege, user_not_banned,
     require_active_login, user_may_delete_media, user_may_alter_collection,
     get_user_collection, get_user_collection_item, active_user_from_url,
-    get_optional_media_comment_by_id)
+    get_optional_media_comment_by_id, allow_reporting)
 
 from werkzeug.contrib.atom import AtomFeed
 from werkzeug.exceptions import MethodNotAllowed
@@ -643,6 +643,7 @@ def processing_panel(request):
          'failed_entries': failed_entries,
          'processed_entries': processed_entries})
 
+@allow_reporting
 @get_user_media_entry
 @user_has_privilege(u'reporter')
 @get_optional_media_comment_by_id
@@ -682,4 +683,3 @@ def file_a_report(request, media, comment):
         request,
         'mediagoblin/user_pages/report.html',
         context)
-