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