+@admin_tools_page(_("nodeman"), _("Node management"))
+def node_management(request):
+ nodes = Node.objects.all()
+
+ if (request.GET):
+ filter_form = NodeManFilterForm(request.GET)
+ else:
+ filter_form = NodeManFilterForm({'node_type': 'all', 'state_type': 'any'})
+
+ if filter_form.is_valid():
+ data = filter_form.cleaned_data
+
+ if data['node_type'] != 'all':
+ nodes = nodes.filter(node_type=data['node_type'])
+
+ if (data['state_type'] != 'any'):
+ nodes = nodes.filter_state(**{str(data['state_type']): True})
+
+ if data['text']:
+ filter = None
+
+ if data['text_in'] == 'title' or data['text_in'] == 'both':
+ filter = models.Q(title__icontains=data['text'])
+
+ if data['text_in'] == 'body' or data['text_in'] == 'both':
+ sec_filter = models.Q(body__icontains=data['text'])
+ if filter:
+ filter = filter | sec_filter
+ else:
+ filter = sec_filter
+
+ if filter:
+ nodes = nodes.filter(filter)
+
+
+ node_types = [('all', _("all"))] + [(k, n.friendly_name) for k, n in NodeMetaClass.types.items()]
+ state_types = NodeState.objects.filter(node__in=nodes).values_list('state_type', flat=True).distinct('state_type')
+
+ return ('osqaadmin/nodeman.html', pagination.paginated(request, ("nodes", ActivityPaginatorContext()), {
+ 'nodes': nodes,
+ 'node_types': node_types,
+ 'state_types': state_types,
+ 'filter_form': filter_form,
+ 'hide_menu': True
+ }))
+
+
+
+
+
+
+