From 95fdaedc4980b06ac81e577872a46b55bf674c3d Mon Sep 17 00:00:00 2001 From: Rob Cresswell Date: Sun, 22 Feb 2015 12:58:50 +0000 Subject: [PATCH] Refactor modal forms for Settings dashboard Refactor of User settings & Password modals Based on merged patch: https://review.openstack.org/#/c/123472/ Change-Id: Ibadfda67edc6c8c2c0a9c42c7f0ec982497005ef Partially-Implements: blueprint form-template-to-view --- .../password/templates/password/_change.html | 26 +++---------------- .../dashboards/settings/password/views.py | 8 +++++- .../user/templates/user/_settings.html | 25 +++--------------- .../dashboards/settings/user/views.py | 8 +++++- 4 files changed, 20 insertions(+), 47 deletions(-) diff --git a/openstack_dashboard/dashboards/settings/password/templates/password/_change.html b/openstack_dashboard/dashboards/settings/password/templates/password/_change.html index 1ce08a1cba..897c6940e3 100644 --- a/openstack_dashboard/dashboards/settings/password/templates/password/_change.html +++ b/openstack_dashboard/dashboards/settings/password/templates/password/_change.html @@ -1,27 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}change_password_modal{% endblock %} -{% block form_action %}{% url 'horizon:settings:password:index' %}{% endblock %} - -{% block modal_id %}change_password_modal{% endblock %} -{% block modal-header %}{% trans "Change Password" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Change your password. We highly recommend you create a strong one. " %}

-
+{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "Change your password. We highly recommend you create a strong one. " %}

{% endblock %} - -{% block modal-footer %} - - {% if hide %}{% trans "Cancel" %}{% endif %} -{% endblock %} - diff --git a/openstack_dashboard/dashboards/settings/password/views.py b/openstack_dashboard/dashboards/settings/password/views.py index a21dfc02e0..2905371a32 100644 --- a/openstack_dashboard/dashboards/settings/password/views.py +++ b/openstack_dashboard/dashboards/settings/password/views.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ from horizon import forms @@ -22,5 +23,10 @@ from openstack_dashboard.dashboards.settings.password \ class PasswordView(forms.ModalFormView): form_class = pass_forms.PasswordForm - template_name = 'settings/password/change.html' + form_id = "change_password_modal" + modal_header = _("Change Password") + modal_id = "change_password_modal" page_title = _("Change Password") + submit_label = _("Change") + submit_url = reverse_lazy("horizon:settings:password:index") + template_name = 'settings/password/change.html' diff --git a/openstack_dashboard/dashboards/settings/user/templates/user/_settings.html b/openstack_dashboard/dashboards/settings/user/templates/user/_settings.html index 434ef2ef87..815e2a9796 100644 --- a/openstack_dashboard/dashboards/settings/user/templates/user/_settings.html +++ b/openstack_dashboard/dashboards/settings/user/templates/user/_settings.html @@ -1,26 +1,7 @@ {% extends "horizon/common/_modal_form.html" %} {% load i18n %} -{% load url from future %} -{% block form_id %}user_settings_modal{% endblock %} -{% block form_action %}{% url 'horizon:settings:user:index' %}{% endblock %} - -{% block modal_id %}user_settings_modal{% endblock %} -{% block modal-header %}{% trans "User Settings" %}{% endblock %} - -{% block modal-body %} -
-
- {% include "horizon/common/_form_fields.html" %} -
-
-
-

{% trans "Description:" %}

-

{% trans "Modify dashboard settings for your user." %}

-
-{% endblock %} - -{% block modal-footer %} - - {% if hide %}{% trans "Cancel" %}{% endif %} +{% block modal-body-right %} +

{% trans "Description:" %}

+

{% trans "Modify dashboard settings for your user." %}

{% endblock %} diff --git a/openstack_dashboard/dashboards/settings/user/views.py b/openstack_dashboard/dashboards/settings/user/views.py index 6f81435948..f692d6e744 100644 --- a/openstack_dashboard/dashboards/settings/user/views.py +++ b/openstack_dashboard/dashboards/settings/user/views.py @@ -13,6 +13,7 @@ # under the License. from django.conf import settings +from django.core.urlresolvers import reverse_lazy from django.utils.translation import ugettext_lazy as _ from horizon import forms @@ -22,8 +23,13 @@ from openstack_dashboard.dashboards.settings.user import forms as user_forms class UserSettingsView(forms.ModalFormView): form_class = user_forms.UserSettingsForm - template_name = 'settings/user/settings.html' + form_id = "user_settings_modal" + modal_header = _("User Settings") + modal_id = "user_settings_modal" page_title = _("User Settings") + submit_label = _("Save") + submit_url = reverse_lazy("horizon:settings:user:index") + template_name = 'settings/user/settings.html' def get_initial(self): return {