Merge branch 'master' into upstream-master
[mediagoblin.git] / mediagoblin / templates / mediagoblin / moderation / user.html
index ef48fe54ea135adb354fcbd5829de34412f8c2fc..6335ea1266fe3543c0be0f88b5c18da120904dfc 100644 (file)
@@ -16,7 +16,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #}
 {% extends "mediagoblin/base.html" %}
-
+{% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
 
 {% block title %}
   {%- if user -%}
   {%- endif -%}
 {% endblock %}
 
+{%- block mediagoblin_head %}
+ <script src="{{ request.staticdirect('/js/setup_report_forms.js') }}">
+ </script>
+{% endblock %}
 
 {% block mediagoblin_content -%}
   {# If no user... #}
   {% if not user %}
     <p>{% trans %}Sorry, no such user found.{% endtrans %}</p>
   {# User exists, but needs verification #}
-  {% elif user.status == "needs_email_verification" %}
-    <div class="form_box">
+  {% elif not user.has_privilege('active') %}
+    <div class="profile_sidebar empty_space">
     <h1>{% trans %}Email verification needed{% endtrans %}</h1>
     <p>
       {% trans -%}
       {%- endtrans %}
     </p>
 
-    <p>
-      {% trans login_url=request.urlgen('mediagoblin.auth.login') -%}
-        If you are that person but you've lost your verification email, you can
-        <a href="{{ login_url }}">log in</a> and resend it.
-      {%- endtrans %}
-    </p>
     </div>
 
   {# Active(?) (or at least verified at some point) user, horray! #}
     <h1>
       {%- trans username=user.username %}{{ username }}'s profile{% endtrans -%}
     {% if user_banned and user_banned.expiration_date %}
-      &mdash; BANNED until {{ user_banned.expiration_date }}
+      &mdash; {% trans expiration_date=user_banned.expiration_date -%}
+        BANNED until {{ expiration_date }}
+      {%- endtrans %}
     {% elif user_banned %}
-      &mdash; Banned Indefinitely
+      &mdash; {% trans %}Banned Indefinitely{% endtrans %}
     {% endif %}
     </h1>
     {% if not user.url and not user.bio %}
     </div>
   {% endif %}
   {% if user %}
-    <h2>{%- trans %}Active Reports on {% endtrans -%}{{ user.username }}</h2>
+    <h2>
+      {%- trans username=user.username -%}
+        Active Reports on {{ username }}
+      {%- endtrans -%}
+    </h2>
     {% if reports.count() %}
     <table class="admin_side_panel">
       <tr>
             <img src="{{ request.staticdirect('/images/icon_clipboard.png') }}" />
             <a href="{{ request.urlgen('mediagoblin.moderation.reports_detail',
                                                report_id=report.id) }}">
-              {%- trans %}Report #{% endtrans -%}{{ report.id }}
+              {%- trans report_number=report.id -%}
+                Report #{{ report_number }}
+              {%- endtrans -%}
             </a>
           </td>
           <td>
         <tr><td></td><td></td>
     </table>
     {% else %}
-      {%- trans %}No active reports filed on {% endtrans -%} {{ user.username }}
+      {%- trans username=user.username -%}
+        No active reports filed on {{ username }}
+      {%- endtrans -%}
     {% endif %}
-    <a class="right_align">{{ user.username }}'s report history</a>
+    <span class="right_align">
+        <a href="{{ request.urlgen(
+            'mediagoblin.moderation.reports') }}?reported_user={{user.id}}">
+        {%- trans
+            username=user.username %}All reports on {{ username }}{% endtrans %}</a>
+    &middot;
+        <a href="{{ request.urlgen(
+                'mediagoblin.moderation.reports') }}?reporter={{user.id}}">
+        {%- trans username=user.username -%}
+          All reports that {{ username }} has filed
+        {%- endtrans %}</a>
+    </span>
     <span class=clear></span>
-    <h2>{{ user.username }}'s Privileges</h2>
-    {% if request.user.has_privilege('admin') and not user_banned and 
-        not user.id == request.user.id %}
-        <input type=button class="button_action right_align" 
-               value="Ban User" />
-    {% elif request.user.has_privilege('admin') and
+    <h2>{% trans username=user.username -%}
+          {{ username }}'s Privileges{% endtrans %}</h2>
+      <form method=POST action="{{ request.urlgen(
+        'mediagoblin.moderation.ban_or_unban',
+        user=user.username) }}" class="right_align">
+        {{ csrf_token }}
+        {% if request.user.has_privilege('admin') and not user_banned and
             not user.id == request.user.id %}
-        <input type=button class="button_action right_align"
-               value="UnBan User" />
-    {% endif %}
+          {{ wtforms_util.render_divs(ban_form) }}
+          <input type=submit class="button_action"
+               value="{% trans %}Ban User{% endtrans %}"
+               id="ban_user_submit" />
+        {% elif request.user.has_privilege('admin') and
+            not user.id == request.user.id %}
+          <input type=submit class="button_action right_align"
+                 value="{% trans %}UnBan User{% endtrans %}" />
+        {% endif %}
+      </form>
     <form action="{{ request.urlgen('mediagoblin.moderation.give_or_take_away_privilege',
                user=user.username) }}"
           method=post >
             <td>{{ privilege.privilege_name }}</td>
             {% if privilege in user.all_privileges  %}
               <td class="user_with_privilege">
-                Yes{% else %}
+                {% trans %}Yes{% endtrans %}{% else %}
               <td class="user_without_privilege">
-                No{% endif %}
+                {% trans %}No{% endtrans %}{% endif %}
             </td>
             {% if request.user.has_privilege('admin') %}
               <td>
           </tr>
         {% endfor %}
     </table>
-       {{ csrf_token }}
+    {{ csrf_token }}
     <input type=hidden name=privilege_name id=hidden_privilege_name />
     </form>
   {% endif %}
@@ -181,6 +208,10 @@ $(document).ready(function(){
     $('.submit_button').click(function(){
         $('#hidden_privilege_name').val($(this).attr('id'));
     });
+    init_user_banned_form();
+    $('#ban_user_submit').click(function(){
+        submit_user_banned_form()
+    });
 });
     </script>
 {% endblock %}