summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/DBSettings.py38
-rw-r--r--src/lib/Bcfg2/Reporting/Compat.py4
-rw-r--r--src/lib/Bcfg2/Reporting/templates/clients/detail.html8
-rw-r--r--src/lib/Bcfg2/Reporting/templates/clients/detailed-list.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/clients/manage.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/config_items/common.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/config_items/entry_status.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/config_items/listing.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/displays/summary.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/displays/timing.html2
-rw-r--r--src/lib/Bcfg2/Reporting/templates/widgets/interaction_list.inc2
-rw-r--r--src/lib/Bcfg2/Reporting/views.py72
12 files changed, 75 insertions, 63 deletions
diff --git a/src/lib/Bcfg2/DBSettings.py b/src/lib/Bcfg2/DBSettings.py
index ddcf66b44..5d99d4ee2 100644
--- a/src/lib/Bcfg2/DBSettings.py
+++ b/src/lib/Bcfg2/DBSettings.py
@@ -56,15 +56,6 @@ settings = dict(
AUTHENTICATION_BACKENDS=('django.contrib.auth.backends.ModelBackend'),
LOGIN_URL='/login',
SESSION_EXPIRE_AT_BROWSER_CLOSE=True,
- TEMPLATE_DIRS=(
- '/usr/share/python-support/python-django/django/contrib/admin/'
- 'templates/'),
- TEMPLATE_CONTEXT_PROCESSORS=(
- 'django.contrib.auth.context_processors.auth',
- 'django.core.context_processors.debug',
- 'django.core.context_processors.i18n',
- 'django.core.context_processors.media',
- 'django.core.context_processors.request'),
DATABASE_ROUTERS=['Bcfg2.DBSettings.PerApplicationRouter'],
TEST_RUNNER='django.test.simple.DjangoTestSuiteRunner',
CACHES={
@@ -88,6 +79,35 @@ elif HAS_SOUTH:
'Reporting': 'Bcfg2.Reporting.south_migrations',
'Server': 'Bcfg2.Server.south_migrations',
}
+if HAS_DJANGO and django.VERSION[0] == 1 and django.VERSION[1] >= 8:
+ settings['TEMPLATES'] = [{
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [
+ '/usr/share/python-support/python-django/' +
+ 'django/contrib/admin/templates/'
+ ],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.contrib.auth.context_processors.auth',
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.i18n',
+ 'django.template.context_processors.media',
+ 'django.template.context_processors.request',
+ ],
+ },
+ }]
+else:
+ settings['TEMPLATE_DIRS'] = ('/usr/share/python-support/python-django/' +
+ 'django/contrib/admin/templates/')
+ settings['TEMPLATE_CONTEXT_PROCESSORS'] = (
+ 'django.contrib.auth.context_processors.auth',
+ 'django.core.context_processors.debug',
+ 'django.core.context_processors.i18n',
+ 'django.core.context_processors.media',
+ 'django.core.context_processors.request',
+ )
+
if 'BCFG2_LEGACY_MODELS' in os.environ:
settings['INSTALLED_APPS'] += ('Bcfg2.Server.Reports.reports',)
diff --git a/src/lib/Bcfg2/Reporting/Compat.py b/src/lib/Bcfg2/Reporting/Compat.py
index 9754314a7..a87a8e480 100644
--- a/src/lib/Bcfg2/Reporting/Compat.py
+++ b/src/lib/Bcfg2/Reporting/Compat.py
@@ -19,10 +19,10 @@ except ImportError:
from django.conf.urls import patterns
except:
# Django > 1.10
- def patterns(_prefix, urls):
+ def patterns(_prefix, *urls):
url_list = list()
for u in urls:
- if isinstance(url_tuple, (list, tuple)):
+ if isinstance(u, (list, tuple)):
u = url(*u)
url_list.append(u)
return url_list
diff --git a/src/lib/Bcfg2/Reporting/templates/clients/detail.html b/src/lib/Bcfg2/Reporting/templates/clients/detail.html
index 4258fc11d..5a638f2b1 100644
--- a/src/lib/Bcfg2/Reporting/templates/clients/detail.html
+++ b/src/lib/Bcfg2/Reporting/templates/clients/detail.html
@@ -73,7 +73,7 @@ span.history_links a {
</div>
<table id='groups_table' class='entry_list' style='display: none'>
{% endif %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='entry_list_type'>{{group}}</td>
</tr>
{% if forloop.last %}
@@ -91,7 +91,7 @@ span.history_links a {
</div>
<table id='bundles_table' class='entry_list' style='display: none'>
{% endif %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='entry_list_type'>{{bundle}}</td>
</tr>
{% if forloop.last %}
@@ -109,7 +109,7 @@ span.history_links a {
</div>
<table id='{{entry_type}}_table' class='entry_list'>
{% for entry in entry_list %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='entry_list_type'>{{entry.entry_type}}</td>
<td><a href="{% url "reports_item" entry.class_name entry.pk interaction.pk %}">
{{entry.name}}</a></td>
@@ -128,7 +128,7 @@ span.history_links a {
</div>
<table id='failures_table' class='entry_list' style='display: none'>
{% for failure in interaction.failures.all %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='entry_list_type'>{{failure.entry_type}}</td>
<td><a href="{% url "reports_item" failure.class_name failure.pk interaction.pk %}">
{{failure.name}}</a></td>
diff --git a/src/lib/Bcfg2/Reporting/templates/clients/detailed-list.html b/src/lib/Bcfg2/Reporting/templates/clients/detailed-list.html
index 56594554c..65c53a76c 100644
--- a/src/lib/Bcfg2/Reporting/templates/clients/detailed-list.html
+++ b/src/lib/Bcfg2/Reporting/templates/clients/detailed-list.html
@@ -21,7 +21,7 @@
<td class='right_column_wide'>{% sort_link 'server' 'Server' %}</td>
</tr>
{% for entry in entry_list %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='left_column'><a href='{% url "reports_client_detail_pk" hostname=entry.client.name pk=entry.id %}'>{{ entry.client.name }}</a></td>
<td class='right_column' style='width:75px'><a href='{% add_url_filter state=entry.state %}'
class='{{entry|determine_client_state}}'>{{ entry.state }}</a></td>
diff --git a/src/lib/Bcfg2/Reporting/templates/clients/manage.html b/src/lib/Bcfg2/Reporting/templates/clients/manage.html
index 2379cfe6a..3f080c52e 100644
--- a/src/lib/Bcfg2/Reporting/templates/clients/manage.html
+++ b/src/lib/Bcfg2/Reporting/templates/clients/manage.html
@@ -21,7 +21,7 @@
<td class='right_column_narrow'>Manage</td>
</tr>
{% for client in clients %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td><span id="{{ client.name }}"> </span>
<span id="ttag-{{ client.name }}"> </span>
<span id="s-ttag-{{ client.name }}"> </span>
diff --git a/src/lib/Bcfg2/Reporting/templates/config_items/common.html b/src/lib/Bcfg2/Reporting/templates/config_items/common.html
index 1445182be..8c2df8db1 100644
--- a/src/lib/Bcfg2/Reporting/templates/config_items/common.html
+++ b/src/lib/Bcfg2/Reporting/templates/config_items/common.html
@@ -28,7 +28,7 @@
<table id='table_{{ type_name }}' class='entry_list'>
<tr style='text-align: left'><th>Type</th><th>Name</th><th>Count</th><th>Reason</th></tr>
{% for item in type_list %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td>{{ item.ENTRY_TYPE }}</td>
<td><a href='{% url "reports_entry" item.class_name item.pk %}'>{{ item.name }}</a></td>
<td>{{ item.num_entries }}</td>
diff --git a/src/lib/Bcfg2/Reporting/templates/config_items/entry_status.html b/src/lib/Bcfg2/Reporting/templates/config_items/entry_status.html
index 160d9c738..4d9c42391 100644
--- a/src/lib/Bcfg2/Reporting/templates/config_items/entry_status.html
+++ b/src/lib/Bcfg2/Reporting/templates/config_items/entry_status.html
@@ -17,7 +17,7 @@
<tr style='text-align: left' ><th>Name</th><th>Timestamp</th><th>State</th><th>Reason</th></tr>
{% for item, inters in items %}
{% for inter in inters %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td><a href='{% url "reports_client_detail" hostname=inter.client.name %}'>{{inter.client.name}}</a></td>
<td><a href='{% url "reports_client_detail_pk" hostname=inter.client.name pk=inter.pk %}' style="white-space: nowrap;">
{{inter.timestamp|date:"SHORT_DATETIME_FORMAT"|safe}}
diff --git a/src/lib/Bcfg2/Reporting/templates/config_items/listing.html b/src/lib/Bcfg2/Reporting/templates/config_items/listing.html
index 1ae82dab5..b8fba61ce 100644
--- a/src/lib/Bcfg2/Reporting/templates/config_items/listing.html
+++ b/src/lib/Bcfg2/Reporting/templates/config_items/listing.html
@@ -21,7 +21,7 @@
<table id='table_{{ type_name }}' class='entry_list'>
<tr style='text-align: left' ><th>Name</th><th>Count</th><th>Reason</th></tr>
{% for entry in type_data %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td><a href='{% url "reports_entry" entry.class_name entry.pk %}'>{{entry.name}}</a></td>
<td>{{entry.num_entries}}</td>
<td><a href='{% url "reports_item" entry.class_name entry.pk %}'>{{entry.short_list|join:","}}</a></td>
diff --git a/src/lib/Bcfg2/Reporting/templates/displays/summary.html b/src/lib/Bcfg2/Reporting/templates/displays/summary.html
index 53f504c15..a9082aeee 100644
--- a/src/lib/Bcfg2/Reporting/templates/displays/summary.html
+++ b/src/lib/Bcfg2/Reporting/templates/displays/summary.html
@@ -30,7 +30,7 @@ hide_tables[{{ forloop.counter0 }}] = "table_{{ summary.name }}";
<table id='table_{{ summary.name }}' class='entry_list'>
{% for node in summary.nodes|sort_interactions_by_name %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td><a href='{% url "reports_client_detail_pk" hostname=node.client.name pk=node.id %}'>{{ node.client.name }}</a></td>
</tr>
{% endfor %}
diff --git a/src/lib/Bcfg2/Reporting/templates/displays/timing.html b/src/lib/Bcfg2/Reporting/templates/displays/timing.html
index 2d24fc1c2..69d56b62f 100644
--- a/src/lib/Bcfg2/Reporting/templates/displays/timing.html
+++ b/src/lib/Bcfg2/Reporting/templates/displays/timing.html
@@ -23,7 +23,7 @@
<td>Total</td>
</tr>
{% for metric in metrics|dictsort:"name" %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td><a style='font-size: 100%'
href='{% url "reports_client_detail" hostname=metric.name %}'>{{ metric.name }}</a></td>
{% for mitem in metric|build_metric_list %}
diff --git a/src/lib/Bcfg2/Reporting/templates/widgets/interaction_list.inc b/src/lib/Bcfg2/Reporting/templates/widgets/interaction_list.inc
index 90c5152ba..1dbcbf3f1 100644
--- a/src/lib/Bcfg2/Reporting/templates/widgets/interaction_list.inc
+++ b/src/lib/Bcfg2/Reporting/templates/widgets/interaction_list.inc
@@ -14,7 +14,7 @@
<td class='right_column_wide'>Server</td>
</tr>
{% for entry in entry_list %}
- <tr class='{% cycle listview,listview_alt %}'>
+ <tr class='{% cycle 'listview' 'listview_alt' %}'>
<td class='left_column'><a href='{% url "reports_client_detail_pk" hostname=entry.client.name pk=entry.id %}' class="white-space: nowrap;">
{{ entry.timestamp|date:"SHORT_DATETIME_FORMAT"|safe }}
</a></td>
diff --git a/src/lib/Bcfg2/Reporting/views.py b/src/lib/Bcfg2/Reporting/views.py
index 7d60e724a..3b9e2e53b 100644
--- a/src/lib/Bcfg2/Reporting/views.py
+++ b/src/lib/Bcfg2/Reporting/views.py
@@ -7,10 +7,10 @@ from datetime import datetime, timedelta
import sys
from time import strptime
-from django.template import Context, RequestContext
+from django.template import Context
from django.http import \
HttpResponse, HttpResponseRedirect, HttpResponseServerError, Http404
-from django.shortcuts import render_to_response, get_object_or_404
+from django.shortcuts import render, get_object_or_404
from django.core.urlresolvers import \
resolve, reverse, Resolver404, NoReverseMatch
from django.db import DatabaseError
@@ -166,11 +166,10 @@ def config_item(request, pk, entry_type, interaction=None):
template = 'config_items/item-failure.html'
else:
template = 'config_items/item.html'
- return render_to_response(template,
- {'item': item,
- 'associated_list': associated_list,
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
+ return render(request, template,
+ {'item': item,
+ 'associated_list': associated_list,
+ 'timestamp': timestamp})
@timeview
@@ -191,11 +190,10 @@ def config_item_list(request, item_state, timestamp=None, **kwargs):
# Property doesn't render properly..
lists.append((etype.ENTRY_TYPE, ldata))
- return render_to_response('config_items/listing.html',
- {'item_list': lists,
- 'item_state': item_state,
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
+ return render(request, 'config_items/listing.html',
+ {'item_list': lists,
+ 'item_state': item_state,
+ 'timestamp': timestamp})
@timeview
@@ -219,12 +217,10 @@ def entry_status(request, entry_type, pk, timestamp=None, **kwargs):
items.append((it, it.interaction_set.filter(pk__in=current_clients).order_by('client__name').select_related('client')))
seen.append(it.pk)
- return render_to_response('config_items/entry_status.html',
- {'entry': item,
- 'items': items,
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
-
+ return render(request, 'config_items/entry_status.html',
+ {'entry': item,
+ 'items': items,
+ 'timestamp': timestamp})
@timeview
def common_problems(request, timestamp=None, threshold=None, group=None):
@@ -262,11 +258,10 @@ def common_problems(request, timestamp=None, threshold=None, group=None):
# Property doesn't render properly..
lists.append((etype.ENTRY_TYPE, ldata))
- return render_to_response('config_items/common.html',
- {'lists': lists,
- 'timestamp': timestamp,
- 'threshold': threshold},
- context_instance=RequestContext(request))
+ return render(request, 'config_items/common.html',
+ {'lists': lists,
+ 'timestamp': timestamp,
+ 'threshold': threshold})
@timeview
@@ -281,10 +276,9 @@ def client_index(request, timestamp=None, **kwargs):
list = _handle_filters(Interaction.objects.recent(timestamp), **kwargs).\
select_related('client').order_by("client__name").all()
- return render_to_response('clients/index.html',
- {'inter_list': list,
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
+ return render(request, 'clients/index.html',
+ {'inter_list': list,
+ 'timestamp': timestamp})
@timeview
@@ -374,9 +368,9 @@ def client_manage(request):
client_name = "<none>"
message = "Couldn't find client \"%s\"" % client_name
- return render_to_response('clients/manage.html',
- {'clients': Client.objects.order_by('name').all(), 'message': message},
- context_instance=RequestContext(request))
+ return render(request, 'clients/manage.html',
+ {'clients': Client.objects.order_by('name').all(),
+ 'message': message})
@timeview
@@ -429,10 +423,10 @@ def display_summary(request, timestamp=None):
summary_data.append(get_dict('stale',
'nodes did not run within the last 24 hours.'))
- return render_to_response('displays/summary.html',
- {'summary_data': summary_data, 'node_count': node_count,
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
+ return render(request, 'displays/summary.html',
+ {'summary_data': summary_data,
+ 'node_count': node_count,
+ 'timestamp': timestamp})
@timeview
@@ -447,10 +441,9 @@ def display_timing(request, timestamp=None):
mdict[client] = { 'name': client }
mdict[client][perf.metric] = perf.value
- return render_to_response('displays/timing.html',
- {'metrics': list(mdict.values()),
- 'timestamp': timestamp},
- context_instance=RequestContext(request))
+ return render(request, 'displays/timing.html',
+ {'metrics': list(mdict.values()),
+ 'timestamp': timestamp})
def render_history_view(request, template='clients/history.html', **kwargs):
@@ -525,8 +518,7 @@ def render_history_view(request, template='clients/history.html', **kwargs):
else:
context['entry_list'] = iquery.all()
- return render_to_response(template, context,
- context_instance=RequestContext(request))
+ return render(request, template, context)
def prepare_paginated_list(request, context, paged_list, page=1, max_results=25):