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
This commit is contained in:
Rob Cresswell 2015-02-22 12:58:50 +00:00
parent 1f2f0c0cc9
commit 95fdaedc49
4 changed files with 20 additions and 47 deletions

View File

@ -1,27 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}change_password_modal{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:settings:password:index' %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% trans "Change your password. We highly recommend you create a strong one. " %}</p>
{% block modal_id %}change_password_modal{% endblock %}
{% block modal-header %}{% trans "Change Password" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Change your password. We highly recommend you create a strong one. " %}</p>
</div>
{% endblock %} {% endblock %}
{% block modal-footer %}
<button type="submit" class="btn btn-primary">{% trans "Change" %}</button>
{% if hide %}<a href="{% url 'horizon:settings:password:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>{% endif %}
{% endblock %}

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from horizon import forms from horizon import forms
@ -22,5 +23,10 @@ from openstack_dashboard.dashboards.settings.password \
class PasswordView(forms.ModalFormView): class PasswordView(forms.ModalFormView):
form_class = pass_forms.PasswordForm 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") page_title = _("Change Password")
submit_label = _("Change")
submit_url = reverse_lazy("horizon:settings:password:index")
template_name = 'settings/password/change.html'

View File

@ -1,26 +1,7 @@
{% extends "horizon/common/_modal_form.html" %} {% extends "horizon/common/_modal_form.html" %}
{% load i18n %} {% load i18n %}
{% load url from future %}
{% block form_id %}user_settings_modal{% endblock %} {% block modal-body-right %}
{% block form_action %}{% url 'horizon:settings:user:index' %}{% endblock %} <h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify dashboard settings for your user." %}</p>
{% block modal_id %}user_settings_modal{% endblock %}
{% block modal-header %}{% trans "User Settings" %}{% endblock %}
{% block modal-body %}
<div class="left">
<fieldset>
{% include "horizon/common/_form_fields.html" %}
</fieldset>
</div>
<div class="right">
<h3>{% trans "Description:" %}</h3>
<p>{% trans "Modify dashboard settings for your user." %}</p>
</div>
{% endblock %}
{% block modal-footer %}
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
{% if hide %}<a href="{% url 'horizon:settings:user:index' %}" class="btn btn-default secondary cancel close">{% trans "Cancel" %}</a>{% endif %}
{% endblock %} {% endblock %}

View File

@ -13,6 +13,7 @@
# under the License. # under the License.
from django.conf import settings from django.conf import settings
from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from horizon import forms from horizon import forms
@ -22,8 +23,13 @@ from openstack_dashboard.dashboards.settings.user import forms as user_forms
class UserSettingsView(forms.ModalFormView): class UserSettingsView(forms.ModalFormView):
form_class = user_forms.UserSettingsForm 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") 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): def get_initial(self):
return { return {