I did some more code-keeping in this commit. I added a lot of documentation, so
[mediagoblin.git] / mediagoblin / templates / mediagoblin / moderation / user.html
1 {#
2 # GNU MediaGoblin -- federated, autonomous media hosting
3 # Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
14 #
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #}
18 {% extends "mediagoblin/base.html" %}
19 {% import "/mediagoblin/utils/wtforms.html" as wtforms_util %}
20
21 {% block title %}
22 {%- if user -%}
23 {%- trans username=user.username -%}
24 User: {{ username }}
25 {%- endtrans %} &mdash; {{ super() }}
26 {%- else -%}
27 {{ super() }}
28 {%- endif -%}
29 {% endblock %}
30
31 {%- block mediagoblin_head %}
32 <script src="{{ request.staticdirect('/js/setup_report_forms.js') }}"></script>
33 {% endblock %}
34
35 {% block mediagoblin_content -%}
36 {# If no user... #}
37 {% if not user %}
38 <p>{% trans %}Sorry, no such user found.{% endtrans %}</p>
39 {# User exists, but needs verification #}
40 {% elif user.status == "needs_email_verification" %}
41 <div class="form_box">
42 <h1>{% trans %}Email verification needed{% endtrans %}</h1>
43 <p>
44 {% trans -%}
45 Someone has registered an account with this username, but it still has
46 to be activated.
47 {%- endtrans %}
48 </p>
49
50 <p>
51 {% trans login_url=request.urlgen('mediagoblin.auth.login') -%}
52 If you are that person but you've lost your verification email, you can
53 <a href="{{ login_url }}">log in</a> and resend it.
54 {%- endtrans %}
55 </p>
56 </div>
57
58 {# Active(?) (or at least verified at some point) user, horray! #}
59 {% else %}
60 <a href="{{ request.urlgen('mediagoblin.moderation.users') }}"
61 class="return_to_panel button_action"
62 title="Return to Users Panel">
63 {% trans %}Return to Users Panel{% endtrans %}</a>
64 <h1>
65 {%- trans username=user.username %}{{ username }}'s profile{% endtrans -%}
66 {% if user_banned and user_banned.expiration_date %}
67 &mdash; BANNED until {{ user_banned.expiration_date }}
68 {% elif user_banned %}
69 &mdash; Banned Indefinitely
70 {% endif %}
71 </h1>
72 {% if not user.url and not user.bio %}
73 <div class="profile_sidebar empty_space">
74 <p>
75 {% trans -%}
76 This user hasn't filled in their profile (yet).
77 {%- endtrans %}
78 </p>
79 {% else %}
80 <div class="profile_sidebar">
81 {% include "mediagoblin/utils/profile.html" %}
82 {% if request.user and
83 (request.user.id == user.id or request.user.has_privilege('admin')) %}
84 <a href="{{ request.urlgen('mediagoblin.edit.profile',
85 user=user.username) }}">
86 {%- trans %}Edit profile{% endtrans -%}
87 </a>
88 {% endif %}
89 {% endif %}
90 <p>
91 <a href="{{ request.urlgen('mediagoblin.user_pages.collection_list',
92 user=user.username) }}">
93 {%- trans %}Browse collections{% endtrans -%}
94 </a>
95 </p>
96 </div>
97 {% endif %}
98 {% if user %}
99 <h2>{%- trans %}Active Reports on {% endtrans -%}{{ user.username }}</h2>
100 {% if reports.count() %}
101 <table class="admin_side_panel">
102 <tr>
103 <th>{%- trans %}Report ID{% endtrans -%}</th>
104 <th>{%- trans %}Reported Content{% endtrans -%}</th>
105 <th>{%- trans %}Description of Report{% endtrans -%}</th>
106 </tr>
107 {% for report in reports %}
108 <tr>
109 <td>
110 <img src="{{ request.staticdirect('/images/icon_clipboard.png') }}" />
111 <a href="{{ request.urlgen('mediagoblin.moderation.reports_detail',
112 report_id=report.id) }}">
113 {%- trans %}Report #{% endtrans -%}{{ report.id }}
114 </a>
115 </td>
116 <td>
117 {% if report.discriminator == "comment_report" %}
118 <a>{%- trans %}Reported Comment{% endtrans -%}</a>
119 {% elif report.discriminator == "media_report" %}
120 <a>{%- trans %}Reported Media Entry{% endtrans -%}</a>
121 {% endif %}
122 </td>
123 <td>{{ report.report_content[:21] }}
124 {% if report.report_content|count >20 %}...{% endif %}</td>
125 <td>{%- trans %}Resolve{% endtrans -%}</td>
126 </tr>
127 {% endfor %}
128 <tr><td></td><td></td>
129 </table>
130 {% else %}
131 {%- trans %}No active reports filed on {% endtrans -%} {{ user.username }}
132 {% endif %}
133 <a href="{{ request.urlgen('mediagoblin.moderation.reports') }}?active_reported_user={{user.id}}&closed_reported_user={{user.id}}"
134 class="right_align">{{ user.username }}'s report history</a>
135 <span class=clear></span>
136 <h2>{{ user.username }}'s Privileges</h2>
137 <form method=POST action="{{ request.urlgen(
138 'mediagoblin.moderation.ban_or_unban',
139 user=user.username) }}" class="right_align">
140 {{ csrf_token }}
141 {% if request.user.has_privilege('admin') and not user_banned and
142 not user.id == request.user.id %}
143 {{ wtforms_util.render_divs(ban_form) }}
144 <input type=submit class="button_action"
145 value="{% trans %}Ban User{% endtrans %}"
146 id="ban_user_submit" />
147 {% elif request.user.has_privilege('admin') and
148 not user.id == request.user.id %}
149 <input type=submit class="button_action right_align"
150 value="{% trans %}UnBan User{% endtrans %}" />
151 {% endif %}
152 </form>
153 <form action="{{ request.urlgen('mediagoblin.moderation.give_or_take_away_privilege',
154 user=user.username) }}"
155 method=post >
156 <table class="admin_side_panel">
157 <tr>
158 <th>{% trans %}Privilege{% endtrans %}</th>
159 <th>{% trans %}User Has Privilege{% endtrans %}</th>
160 </tr>
161 {% for privilege in privileges %}
162 <tr>
163 <td>{{ privilege.privilege_name }}</td>
164 {% if privilege in user.all_privileges %}
165 <td class="user_with_privilege">
166 Yes{% else %}
167 <td class="user_without_privilege">
168 No{% endif %}
169 </td>
170 {% if request.user.has_privilege('admin') %}
171 <td>
172 {% if privilege in user.all_privileges %}
173 <input type=submit id="{{ privilege.privilege_name }}"
174 class="submit_button button_action"
175 value =" -" />
176 {% else %}
177 <input type=submit id="{{ privilege.privilege_name }}"
178 class="submit_button button_action"
179 value ="+" />
180 {% endif %}
181 </td>
182 {% endif %}
183 </tr>
184 {% endfor %}
185 </table>
186 {{ csrf_token }}
187 <input type=hidden name=privilege_name id=hidden_privilege_name />
188 </form>
189 {% endif %}
190 <script>
191 $(document).ready(function(){
192 $('.submit_button').click(function(){
193 $('#hidden_privilege_name').val($(this).attr('id'));
194 });
195 init_user_banned_form();
196 $('#ban_user_submit').click(function(){
197 submit_user_banned_form()
198 });
199 });
200 </script>
201 {% endblock %}