1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
{% extends basetemplate %}
{% load i18n user_tags extra_tags extra_filters %}
{% block adminjs %}
<script type="text/javascript">
$(function() {
var $form = $('#changelist-search');
$('#all-node-type-link').click(function() {
$('#type-filter-container').find('input').remove();
$form.submit();
});
$('.node-type-link').click(function() {
var link_type = $(this).attr('href').substring(1);
if ($('#type-filter-container').find('input[value=' + link_type + ']').length == 0) {
$('#type-filter-container').append($("<input name=\"node_type\" type=\"hidden\" value=\"" + link_type + "\" />"));
} else {
$('#type-filter-container').find('input[value=' + link_type + ']').remove();
}
$form.submit();
});
$('#all-state-link').click(function() {
$('#state-filter-container').find('input').remove();
$form.submit();
});
$('.state-type-link').click(function() {
var state_type = $(this).attr('href').substring(1);
if ($('#state-filter-container').find('input[value=' + state_type + ']').length == 0) {
$('#state-filter-container').append($("<input name=\"state_type\" type=\"hidden\" value=\"" + state_type + "\" />"));
} else {
$('#state-filter-container').find('input[value=' + state_type + ']').remove();
}
$form.submit();
});
$('.action-select').change(function() {
$('#action-toggle').removeAttr('checked');
var $tr = $(this).parents('tr');
if ($(this).attr('checked')) {
$tr.addClass('selected');
} else {
$tr.removeClass('selected');
}
}).change();
$('#action-toggle').change(function() {
var $rows = $('#result_list').find('tbody').find('tr');
var $boxes = $('#result_list').find('tbody').find('input');
if ($(this).attr('checked')) {
$rows.addClass('selected');
$boxes.attr('checked', 'checked')
} else {
$rows.removeClass('selected');
$boxes.removeAttr('checked');
}
});
$('#author-selector').autocomplete('{% url matching_users %}', {
minChars: 1,
matchContains: true,
max: 10,
formatItem: function(row, i, max, value) {
return row[1] + ' (' + row[2] + ' {% trans "rep" %})';
},
formatResult: function(row, i, max, value){
return row[1];
}
});
$('#author-selector').result(function(event, data, formatted) {
if ($('#author-filter-container').find('input[value=' + data[0] + ']').length == 0) {
$('#author-filter-container').append($("<input name=\"authors\" type=\"hidden\" value=\"" + data[0] + "\" />"));
$form.submit();
}
});
$('.author-filter-remover').click(function() {
var id = $(this).attr('rel');
if ($('#author-filter-container').find('input[value=' + id + ']').length > 0) {
$('#author-filter-container').find('input[value=' + id + ']').remove();
$form.submit();
}
});
$('#tag-selector').autocomplete('{% url matching_tags %}', {
minChars: 1,
matchContains: true,
max: 10,
formatItem: function(row, i, max, value) {
return row[1] + ' (' + row[2] + ' {% trans "uses" %})';
},
formatResult: function(row, i, max, value){
return row[1];
}
});
$('#tag-selector').result(function(event, data, formatted) {
if ($('#tag-filter-container').find('input[value=' + data[0] + ']').length == 0) {
$('#tag-filter-container').append($("<input name=\"tags\" type=\"hidden\" value=\"" + data[0] + "\" />"));
$form.submit();
}
});
$('.tag-filter-remover').click(function() {
var id = $(this).attr('rel');
if ($('#tag-filter-container').find('input[value=' + id + ']').length > 0) {
$('#tag-filter-container').find('input[value=' + id + ']').remove();
$form.submit();
}
});
$('#filter-name-box').one('focus', function() {
$(this).val('');
$(this).css('color', 'black');
});
$('#filter-name-box').keyup(function() {
if ($(this).val().trim().length > 0) {
$('#save-filter-button').removeAttr('disabled');
$('#save-filter-button').css('color', 'black');
} else {
$('#save-filter-button').css('color', '#AAA');
$('#save-filter-button').attr('disabled', 'disabled');
}
});
var resize_data = null;
$('.col-resizer').mousedown(function(e) {
var $to_resize = $(this).prev();
resize_data = {
resizer: $(this),
to_resize: $to_resize,
start_width: $to_resize.innerWidth(),
x_start: e.pageX,
}
});
$('body').mousemove(function(e) {
if (resize_data != null) {
var new_size = (resize_data.start_width - (resize_data.x_start - e.pageX)) + 'px';
resize_data.to_resize.css({'max-width': new_size, 'min-width': new_size})
resize_data.resizer.css('max-width', '3px');
}
});
$('body').mouseup(function() {
if (resize_data != null)
resize_data = null;
});
$('#filter-panel-header').click(function() {
$('#filter-panel').slideToggle();
});
$('#state-filter-type').change(function() {
$('#state-filter-type-hidden').val($(this).val());
$form.submit();
});
$('#reset-text-filter').click(function() {
$('#text-filter-input').val('');
$form.submit();
return false;
});
});
</script>
<style>
#toolbar ul li {
list-style-type: none;
display: inline;
margin-right: 12px;
}
#result_list tr td.deleted {
background-color: #FDD;
border-bottom: 1px solid #a9a9a9;
}
#result_list tr td.accepted {
background-color: #DFD;
border-bottom: 1px solid #a9a9a9;
}
span.question-deleted {
text-decoration: line-through;
}
.col-resizer {
width: 2px;
min-width: 2px;
min-width: 2px;
cursor: col-resize;
padding: 0 0 0 0;
}
</style>
<script type="text/javascript">window.__admin_media_prefix__ = "{{ settings.ADMIN_MEDIA_PREFIX }}";</script>
<link href="{{ settings.ADMIN_MEDIA_PREFIX }}css/base.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript">
/* gettext identity library */
function gettext(msgid) { return msgid; }
function ngettext(singular, plural, count) { return (count == 1) ? singular : plural; }
function gettext_noop(msgid) { return msgid; }
function interpolate(fmt, obj, named) {
if (named) {
return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
} else {
return fmt.replace(/%s/g, function(match){return String(obj.shift())});
}
}
/* formatting library */
var formats = new Array();
formats['DATETIME_FORMAT'] = 'N j, Y, P';
formats['DATE_FORMAT'] = 'N j, Y';
formats['DECIMAL_SEPARATOR'] = '.';
formats['MONTH_DAY_FORMAT'] = 'F j';
formats['NUMBER_GROUPING'] = '0';
formats['TIME_FORMAT'] = 'P';
formats['FIRST_DAY_OF_WEEK'] = '0';
formats['TIME_INPUT_FORMATS'] = ['%H:%M:%S', '%H:%M'];
formats['THOUSAND_SEPARATOR'] = ',';
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'];
formats['YEAR_MONTH_FORMAT'] = 'F Y';
formats['SHORT_DATE_FORMAT'] = 'm/d/Y';
formats['SHORT_DATETIME_FORMAT'] = 'm/d/Y P';
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'];
function get_format(format_type) {
var value = formats[format_type];
if (typeof(value) == 'undefined') {
return msgid;
} else {
return value;
}
}
</script>
<script type="text/javascript" src="{{ settings.ADMIN_MEDIA_PREFIX }}js/core.js"></script>
{% endblock %}
{% block subtitle %}
{% trans "Node manager" %}
{% endblock %}
{% block description %}
{% trans "Nodes bulk management" %}
{% endblock %}
{% block admincontent %}
<div id="changelist" class="module filtered">
<div id="toolbar">
<form method="get" action="" id="changelist-search">
{% csrf_token %}
<div>
<div>
<label><img alt="Search" src="{{ settings.ADMIN_MEDIA_PREFIX }}img/admin/icon_searchbox.png"></label>
<input type="text" size="40" name="text" id="text-filter-input" value="{{ text }}">
<input type="submit" value="{% trans "Search" %}">
{% if text %}
<small><a href="#" id="reset-text-filter">{% trans "reset text filter" %}</a></small>
{% endif %}
<br />
<ul>
<li>
<label>
<input type="radio" name="text_in" value="title"{% ifequal text_in "title" %} checked="checked"{% endifequal %} />
{% trans "Title" %}</label>
</li>
<li>
<label>
<input type="radio" name="text_in" value="body"{% ifequal text_in "body" %} checked="checked"{% endifequal %} />
{% trans "Body" %}</label>
</li>
<li>
<label>
<input type="radio" name="text_in" value="both"{% ifequal text_in "both" %} checked="checked"{% endifequal %} />
{% trans "Title and Body" %}</label>
</li>
</ul>
</div>
</div>
<input type="hidden" name="sort" value="{{ nodes.paginator.current_sort }}" />
<input type="hidden" id="state-filter-type-hidden" name="state_filter_type" value="" />
<div style="display: none;" id="author-filter-container">
{% for u in authors %}
<input name="authors" type="hidden" value="{{ u.id }}" />
{% endfor %}
</div>
<div style="display: none;" id="tag-filter-container">
{% for t in tags %}
<input name="tags" type="hidden" value="{{ t.id }}" />
{% endfor %}
</div>
<div id="type-filter-container" style="display: none;">
{% for type in type_filter %}
<input name="node_type" type="hidden" value="{{ type }}" />
{% endfor %}
</div>
<div id="state-filter-container" style="display: none;">
{% for type in state_filter %}
<input name="state_type" type="hidden" value="{{ type }}" />
{% endfor %}
</div>
</form>
</div>
<div id="changelist-filter">
<h2 id="filter-panel-header">{% trans "Filter" %}<small> ({% trans "Click to show/hide" %})</small></h2>
<div id="filter-panel">
<h3>{% trans "By type" %}</h3>
<ul>
<li {% if not type_filter %} class="selected"{% endif %}>
<a id="all-node-type-link" href="#all" title="{% trans "click to clear the type filter" %}">{% trans "all" %}</a>
</li>
{% for type, name in node_types %}
<li{% if type|contained_in:type_filter %} class="selected" title="{% trans "click to remove from the filter" %}"{% else %} title="{% trans "click to add to the filter" %}"{% endif %}>
<a class="node-type-link" href="#{{ type }}">{{ name }}</a>
</li>
{% endfor %}
</ul>
<h3>{% trans "By state" %}</h3>
<ul>
<li {% if not state_filter %} class="selected"{% endif %}>
<a id="all-state-link" href="#any" title="{% trans "click to clear the state filter" %}">{% trans "any" %}</a>
</li>
{% for state_type in state_types %}
<li{% if state_type|contained_in:state_filter %} class="selected" title="{% trans "click to remove from the filter" %}"{% else %} title="{% trans "click to add to the filter" %}"{% endif %}>
<a class="state-type-link" href="#{{ state_type }}">{{ state_type }}</a>
</li>
{% endfor %}
<li>
<select id="state-filter-type">
<option value="any"{% ifequal state_filter_type "any" %} selected="selected"{% endifequal %}>{% trans "Match any selected" %}</option>
<option value="all"{% ifequal state_filter_type "all" %} selected="selected"{% endifequal %}>{% trans "Match all selected" %}</option>
</select>
</li>
</ul>
<h3>{% trans "By author(s)" %}</h3>
{% if not authors.count %}
<small>{% trans "No users selected, use the box bellow to add users to the filter." %}</small>
{% else %}
<ul>
{% for u in authors %}
<li class="selected">
<img class="author-filter-remover" rel="{{ u.id }}" src="{% media "/media/images/close-small-dark.png" %}">
{{ u.decorated_name }} ({{ u.reputation }})
</li>
{% endfor %}
</ul>
<small>{% trans "Click on the cross next to a user name to remove it from the filter." %}</small>
{% endif %}
<input type="text" size="20" autocomplete="off" id="author-selector" />
<h3>{% trans "By tag(s)" %}</h3>
{% if not tags.count %}
<small>{% trans "No tags selected, use the box bellow to add tags to the filter." %}</small>
{% else %}
<ul>
{% for t in tags %}
<li class="selected">
<img class="tag-filter-remover" rel="{{ t.id }}" src="{% media "/media/images/close-small-dark.png" %}">
{{ t.name }} ({{ t.used_count }})
</li>
{% endfor %}
</ul>
<small>{% trans "Click on the cross next to a tag name to remove it from the filter." %}</small>
{% endif %}
<input type="text" size="20" autocomplete="off" id="tag-selector" />
<h3>{% trans "Pre defined" %}</h3>
{% if not settings.NODE_MAN_FILTERS %}
<small>{% trans "There are no saved filters. Click bellow to add." %}</small>
{% endif %}
<ul id="pre-filter-container">
{% for name, uri in settings.NODE_MAN_FILTERS %}
<li class="selected"><a href="{% url admin_tools "nodeman" %}?{{ uri }}">{{ name }}</a></li>
{% endfor %}
</ul>
<form action="" method="POST">
{% csrf_token %}
<input name="filter_name" type="text" size="20" id="filter-name-box" style="color: #AAA;" value="{% trans "Filter name..." %}" />
<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>
</form>
{% comment %}<h3>{% trans "Show" %}</h3>
<form action="" method="get">
{% csrf_token %}
<div>{{ show_form.show }}</div>
<input type="submit" value="{% trans "Refresh" %}" />
</form>{% endcomment %}
</div>
</div>
<form id="changelist-form" method="POST" action="">
{% csrf_token %}
<div class="actions">
<label>
{% trans "Action" %}:
<select name="action">
<option selected="selected" value="">---------</option>
<option value="delete_selected">{% trans "Mark deleted" %}</option>
<option value="undelete_selected">{% trans "Undelete" %}</option>
<option value="hard_delete_selected">{% trans "Delete completely" %}</option>
<option value="close_selected">{% trans "Close (questions only)" %}</option>
</select>
</label>
<button value="0" name="execute" title="{% trans "Run the selected action" %}" class="button" type="submit">{% trans "Go" %}</button>
</div>
<table id="result_list" cellspacing="0">
<thead>
<tr>
{% declare %}
current_sort = nodes.paginator.current_sort
added_at = current_sort == "added_at" and "ascending" or (current_sort == "added_at_asc" and "descending" or "")
author = current_sort == "author" and "ascending" or (current_sort == "author_asc" and "descending" or "")
score = current_sort == "score" and "ascending" or (current_sort == "score_asc" and "descending" or "")
act_at = current_sort == "act_at" and "ascending" or (current_sort == "act_at_asc" and "descending" or "")
act_by = current_sort == "act_by" and "ascending" or (current_sort == "act_by_asc" and "descending" or "")
added_at_link = current_sort == "added_at" and nodes.paginator.added_at_asc_sort_link or nodes.paginator.added_at_sort_link
author_link = current_sort == "author_asc" and nodes.paginator.author_sort_link or nodes.paginator.author_asc_sort_link
act_at_link = current_sort == "act_at" and nodes.paginator.act_at_asc_sort_link or nodes.paginator.act_at_sort_link
act_by_link = current_sort == "act_by_asc" and nodes.paginator.act_by_sort_link or nodes.paginator.act_by_asc_sort_link
{% enddeclare %}
{% spaceless %}
<th class="action-checkbox-column">
<input type="checkbox" id="action-toggle" style="display: inline;" />
</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Summary" %}</th>
<th class="col-resizer"></th>
<th>{% trans "State" %}</th>
<th class="sorted {{ author }}">
<a href="{{ author_link }}">{% trans "Author" %}</a>
</th>
<th class="sorted {{ added_at }}">
<a href="{{ added_at_link }}">{% trans "Added at" %}</a>
</th>
{% comment %}
<th class="sorted {{ score }}">
<a href="{{ score_link }}">{% trans "Score" %}</a>
</th>
{% endcomment %}
<th class="sorted {{ act_by }}">
<a href="{{ act_by_link }}">{% trans "Last activity by" %}</a>
</th>
<th class="sorted {{ act_at }}">
<a href="{{ act_at_link }}">{% trans "Last activity at" %}</a>
</th>
<th>{% trans "Tags" %}</th>
{% endspaceless %}
</tr>
</thead>
<tbody>
{% with filter_form.state_type.data as state_type %}
{% for node in nodes.paginator.page %}
<tr class="{% cycle 'row1' 'row2' %}">
<td><input type="checkbox" name="_selected_node" value="{{ node.id }}" class="action-select"></td>
<td>{{ node.friendly_name }}</td>
{% declare %}
is_root = node.abs_parent == None
title = is_root and node.title or node.abs_parent.title
anchor = "<strong>%s</strong>" % html.hyperlink(node.get_absolute_url(), title)
anchor = ((not is_root) and node.abs_parent.nis.deleted) and "<span class=\"question-deleted\">%s</span>" % anchor or anchor
anchor = is_root and anchor or "(%s)" % anchor
anchor = html.mark_safe(anchor)
td_class = ""
td_class = node.nis.accepted and "accepted" or td_class
td_class = node.nis.deleted and "deleted" or td_class
{% enddeclare %}
<td class="{{ td_class }}" colspan="2">
{{ anchor }}<br />
{{ node.summary }}
</td>
<td>
{% for state in node.states.all %}
<b>{{ state.state_type }}</b> {% diff_date state.action.at %} {% trans "by" %}
<a target="_blank" href="{{ state.action.by.get_absolute_url }}">{{ state.action.by.decorated_name }}</a><br />
{% endfor %}
</td>
<td><a href="{{ node.author.get_absolute_url }}">{{ node.author.decorated_name }}</a></td>
<td>{% diff_date node.added_at %}</td>
<!--<td>{{ node.score }}</td>-->
<td><a href="{{ node.last_activity_by.get_absolute_url }}">{{ node.last_activity_by.decorated_name }}</a></td>
<td>{% diff_date node.last_activity_at %}</td>
<td>
{% for t in node.tags.all %}
{% if t|contained_in:tags %}<b>{{ t.name }}</b>
{% else %}{{ t.name }}{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
{% endwith %}
</tbody>
</table>
{{ nodes.paginator.page_numbers }}
</form>
</div>
{% endblock %}