Refactored the templates code

Created generic template _workflow_base.html
in horizon/templates/horizon/common folder
with 'workflow.name' to replace multiple nearly
identical templates with different titles.

Implements blueprint dry-templates

Change-Id: Ieb14e263381020ed6604149ff9295f8cc814a9e6
This commit is contained in:
Tatiana Mazur
2013-05-06 15:27:50 +04:00
parent d17fd51359
commit 78923fbe6d
29 changed files with 27 additions and 185 deletions

View File

@@ -30,6 +30,7 @@ from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from .utils import get_int_or_uuid
from horizon.workflows.views import WorkflowView
INDEX_URL = reverse('horizon:project:access_and_security:index')
@@ -48,8 +49,7 @@ class FloatingIpViewTests(test.TestCase):
url = reverse('%s:associate' % NAMESPACE)
res = self.client.get(url)
self.assertTemplateUsed(res,
'project/access_and_security/floating_ips/associate.html')
self.assertTemplateUsed(res, WorkflowView.template_name)
workflow = res.context['workflow']
choices = dict(workflow.steps[0].action.fields['ip_id'].choices)
# Verify that our "associated" floating IP isn't in the choices list.

View File

@@ -38,7 +38,6 @@ from .workflows import IPAssociationWorkflow
class AssociateView(workflows.WorkflowView):
workflow_class = IPAssociationWorkflow
template_name = "project/access_and_security/floating_ips/associate.html"
class AllocateView(forms.ModalFormView):

View File

@@ -1,11 +0,0 @@
{% extends 'base.html' %}
{% load i18n %}
{% block title %}{% trans "Associate Floating IP" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Associate Floating IP") %}
{% endblock page_header %}
{% block main %}
{% include 'horizon/common/_workflow.html' %}
{% endblock %}

View File

@@ -27,6 +27,7 @@ from mox import IsA
from openstack_dashboard import api
from openstack_dashboard.test import helpers as test
from horizon.workflows.views import WorkflowView
class AccessAndSecurityTests(test.TestCase):
@@ -86,8 +87,7 @@ class AccessAndSecurityTests(test.TestCase):
res = self.client.get(reverse("horizon:project:access_and_security:"
"floating_ips:associate"))
self.assertTemplateUsed(res,
'project/access_and_security/floating_ips/associate.html')
self.assertTemplateUsed(res, WorkflowView.template_name)
self.assertContains(res,
'<option value="1">server_1 (1)</option>')