Summary: Facelift dbtemplate app, and fix a URL bug

- Legacy-Id: 8928
This commit is contained in:
Ole Laursen 2015-01-27 16:29:00 +00:00
parent 336cc1bd14
commit 842160cc32
3 changed files with 22 additions and 16 deletions

View file

@ -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 %}

View file

@ -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 %}

View file

@ -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)