summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzu-Mainn Chen <tzumainn@redhat.com>2013-07-23 08:10:50 -0400
committerTomas Sedovic <tomas@sedovic.cz>2013-08-01 16:18:57 +0200
commit5a5b93ff563171737191e569b51b021d5c7e6435 (patch)
treedf322529b71d99a8435b3bba88f7cfc8c33aa8f3
parentd0f249c161cc5bfa91d326b407353204ac2a8d8c (diff)
downloadtuskar-ui-5a5b93ff563171737191e569b51b021d5c7e6435.tar.gz
added flavor detail action
Change-Id: Ia0daa1a208dfee00d33b2b5de15a89b50bbe39bf
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/flavors/urls.py7
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py14
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_edit.html4
-rw-r--r--openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/detail.html6
4 files changed, 26 insertions, 5 deletions
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/urls.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/urls.py
index 9c825cdd..aca72419 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/urls.py
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/urls.py
@@ -15,7 +15,8 @@
from django.conf.urls.defaults import patterns, url
-from .views import CreateView, DetailView, EditView, ActiveInstancesDataView
+from .views import (CreateView, DetailView, EditView,
+ DetailEditView, ActiveInstancesDataView)
FLAVORS = r'^(?P<flavor_id>[^/]+)/%s$'
@@ -24,7 +25,9 @@ VIEW_MOD = 'openstack_dashboard.dashboards.infrastructure.' \
urlpatterns = patterns(VIEW_MOD,
url(r'^create/$', CreateView.as_view(), name='create'),
- url(FLAVORS % '/edit/$', EditView.as_view(), name='edit'),
+ url(FLAVORS % 'edit/$', EditView.as_view(), name='edit'),
+ url(FLAVORS % 'detail_edit/$',
+ DetailEditView.as_view(), name='detail_edit'),
url(FLAVORS % 'detail', DetailView.as_view(), name='detail'),
url(FLAVORS % 'active_instances_data',
ActiveInstancesDataView.as_view(), name='active_instances_data')
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py
index 77c86c71..bd82666a 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py
@@ -18,7 +18,7 @@ import json
import logging
from django.core.serializers.json import DjangoJSONEncoder
-from django.core.urlresolvers import reverse_lazy
+from django.core.urlresolvers import reverse, reverse_lazy
from django.http import HttpResponse
from django.utils.translation import ugettext_lazy as _
from django.views.generic import View
@@ -47,12 +47,15 @@ class CreateView(forms.ModalFormView):
class EditView(forms.ModalFormView):
form_class = EditFlavor
template_name = 'infrastructure/resource_management/flavors/edit.html'
+ form_url = 'horizon:infrastructure:resource_management:flavors:edit'
success_url = reverse_lazy(
'horizon:infrastructure:resource_management:index')
def get_context_data(self, **kwargs):
context = super(EditView, self).get_context_data(**kwargs)
context['flavor_id'] = self.kwargs['flavor_id']
+ context['form_url'] = self.form_url
+ context['success_url'] = self.get_success_url()
return context
def get_initial(self):
@@ -71,6 +74,15 @@ class EditView(forms.ModalFormView):
'swap_disk': flavor.swap_disk.value}
+class DetailEditView(EditView):
+ form_url = 'horizon:infrastructure:resource_management:flavors:detail_edit'
+ success_url = 'horizon:infrastructure:resource_management:flavors:detail'
+
+ def get_success_url(self):
+ return reverse(self.success_url,
+ args=(self.kwargs['flavor_id'],))
+
+
class DetailView(tabs.TabView):
tab_group_class = FlavorDetailTabs
template_name = 'infrastructure/resource_management/flavors/detail.html'
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_edit.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_edit.html
index 15447f30..44740745 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_edit.html
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/_edit.html
@@ -3,7 +3,7 @@
{% load url from future %}
{% block form_id %}edit_flavor_form{% endblock %}
-{% block form_action %}{% url 'horizon:infrastructure:resource_management:flavors:edit' flavor_id %}{% endblock %}
+{% block form_action %}{% url form_url flavor_id %}{% endblock %}
{% block modal_id %}edit_flavor_modal{% endblock %}
{% block modal-header %}{% trans "Edit Flavor" %}{% endblock %}
@@ -23,5 +23,5 @@
{% block modal-footer %}
<input class="btn btn-primary pull-right" type="submit" value="{% trans "Save" %}" />
- <a href="{% url 'horizon:infrastructure:resource_management:index' %}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
+ <a href="{{ success_url }}" class="btn secondary cancel close">{% trans "Cancel" %}</a>
{% endblock %}
diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/detail.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/detail.html
index dff5156a..02a948b8 100644
--- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/detail.html
+++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/flavors/detail.html
@@ -6,6 +6,12 @@
{% include "horizon/common/_page_header.html" with title=_("Flavor Detail") %}
{% endblock page_header %}
+{% block actions %}
+ <div class="btn-group">
+ <a class="btn ajax-modal" href="{% url 'horizon:infrastructure:resource_management:flavors:detail_edit' flavor.id %}">{% trans "Edit" %}</a>
+ </div>
+{% endblock %}
+
{% block breadcrumbs %}
<div class="breadcrumbs">
<a href="{% url 'horizon:infrastructure:resource_management:index' %}?tab=resource_management_tabs__resource_classes_tab" >Home</a>