From 842160cc3231a4c43407791e7f3a37055728460a Mon Sep 17 00:00:00 2001
From: Ole Laursen <olau@iola.dk>
Date: Tue, 27 Jan 2015 16:29:00 +0000
Subject: [PATCH] Summary: Facelift dbtemplate app, and fix a URL bug  -
 Legacy-Id: 8928

---
 .../templates/dbtemplate/template_edit.html   | 25 ++++++++++++-------
 .../templates/dbtemplate/template_list.html   |  4 +--
 ietf/dbtemplate/views.py                      |  9 +++----
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/ietf/dbtemplate/templates/dbtemplate/template_edit.html b/ietf/dbtemplate/templates/dbtemplate/template_edit.html
index fb4da59a1..267130bff 100644
--- a/ietf/dbtemplate/templates/dbtemplate/template_edit.html
+++ b/ietf/dbtemplate/templates/dbtemplate/template_edit.html
@@ -1,4 +1,6 @@
-{% extends "base.html" %}
+{% extends "ietf.html" %}
+
+{% load bootstrap3 %}
 
 {% block content %}
 <h1>Template: {{ template }}</h1>
@@ -12,15 +14,15 @@
   <dt>Template type</dt>
   <dd>{{ template.type.name }}
   {% if template.type.slug == "rst" %}
-  <p>This template uses the syntax of reStructuredText. Get a quick reference at <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">http://docutils.sourceforge.net/docs/user/rst/quickref.html</a>.</p>
-  <p>You can do variable interpolation with $varialbe if the template allows any variable.</p>
+  <p class="help-block">This template uses the syntax of reStructuredText. Get a quick reference at <a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">http://docutils.sourceforge.net/docs/user/rst/quickref.html</a>.</p>
+  <p class="help-block">You can do variable interpolation with $varialbe if the template allows any variable.</p>
   {% endif %}
   {% if template.type.slug == "django" %}
-  <p>This template uses the syntax of the default django template framework. Get more info at <a href="https://docs.djangoproject.com/en/dev/topics/templates/">https://docs.djangoproject.com/en/dev/topics/templates/</a>.</p>
-  <p>You can do variable interpolation with the current django markup &#123;&#123;variable&#125;&#125; if the template allows any variable.</p>
+  <p class="help-block">This template uses the syntax of the default django template framework. Get more info at <a href="https://docs.djangoproject.com/en/dev/topics/templates/">https://docs.djangoproject.com/en/dev/topics/templates/</a>.</p>
+  <p class="help-block">You can do variable interpolation with the current django markup &#123;&#123;variable&#125;&#125; if the template allows any variable.</p>
   {% endif %}
   {% if template.type.slug == "plain" %}
-  <p>This template uses plain text, so no markup is used. You can do variable interpolation with $variable if the template allows any variable.</p>
+  <p class="help-block">This template uses plain text, so no markup is used. You can do variable interpolation with $variable if the template allows any variable.</p>
   {% endif %}
   </dd>
   {% if template.variables %}
@@ -30,8 +32,13 @@
 </dl>
 
 <h2>Edit template content</h2>
-<form action="" method="post">{% csrf_token %}
-{{ form.as_p }}
-<input type="submit" value="Submit changes" />
+<form role="form" method="post">
+  {% csrf_token %}
+
+  {% bootstrap_form form %}
+
+  {% buttons %}
+    <button class="btn btn-default" type="submit">Save changes</button>
+  {% endbuttons %}
 </form>
 {% endblock content %}
diff --git a/ietf/dbtemplate/templates/dbtemplate/template_list.html b/ietf/dbtemplate/templates/dbtemplate/template_list.html
index dd2036bc6..8beb06c7b 100644
--- a/ietf/dbtemplate/templates/dbtemplate/template_list.html
+++ b/ietf/dbtemplate/templates/dbtemplate/template_list.html
@@ -1,4 +1,4 @@
-{% extends "base.html" %}
+{% extends "ietf.html" %}
 
 {% block content %}
 <h1>Defined templates for group {{ group }}</h1>
@@ -6,7 +6,7 @@
 {% if template_list %}
 <ul>
 {% for template in template_list %}
-  <li><a href="{% url template_edit group.acronym template.id %}">{{ template }}</a></li>
+  <li><a href="{% url "template_edit" group.acronym template.id %}">{{ template }}</a></li>
 {% endfor %}
 </ul>
 {% else %}
diff --git a/ietf/dbtemplate/views.py b/ietf/dbtemplate/views.py
index 95529c378..6986fffdc 100644
--- a/ietf/dbtemplate/views.py
+++ b/ietf/dbtemplate/views.py
@@ -1,6 +1,5 @@
 from django.http import HttpResponseForbidden, HttpResponseRedirect
-from django.shortcuts import get_object_or_404, render_to_response
-from django.template import RequestContext
+from django.shortcuts import get_object_or_404, render
 
 from ietf.dbtemplate.models import DBTemplate
 from ietf.dbtemplate.forms import DBTemplateForm
@@ -15,10 +14,10 @@ def template_list(request, acronym):
         return HttpResponseForbidden("You are not authorized to access this view")
 
     template_list = DBTemplate.objects.filter(group=group)
-    return render_to_response('dbtemplate/template_list.html',
+    return render(request, 'dbtemplate/template_list.html',
         {'template_list': template_list,
          'group': group,
-        }, RequestContext(request))
+        })
 
 
 def template_edit(request, acronym, template_id, base_template='dbtemplate/template_edit.html', formclass=DBTemplateForm, extra_context=None):
@@ -43,4 +42,4 @@ def template_edit(request, acronym, template_id, base_template='dbtemplate/templ
         'form': form,
     }
     context.update(extra_context)
-    return render_to_response(base_template, context, RequestContext(request))
+    return render(request, base_template, context)