diff --git a/adagios/context_processors.py b/adagios/context_processors.py index 4b3c35e51..cd6309178 100644 --- a/adagios/context_processors.py +++ b/adagios/context_processors.py @@ -160,7 +160,7 @@ def resolve_urlname(request): request is within the template""" from django.core.urlresolvers import resolve try: - res = resolve(request.path) + res = resolve(request.path_info) if res: return {'urlname': res.url_name} except Exception: diff --git a/adagios/objectbrowser/templates/copy_object.html b/adagios/objectbrowser/templates/copy_object.html index 8045b654c..c569a631e 100644 --- a/adagios/objectbrowser/templates/copy_object.html +++ b/adagios/objectbrowser/templates/copy_object.html @@ -14,17 +14,17 @@
{% trans "Success!" %} - {% url edit_object i.id as the_url %} - {% blocktrans with type=i.object_type desc=u.description file=i.filename %} - {{ type }} "{{ desc }}" was successfully saved to {{ file }}. - {% endblocktrans %} + {% url edit_object object.id as the_url %} + {% blocktrans with type=object.object_type desc=object.description file=object.filename %} + {{ type }} "{{ desc }}" was successfully saved to {{ file }}. + {% endblocktrans %}
{% endfor %} {% else %}
- {% blocktrans with type=i.object_type desc=u.description %} - You are about to copy {{ type }} "{{ desc }}". - {% endblocktrans %} + {% blocktrans with type=object.object_type desc=object.description %} + You are about to copy {{ type }} "{{ desc }}". + {% endblocktrans %}

{% csrf_token %} diff --git a/adagios/status/templates/snippets/status_hostgrouplist_snippet.html b/adagios/status/templates/snippets/status_hostgrouplist_snippet.html index 958b23f95..06235674a 100644 --- a/adagios/status/templates/snippets/status_hostgrouplist_snippet.html +++ b/adagios/status/templates/snippets/status_hostgrouplist_snippet.html @@ -99,8 +99,4 @@ {% else %} {% endif %} - diff --git a/adagios/status/templates/snippets/status_hostlist_snippet.html b/adagios/status/templates/snippets/status_hostlist_snippet.html index 709158268..a747777cf 100644 --- a/adagios/status/templates/snippets/status_hostlist_snippet.html +++ b/adagios/status/templates/snippets/status_hostlist_snippet.html @@ -95,8 +95,4 @@ - diff --git a/adagios/status/templates/snippets/status_servicelist_snippet.html b/adagios/status/templates/snippets/status_servicelist_snippet.html index 05f914ffd..5553c5072 100644 --- a/adagios/status/templates/snippets/status_servicelist_snippet.html +++ b/adagios/status/templates/snippets/status_servicelist_snippet.html @@ -96,9 +96,4 @@ {% blocktrans with length=services|length %}{{ length }} objects found.{% endblocktrans %} - - diff --git a/adagios/status/utils.py b/adagios/status/utils.py index 202c33d8d..3b65f327a 100644 --- a/adagios/status/utils.py +++ b/adagios/status/utils.py @@ -232,10 +232,10 @@ def get_services(request=None, tags=None, fields=None, *args, **kwargs): # If q was added, it is a fuzzy filter on services for i in q: - arguments.append('Filter: host_name ~~ %s' % i) - arguments.append('Filter: description ~~ %s' % i) - arguments.append('Filter: plugin_output ~~ %s' % i) - arguments.append('Filter: host_address ~~ %s' % i) + arguments.append('Filter: host_name ~~ %s' % i.encode('utf-8')) + arguments.append('Filter: description ~~ %s' % i.encode('utf-8')) + arguments.append('Filter: plugin_output ~~ %s' % i.encode('utf-8')) + arguments.append('Filter: host_address ~~ %s' % i.encode('utf-8')) arguments.append('Or: 4') if fields is None: diff --git a/adagios/status/views.py b/adagios/status/views.py index ccf965f0a..ea36683a1 100644 --- a/adagios/status/views.py +++ b/adagios/status/views.py @@ -64,24 +64,26 @@ @adagios_decorator def detail(request): """ Return status detail view for a single given host, hostgroup,service, contact, etc """ - host_name = request.GET.get('host_name') - service_description = request.GET.get('service_description') - contact_name = request.GET.get('contact_name') - hostgroup_name = request.GET.get('hostgroup_name') - contactgroup_name = request.GET.get('contactgroup_name') - servicegroup_name = request.GET.get('servicegroup_name') - if service_description: - return service_detail(request, host_name=host_name, service_description=service_description) - elif host_name: - return host_detail(request, host_name=host_name) - elif contact_name: - return contact_detail(request, contact_name=contact_name) - elif contactgroup_name: - return contactgroup_detail(request, contactgroup_name=contactgroup_name) - elif hostgroup_name: - return hostgroup_detail(request, hostgroup_name=hostgroup_name) - elif servicegroup_name: - return servicegroup_detail(request, servicegroup_name=servicegroup_name) + args = {} + for query_parm in ['host_name', 'service_description', 'contact_name', + 'hostgroup_name', 'contactgroup_name', 'servicegroup_name']: + value = request.GET.get(query_parm) + if value: + args[query_parm] = value.encode('utf-8') + + if 'service_description' in args: + return service_detail(request, host_name=args['host_name'], + service_description=args['service_description']) + elif 'host_name' in args: + return host_detail(request, host_name=args['host_name']) + elif 'contact_name' in args: + return contact_detail(request, contact_name=args['contact_name']) + elif 'contactgroup_name' in args: + return contactgroup_detail(request, contactgroup_name=args['contactgroup_name']) + elif 'hostgroup_name' in args: + return hostgroup_detail(request, hostgroup_name=args['hostgroup_name']) + elif 'servicegroup_name' in args: + return servicegroup_detail(request, servicegroup_name=args['servicegroup_name']) raise Exception(_("You have to provide an item via querystring so we know what to give you details for")) @@ -1223,6 +1225,10 @@ def backends(request): @adagios_decorator def custom_view(request, viewname): + c = {} + c['messages'] = [] + c['errors'] = [] + def data_to_query(data): """ Transforms a view dict into a Livestatus query. @@ -1244,9 +1250,10 @@ def data_to_query(data): '%(columns)s' '%(filters)s' '%(stats)s') % d + # Remove uneeded linebreaks at the end: + query = query.strip() return query - c = {} # View management user = userdata.User(request) c['viewname'] = viewname @@ -1267,8 +1274,11 @@ def data_to_query(data): # the split is a workaround for pynag and the 'Stats:' clause c['data'] = livestatus.query(*livestatus_query.split('\n')) except Exception as e: - c['data'] = [] - c['errors'] = [_('Error in LiveStatus query'), e.message] + # Any exception in livestatus query here is a critical error + error = _('Error in LiveStatus query') + c['errors'].append(error) + c['errors'].append(e.message) + return error_page(request, c) # Data post-processing # sorting diff --git a/adagios/templates/base.html b/adagios/templates/base.html index f8bf25ac2..ad4d7bc3e 100644 --- a/adagios/templates/base.html +++ b/adagios/templates/base.html @@ -33,7 +33,7 @@ - + @@ -117,6 +117,7 @@ {% trans "Performance Data 2" %} {% trans "Business Intelligence" %} {% trans "Dashboard" %} + {% endblock left_sidebar %}