]> git.openstreetmap.org Git - osqa.git/blob - forum/skins/default/templates/osqaadmin/nodeman.html
174d8bf71f313d085a3139e0d8b8f2ddc4ab6499
[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         });
103     </script>
104     <style>
105         #toolbar ul li {
106             list-style-type: none;
107             display: inline;
108             margin-right: 12px;
109         }
110     </style>
111     <script type="text/javascript">window.__admin_media_prefix__ = "{{ settings.ADMIN_MEDIA_PREFIX }}";</script>
112     <link href="{{ settings.ADMIN_MEDIA_PREFIX }}css/base.css" rel="stylesheet" type="text/css" media="screen" />
113     <script type="text/javascript">
114     /* gettext identity library */
115
116     function gettext(msgid) { return msgid; }
117     function ngettext(singular, plural, count) { return (count == 1) ? singular : plural; }
118     function gettext_noop(msgid) { return msgid; }
119
120     function interpolate(fmt, obj, named) {
121       if (named) {
122         return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
123       } else {
124         return fmt.replace(/%s/g, function(match){return String(obj.shift())});
125       }
126     }
127
128     /* formatting library */
129
130     var formats = new Array();
131
132     formats['DATETIME_FORMAT'] = 'N j, Y, P';
133     formats['DATE_FORMAT'] = 'N j, Y';
134     formats['DECIMAL_SEPARATOR'] = '.';
135     formats['MONTH_DAY_FORMAT'] = 'F j';
136     formats['NUMBER_GROUPING'] = '0';
137     formats['TIME_FORMAT'] = 'P';
138     formats['FIRST_DAY_OF_WEEK'] = '0';
139     formats['TIME_INPUT_FORMATS'] = ['%H:%M:%S', '%H:%M'];
140     formats['THOUSAND_SEPARATOR'] = ',';
141     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'];
142     formats['YEAR_MONTH_FORMAT'] = 'F Y';
143     formats['SHORT_DATE_FORMAT'] = 'm/d/Y';
144     formats['SHORT_DATETIME_FORMAT'] = 'm/d/Y P';
145     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'];
146
147     function get_format(format_type) {
148         var value = formats[format_type];
149         if (typeof(value) == 'undefined') {
150           return msgid;
151         } else {
152           return value;
153         }
154     }
155     
156     </script>
157     <script type="text/javascript" src="{{ settings.ADMIN_MEDIA_PREFIX }}js/core.js"></script>
158 {% endblock %}
159
160 {% block subtitle %}
161     {% trans "Node manager" %}
162 {% endblock %}
163 {% block description %}
164     {% trans "Nodes bulk management" %}
165 {% endblock %}
166
167 {% block admincontent %}
168     <div id="changelist" class="module filtered">
169         <div id="toolbar">
170             <form method="get" action="" id="changelist-search">
171             <div>
172                 <div>
173                     <label for="searchbar"><img alt="Search" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_searchbox.png"></label>
174                     {{ filter_form.text }}
175                     {{ filter_form.node_type }}
176                     {{ filter_form.state_type }}
177                     <input type="submit" value="{% trans "Search" %}"><br />
178                     {{ filter_form.text_in }}
179                 </div>
180             </div>
181             <div style="display: none;" id="author-filter-container">
182                 {% for u in authors %}
183                 <input name="authors" type="hidden" value="{{ u.id }}" />
184                 {% endfor %}
185             </div>
186             <div style="display: none;" id="tag-filter-container">
187                 {% for t in tags %}
188                 <input name="tags" type="hidden" value="{{ t.id }}" />
189                 {% endfor %}
190             </div>
191             </form>
192         </div>
193         <div id="changelist-filter">
194             <h2>{% trans "Filter" %}</h2>
195             <h3>{% trans "By type" %}</h3>
196             <ul>
197                 {% for type, name in node_types %}
198                 <li{% ifequal filter_form.node_type.data type %} class="selected"{% endifequal %}>
199                     <a class="node-type-link" href="#{{ type }}">{{ name }}</a>
200                 </li>
201                 {% endfor %}
202             </ul>
203             <h3>{% trans "By state" %}</h3>
204             <ul>
205                 <li{% ifequal filter_form.state_type.data "any" %} class="selected"{% endifequal %}><a class="state-type-link" href="#any">{% trans "any" %}</a></li>
206                 {% for state_type in state_types %}
207                     <li{% ifequal filter_form.state_type.data state_type %} class="selected"{% endifequal %}>
208                         <a class="state-type-link" href="#{{ state_type }}">{{ state_type }}</a>
209                     </li>
210                 {% endfor %}
211             </ul>
212             <h3>{% trans "By author(s)" %}</h3>
213             {% if not authors.count %}
214                 <small>{% trans "No users selected, use the box bellow to add users to the filter." %}</small>
215             {% else %}
216                 <ul>
217                     {% for u in authors %}
218                         <li class="selected">
219                             <img class="author-filter-remover" rel="{{ u.id }}" src="{% media "/media/images/close-small-dark.png" %}">
220                             {{ u.decorated_name }} ({{ u.reputation }})
221                         </li>
222                     {% endfor %}
223                 </ul>
224                 <small>{% trans "Click on the cross next to a user name to remove it from the filter." %}</small>
225             {% endif %}
226             <input type="text" size="20" autocomplete="off" id="author-selector" />
227
228             <h3>{% trans "By tag(s)" %}</h3>
229             {% if not tags.count %}
230                 <small>{% trans "No tags selected, use the box bellow to add tags to the filter." %}</small>
231             {% else %}
232                 <ul>
233                     {% for t in tags %}
234                         <li class="selected">
235                             <img class="tag-filter-remover" rel="{{ t.id }}" src="{% media "/media/images/close-small-dark.png" %}">
236                             {{ t.name }} ({{ t.used_count }})
237                         </li>
238                     {% endfor %}
239                 </ul>
240                 <small>{% trans "Click on the cross next to a tag name to remove it from the filter." %}</small>
241             {% endif %}
242             <input type="text" size="20" autocomplete="off" id="tag-selector" />
243             {% comment %}<h3>{% trans "Show" %}</h3>
244             <form action="" method="get">
245                 <div>{{ show_form.show }}</div>
246                 <input type="submit" value="{% trans "Refresh" %}" />
247             </form>{% endcomment %}
248         </div>
249         <form id="changelist-form" method="POST" action="">
250             <div class="actions">
251                 <label>
252                     {% trans "Action" %}:
253                     <select name="action">
254                         <option selected="selected" value="">---------</option>
255                         <option value="delete_selected">{% trans "Mark deleted" %}</option>
256                         <!--<option value="hard_delete_selected">{% trans "Delete completelly" %}</option>-->
257                         <option value="close_selected">{% trans "Close (questions only)" %}</option>
258                     </select>
259                 </label>
260                 <button value="0" name="index" title="{% trans "Run the selected action" %}" class="button" type="submit">{% trans "Go" %}</button>
261             </div>
262             <table id="result_list" cellspacing="0">
263                 <thead>
264                     <tr>
265                         {% spaceless %}
266                         <th class="action-checkbox-column">
267                             <input type="checkbox" id="action-toggle" style="display: inline;" />
268                         </th>
269                         {% ifequal filter_form.node_type.data "all" %}
270                             <th>{% trans "Type" %}</th>
271                         {% endifequal %}
272                         <th class="sorted{% ifequal nodes.paginator.current_sort "title" %} ascending{% endifequal %}">
273                             <a href="{{ nodes.paginator.title_sort_link }}">{% trans "Title" %}</a>
274                         </th>
275                         <th>{% trans "Author" %}</th>
276                         <th class="sorted{% ifequal nodes.paginator.current_sort "added_at" %} ascending{% endifequal %}">
277                             <a href="{{ nodes.paginator.added_at_sort_link }}">{% trans "Added at" %}</a>
278                         </th>
279                         <th class="sorted{% ifequal nodes.paginator.current_sort "score" %} ascending{% endifequal %}">
280                             <a href="{{ nodes.paginator.score_sort_link }}">{% trans "Score" %}</a>
281                         </th>
282                         <th>{% trans "Last acivity by" %}</th>
283                         <th class="sorted{% ifequal nodes.paginator.current_sort "act_at" %} ascending{% endifequal %}">
284                             <a href="{{ nodes.paginator.act_at_sort_link }}">{% trans "Last activity at" %}</a>
285                         </th>
286                         <th>{% trans "Tags" %}</th>
287                         <th>{% trans "State" %}</th>
288                         {% endspaceless %}
289                     </tr>
290                 </thead>
291                 <tbody>
292                 {% for node in nodes.paginator.page %}
293                     <tr class="{% cycle 'row1' 'row2' %}">
294                         <td><input type="checkbox" name="_selected_node" value="{{ node.id }}" class="action-select"></td>
295                         {% ifequal filter_form.node_type.data "all" %}
296                             <th>{{ node.friendly_name }}</th>
297                         {% endifequal %}
298                         <td><a href="{{ node.get_absolute_url }}" title="{{ node.summary }}" target="_blank">{{ node.headline }}</a></td>
299                         <td><a href="{{ node.author.get_absolute_url  }}">{{ node.author.username }}</a></td>
300                         <td>{% diff_date node.added_at %}</td>
301                         <td>{{ node.score }}</td>
302                         <td><a href="{{ node.last_activity_by.get_absolute_url  }}">{{ node.last_activity_by.username }}</a></td>
303                         <td>{% diff_date node.last_activity_at %}</td>
304                         <td>
305                             {% for t in node.tags.all %}
306                                 {% if t in tags %}<b>{{ t.name }}</b>
307                                 {% else %}{{ t.name }}{% endif %}
308                             {% endfor %}
309                         </td>
310                         <td>{{ node.state_list|join:", " }}</td>
311                     </tr>
312                 {% endfor %}
313                 </tbody>
314             </table>
315             {{ nodes.paginator.page_numbers }}
316         </form>
317     </div>
318 {% endblock %}