]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/osqaadmin/nodeman.html
Adds the hability to hard delete nodes in the bulk manager, and renames the tool.
[osqa.git] / forum / skins / default / templates / osqaadmin / nodeman.html
1 {% extends basetemplate %}
2
3 {% load i18n user_tags extra_tags %}
4
5 {% block adminjs %}
6     <script type="text/javascript">
7         $(function() {
8             var $form = $('#changelist-search');
9
10             $('.node-type-link').click(function() {
11                 $form.find('#id_state_type').val('any');
12                 $form.find('#id_node_type').val($(this).attr('href').substring(1));
13                 $form.submit();
14             });
15
16             $('.state-type-link').click(function() {
17                 $form.find('#id_state_type').val($(this).attr('href').substring(1));
18                 $form.submit();
19             });
20
21             $('.action-select').change(function() {
22                 $('#action-toggle').removeAttr('checked');
23                 var $tr = $(this).parents('tr');
24                 if ($(this).attr('checked')) {
25                     $tr.addClass('selected');
26                 } else {
27                     $tr.removeClass('selected');
28                 }
29             }).change();
30
31             $('#action-toggle').change(function() {
32                 var $rows = $('#result_list').find('tbody').find('tr');
33                 var $boxes = $('#result_list').find('tbody').find('input');
34
35                 if ($(this).attr('checked')) {
36                     $rows.addClass('selected');
37                     $boxes.attr('checked', 'checked')
38                 } else {
39                     $rows.removeClass('selected');
40                     $boxes.removeAttr('checked');
41                 }
42             });
43
44             $('#author-selector').autocomplete('{% url matching_users %}', {
45                 minChars: 1,
46                 matchContains: true,
47                 max: 10,
48
49                 formatItem: function(row, i, max, value) {
50                     return row[1] + ' (' + row[2] + ' {% trans "rep" %})';
51                 },
52
53                 formatResult: function(row, i, max, value){
54                     return row[1];
55                 }
56             });
57
58             $('#author-selector').result(function(event, data, formatted) {
59                 if ($('#author-filter-container').find('input[value=' + data[0] + ']').length == 0) {
60                     $('#author-filter-container').append($("<input name=\"authors\" type=\"hidden\" value=\"" + data[0] + "\" />"));
61                     $form.submit();
62                 }
63             });
64
65             $('.author-filter-remover').click(function() {
66                 var id = $(this).attr('rel');
67                 if ($('#author-filter-container').find('input[value=' + id + ']').length > 0) {
68                     $('#author-filter-container').find('input[value=' + id + ']').remove();
69                     $form.submit();
70                 }
71             });
72
73             $('#tag-selector').autocomplete('{% url matching_tags %}', {
74                 minChars: 1,
75                 matchContains: true,
76                 max: 10,
77
78                 formatItem: function(row, i, max, value) {
79                     return row[1] + ' (' + row[2] + ' {% trans "uses" %})';
80                 },
81
82                 formatResult: function(row, i, max, value){
83                     return row[1];
84                 }
85             });
86
87             $('#tag-selector').result(function(event, data, formatted) {
88                 if ($('#tag-filter-container').find('input[value=' + data[0] + ']').length == 0) {
89                     $('#tag-filter-container').append($("<input name=\"tags\" type=\"hidden\" value=\"" + data[0] + "\" />"));
90                     $form.submit();
91                 }
92             });
93
94             $('.tag-filter-remover').click(function() {
95                 var id = $(this).attr('rel');
96                 if ($('#tag-filter-container').find('input[value=' + id + ']').length > 0) {
97                     $('#tag-filter-container').find('input[value=' + id + ']').remove();
98                     $form.submit();
99                 }
100             });
101
102             $('#filter-name-box').one('focus', function() {
103                 $(this).val('');
104                 $(this).css('color', 'black');
105             });
106
107             $('#filter-name-box').keyup(function() {
108                 if ($(this).val().trim().length > 0) {
109                     $('#save-filter-button').removeAttr('disabled');
110                     $('#save-filter-button').css('color', 'black');
111                 } else {
112                     $('#save-filter-button').css('color', '#AAA');
113                     $('#save-filter-button').attr('disabled', 'disabled');
114                 }
115             });
116
117         });
118     </script>
119     <style>
120         #toolbar ul li {
121             list-style-type: none;
122             display: inline;
123             margin-right: 12px;
124         }
125     </style>
126     <script type="text/javascript">window.__admin_media_prefix__ = "{{ settings.ADMIN_MEDIA_PREFIX }}";</script>
127     <link href="{{ settings.ADMIN_MEDIA_PREFIX }}css/base.css" rel="stylesheet" type="text/css" media="screen" />
128     <script type="text/javascript">
129     /* gettext identity library */
130
131     function gettext(msgid) { return msgid; }
132     function ngettext(singular, plural, count) { return (count == 1) ? singular : plural; }
133     function gettext_noop(msgid) { return msgid; }
134
135     function interpolate(fmt, obj, named) {
136       if (named) {
137         return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
138       } else {
139         return fmt.replace(/%s/g, function(match){return String(obj.shift())});
140       }
141     }
142
143     /* formatting library */
144
145     var formats = new Array();
146
147     formats['DATETIME_FORMAT'] = 'N j, Y, P';
148     formats['DATE_FORMAT'] = 'N j, Y';
149     formats['DECIMAL_SEPARATOR'] = '.';
150     formats['MONTH_DAY_FORMAT'] = 'F j';
151     formats['NUMBER_GROUPING'] = '0';
152     formats['TIME_FORMAT'] = 'P';
153     formats['FIRST_DAY_OF_WEEK'] = '0';
154     formats['TIME_INPUT_FORMATS'] = ['%H:%M:%S', '%H:%M'];
155     formats['THOUSAND_SEPARATOR'] = ',';
156     formats['DATE_INPUT_FORMATS'] = ['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', '%b %d %Y', '%b %d, %Y', '%d %b %Y', '%d %b, %Y', '%B %d %Y', '%B %d, %Y', '%d %B %Y', '%d %B, %Y'];
157     formats['YEAR_MONTH_FORMAT'] = 'F Y';
158     formats['SHORT_DATE_FORMAT'] = 'm/d/Y';
159     formats['SHORT_DATETIME_FORMAT'] = 'm/d/Y P';
160     formats['DATETIME_INPUT_FORMATS'] = ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', '%Y-%m-%d', '%m/%d/%Y %H:%M:%S', '%m/%d/%Y %H:%M', '%m/%d/%Y', '%m/%d/%y %H:%M:%S', '%m/%d/%y %H:%M', '%m/%d/%y'];
161
162     function get_format(format_type) {
163         var value = formats[format_type];
164         if (typeof(value) == 'undefined') {
165           return msgid;
166         } else {
167           return value;
168         }
169     }
170     
171     </script>
172     <script type="text/javascript" src="{{ settings.ADMIN_MEDIA_PREFIX }}js/core.js"></script>
173 {% endblock %}
174
175 {% block subtitle %}
176     {% trans "Node manager" %}
177 {% endblock %}
178 {% block description %}
179     {% trans "Nodes bulk management" %}
180 {% endblock %}
181
182 {% block admincontent %}
183     <div id="changelist" class="module filtered">
184         <div id="toolbar">
185             <form method="get" action="" id="changelist-search">
186             <div>
187                 <div>
188                     <label for="searchbar"><img alt="Search" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_searchbox.png"></label>
189                     {{ filter_form.text }}
190                     {{ filter_form.node_type }}
191                     {{ filter_form.state_type }}
192                     <input type="submit" value="{% trans "Search" %}"><br />
193                     {{ filter_form.text_in }}
194                 </div>
195             </div>
196             <input type="hidden" name="sort" value="{{ nodes.paginator.current_sort }}" />
197             <div style="display: none;" id="author-filter-container">
198                 {% for u in authors %}
199                 <input name="authors" type="hidden" value="{{ u.id }}" />
200                 {% endfor %}
201             </div>
202             <div style="display: none;" id="tag-filter-container">
203                 {% for t in tags %}
204                 <input name="tags" type="hidden" value="{{ t.id }}" />
205                 {% endfor %}
206             </div>
207             </form>
208         </div>
209         <div id="changelist-filter">
210             <h2>{% trans "Filter" %}</h2>
211             <h3>{% trans "By type" %}</h3>
212             <ul>
213                 {% for type, name in node_types %}
214                 <li{% ifequal filter_form.node_type.data type %} class="selected"{% endifequal %}>
215                     <a class="node-type-link" href="#{{ type }}">{{ name }}</a>
216                 </li>
217                 {% endfor %}
218             </ul>
219             <h3>{% trans "By state" %}</h3>
220             <ul>
221                 <li{% ifequal filter_form.state_type.data "any" %} class="selected"{% endifequal %}><a class="state-type-link" href="#any">{% trans "any" %}</a></li>
222                 {% for state_type in state_types %}
223                     <li{% ifequal filter_form.state_type.data state_type %} class="selected"{% endifequal %}>
224                         <a class="state-type-link" href="#{{ state_type }}">{{ state_type }}</a>
225                     </li>
226                 {% endfor %}
227             </ul>
228             <h3>{% trans "By author(s)" %}</h3>
229             {% if not authors.count %}
230                 <small>{% trans "No users selected, use the box bellow to add users to the filter." %}</small>
231             {% else %}
232                 <ul>
233                     {% for u in authors %}
234                         <li class="selected">
235                             <img class="author-filter-remover" rel="{{ u.id }}" src="{% media "/media/images/close-small-dark.png" %}">
236                             {{ u.decorated_name }} ({{ u.reputation }})
237                         </li>
238                     {% endfor %}
239                 </ul>
240                 <small>{% trans "Click on the cross next to a user name to remove it from the filter." %}</small>
241             {% endif %}
242             <input type="text" size="20" autocomplete="off" id="author-selector" />
243
244             <h3>{% trans "By tag(s)" %}</h3>
245             {% if not tags.count %}
246                 <small>{% trans "No tags selected, use the box bellow to add tags to the filter." %}</small>
247             {% else %}
248                 <ul>
249                     {% for t in tags %}
250                         <li class="selected">
251                             <img class="tag-filter-remover" rel="{{ t.id }}" src="{% media "/media/images/close-small-dark.png" %}">
252                             {{ t.name }} ({{ t.used_count }})
253                         </li>
254                     {% endfor %}
255                 </ul>
256                 <small>{% trans "Click on the cross next to a tag name to remove it from the filter." %}</small>
257             {% endif %}
258             <input type="text" size="20" autocomplete="off" id="tag-selector" />
259
260             <h3>{% trans "Pre defined" %}</h3>
261             {% if not settings.NODE_MAN_FILTERS %}
262                 <small>{% trans "There are no saved filters. Click bellow to add." %}</small>
263             {% endif %}
264             <ul id="pre-filter-container">
265                 {% for name, uri in settings.NODE_MAN_FILTERS %}
266                 <li class="selected"><a href="{% url admin_tools "nodeman" %}?{{ uri }}">{{ name }}</a></li>
267                 {% endfor %}
268             </ul>
269             <form action="" method="POST">
270                 <input name="filter_name" type="text" size="20" id="filter-name-box" style="color: #AAA;" value="{% trans "Filter name..." %}" />
271                 <button name="save_filter" value="0" style="color: #AAA;" title="{% trans "Click to save the current filter" %}" id="save-filter-button" disabled="disabled" class="button">{% trans "Save" %}</button>
272             </form>
273
274             {% comment %}<h3>{% trans "Show" %}</h3>
275             <form action="" method="get">
276                 <div>{{ show_form.show }}</div>
277                 <input type="submit" value="{% trans "Refresh" %}" />
278             </form>{% endcomment %}
279         </div>
280         <form id="changelist-form" method="POST" action="">
281             <div class="actions">
282                 <label>
283                     {% trans "Action" %}:
284                     <select name="action">
285                         <option selected="selected" value="">---------</option>
286                         <option value="delete_selected">{% trans "Mark deleted" %}</option>
287                         <option value="hard_delete_selected">{% trans "Delete completelly" %}</option>
288                         <option value="close_selected">{% trans "Close (questions only)" %}</option>
289                     </select>
290                 </label>
291                 <button value="0" name="execute" title="{% trans "Run the selected action" %}" class="button" type="submit">{% trans "Go" %}</button>
292             </div>
293             <table id="result_list" cellspacing="0">
294                 <thead>
295                     <tr>
296                         {% declare %}
297                             current_sort = nodes.paginator.current_sort
298                             added_at = current_sort == "added_at" and "descending" or (current_sort == "added_at_asc" and "ascending" or "")
299                             score = current_sort == "score" and "descending" or (current_sort == "score_asc" and "ascending" or "")
300                             act_at = current_sort == "act_at" and "descending" or (current_sort == "act_at_asc" and "ascending" or "")
301
302                             added_at_link = current_sort == "added_at" and nodes.paginator.added_at_asc_sort_link or nodes.paginator.added_at_sort_link
303                             score_link = current_sort == "score" and nodes.paginator.score_asc_sort_link or nodes.paginator.score_sort_link
304                             act_at_link = current_sort == "act_at" and nodes.paginator.act_at_asc_sort_link or nodes.paginator.act_at_sort_link
305                         {% enddeclare %}
306                         {% spaceless %}
307                         <th class="action-checkbox-column">
308                             <input type="checkbox" id="action-toggle" style="display: inline;" />
309                         </th>
310                         {% ifequal filter_form.node_type.data "all" %}
311                             <th>{% trans "Type" %}</th>
312                         {% endifequal %}
313                         <th>{% trans "Summary" %}</th>
314                         <th>{% trans "State" %}</th>
315                         <th>{% trans "Author" %}</th>
316                         <th class="sorted {{ added_at }}">
317                             <a href="{{ added_at_link }}">{% trans "Added at" %}</a>
318                         </th>
319                         <th class="sorted {{ score }}">
320                             <a href="{{ score_link }}">{% trans "Score" %}</a>
321                         </th>
322                         <th>{% trans "Last acivity by" %}</th>
323                         <th class="sorted {{ act_at }}">
324                             <a href="{{ act_at_link }}">{% trans "Last activity at" %}</a>
325                         </th>
326                         <th>{% trans "Tags" %}</th>
327                         {% endspaceless %}
328                     </tr>
329                 </thead>
330                 <tbody>
331                 {% for node in nodes.paginator.page %}
332                     <tr class="{% cycle 'row1' 'row2' %}">
333                         <td><input type="checkbox" name="_selected_node" value="{{ node.id }}" class="action-select"></td>
334                         {% ifequal filter_form.node_type.data "all" %}
335                             <th>{{ node.friendly_name }}</th>
336                         {% endifequal %}
337                         <td>
338                             <a href="{{ node.get_absolute_url }}" target="_blank">{{ node.headline }}</a><br />
339                             {{ node.summary }}
340                         </td>
341                         <td>{{ node.state_list|join:", " }}</td>
342                         <td><a href="{{ node.author.get_absolute_url  }}">{{ node.author.username }}</a></td>
343                         <td>{% diff_date node.added_at %}</td>
344                         <td>{{ node.score }}</td>
345                         <td><a href="{{ node.last_activity_by.get_absolute_url  }}">{{ node.last_activity_by.username }}</a></td>
346                         <td>{% diff_date node.last_activity_at %}</td>
347                         <td>
348                             {% for t in node.tags.all %}
349                                 {% if t in tags %}<b>{{ t.name }}</b>
350                                 {% else %}{{ t.name }}{% endif %}
351                             {% endfor %}
352                         </td>
353                     </tr>
354                 {% endfor %}
355                 </tbody>
356             </table>
357             {{ nodes.paginator.page_numbers }}
358         </form>
359     </div>
360 {% endblock %}