From 68ee90d1a4c6b723afa663fd77b983ae5b9d7c3c Mon Sep 17 00:00:00 2001 From: Timur Nurlygayanov Date: Thu, 28 Feb 2013 05:49:31 -0500 Subject: [PATCH] Fixed small issues with WebUI. --- dashboard/windc/forms.py | 13 ++++++- dashboard/windc/tables.py | 34 +++++++++++++++++-- dashboard/windc/templates/windc/_dc_help.html | 3 +- .../windc/templates/windc/_services_tabs.html | 28 +++++++++++++++ dashboard/windc/urls.py | 11 ++++-- dashboard/windc/views.py | 22 ++++++++++-- dashboard/windc/workflows.py | 4 +-- 7 files changed, 103 insertions(+), 12 deletions(-) create mode 100644 dashboard/windc/templates/windc/_services_tabs.html diff --git a/dashboard/windc/forms.py b/dashboard/windc/forms.py index 7c1329fbc..d2ce98a0b 100644 --- a/dashboard/windc/forms.py +++ b/dashboard/windc/forms.py @@ -20,19 +20,30 @@ import logging +from django import forms from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ from openstack_dashboard import api -from horizon import exceptions from horizon import forms +from horizon import exceptions from horizon import messages +import pdb LOG = logging.getLogger(__name__) +class WizardForm1(forms.Form): + _type = forms.ChoiceField(label=_("Service Type")) + + +class WizardForm2(forms.Form): + subject = forms.CharField(max_length=100) + sender = forms.CharField(max_length=1) + + class UpdateWinDC(forms.SelfHandlingForm): tenant_id = forms.CharField(widget=forms.HiddenInput) data_center = forms.CharField(widget=forms.HiddenInput) diff --git a/dashboard/windc/tables.py b/dashboard/windc/tables.py index bf34d4bf9..ead8c21b7 100644 --- a/dashboard/windc/tables.py +++ b/dashboard/windc/tables.py @@ -116,6 +116,16 @@ class EditService(tables.LinkAction): return True +class Wizard(tables.LinkAction): + name = "wizard" + verbose_name = _("Wizard") + url = "horizon:project:windc:update" + classes = ("ajax-modal", "btn-edit") + + def allowed(self, request, instance): + return True + + class ShowDataCenterServices(tables.LinkAction): name = "edit" verbose_name = _("Services") @@ -144,18 +154,36 @@ class WinDCTable(tables.DataTable): name = "windc" verbose_name = _("Windows Data Centers") row_class = UpdateRow - table_actions = (CreateDataCenter,) + table_actions = (CreateDataCenter, Wizard) row_actions = (ShowDataCenterServices,DeleteDataCenter) +STATUS_DISPLAY_CHOICES = ( + ("create", "Deploy"), +) + + class WinServicesTable(tables.DataTable): - name = tables.Column('dc_name', verbose_name=_('Name')) + + STATUS_CHOICES = ( + (None, True), + ("deployed", True), + ("active", True), + ("error", False), + ) + + name = tables.Column('dc_name', verbose_name=_('Name'), + link=("horizon:project:windc:service_details"),) _type = tables.Column('type', verbose_name=_('Type')) - status = tables.Column('status', verbose_name=_('Status')) + status = tables.Column('status', verbose_name=_('Status'), + status=True, + status_choices=STATUS_CHOICES, + display_choices=STATUS_DISPLAY_CHOICES) class Meta: name = "services" verbose_name = _("Services") row_class = UpdateRow + status_columns = ['status'] table_actions = (CreateService,) row_actions = (EditService, DeleteService) diff --git a/dashboard/windc/templates/windc/_dc_help.html b/dashboard/windc/templates/windc/_dc_help.html index 1cb4efc57..5e29e2d24 100644 --- a/dashboard/windc/templates/windc/_dc_help.html +++ b/dashboard/windc/templates/windc/_dc_help.html @@ -1,2 +1,3 @@ {% load i18n %} -

{% blocktrans %}You can deploy few domain controllers with one name.{% endblocktrans %}

\ No newline at end of file +

{% blocktrans %}You can deploy few Active Directory services with one domain name.{% endblocktrans %}

+

{% blocktrans %}The DNS service will automatically created for each Active Directory.{% endblocktrans %}

\ No newline at end of file diff --git a/dashboard/windc/templates/windc/_services_tabs.html b/dashboard/windc/templates/windc/_services_tabs.html new file mode 100644 index 000000000..9839711e5 --- /dev/null +++ b/dashboard/windc/templates/windc/_services_tabs.html @@ -0,0 +1,28 @@ +{% extends "horizon/common/_modal_form.html" %} +{% load i18n %} +{% block modal-header %}{% trans "Create Service" %}{% endblock %} + +{% block modal-body %} +

Step {{ wizard.steps.step1 }} of {{ wizard.steps.count }}

+
{% csrf_token %} + +{{ wizard.management_form }} +{% if wizard.form.forms %} + {{ wizard.form.management_form }} + {% for form in wizard.form.forms %} + {{ form }} + {% endfor %} +{% else %} + {{ wizard.form }} +{% endif %} +{{ wizard.form.forms }} +
+{% if wizard.steps.prev %} + + +{% else %} + + +{% endif %} +
+{% endblock %} \ No newline at end of file diff --git a/dashboard/windc/urls.py b/dashboard/windc/urls.py index 6654ed228..a62393e30 100644 --- a/dashboard/windc/urls.py +++ b/dashboard/windc/urls.py @@ -21,7 +21,8 @@ from django.conf.urls.defaults import patterns, url from .views import IndexView, CreateWinDCView, WinServices, CreateWinServiceView - +from .views import Wizard +from .forms import WizardForm1, WizardForm2 VIEW_MOD = 'openstack_dashboard.dashboards.project.windc.views' @@ -29,6 +30,10 @@ urlpatterns = patterns(VIEW_MOD, url(r'^$', IndexView.as_view(), name='index'), url(r'^create$', CreateWinServiceView.as_view(), name='create'), url(r'^create_dc$', CreateWinDCView.as_view(), name='create_dc'), - url(r'^(?P[^/]+)/$', WinServices.as_view(), - name='services') + url(r'^(?P[^/]+)/$', WinServices.as_view(), + name='services'), + url(r'^update$', Wizard.as_view([WizardForm2, WizardForm2]), + name='update'), + url(r'^(?P[^/]+)/$', WinServices.as_view(), + name='service_details') ) diff --git a/dashboard/windc/views.py b/dashboard/windc/views.py index 9c34c29e9..92dc898cf 100644 --- a/dashboard/windc/views.py +++ b/dashboard/windc/views.py @@ -24,24 +24,42 @@ import logging from django import http from django import shortcuts +from django.views import generic from django.core.urlresolvers import reverse, reverse_lazy from django.utils.datastructures import SortedDict from django.utils.translation import ugettext_lazy as _ +from django.contrib.formtools.wizard.views import SessionWizardView from horizon import exceptions from horizon import forms from horizon import tabs from horizon import tables from horizon import workflows +from horizon.forms.views import ModalFormMixin from openstack_dashboard import api from .tables import WinDCTable, WinServicesTable from .workflows import CreateWinService, CreateWinDC +from .forms import WizardForm1, WizardForm2 - +import pdb LOG = logging.getLogger(__name__) +class Wizard(ModalFormMixin, SessionWizardView, generic.FormView): + template_name = 'project/windc/services_tabs.html' + + def done(self, form_list, **kwargs): + #do_something_with_the_form_data(form_list) + return HttpResponseRedirect('/') + + def get_form(self, step=None, data=None, files=None): + form = super(Wizard, self).get_form(step, data, files) + print step + print data + print files + return form + class IndexView(tables.DataTableView): table_class = WinDCTable template_name = 'project/windc/index.html' @@ -69,7 +87,7 @@ class WinServices(tables.DataTableView): def get_data(self): try: - dc_id = self.kwargs['domain_controller_id'] + dc_id = self.kwargs['data_center_id'] datacenter = api.windc.datacenters_get(self.request, dc_id) self.dc_name = datacenter.name services = api.windc.services_list(self.request, datacenter) diff --git a/dashboard/windc/workflows.py b/dashboard/windc/workflows.py index 4eb32e9df..e717866b7 100644 --- a/dashboard/windc/workflows.py +++ b/dashboard/windc/workflows.py @@ -88,7 +88,7 @@ class ConfigureWinDCAction(workflows.Action): # required=False, # help_text=_("A NetBIOS name of new domain.")) - dc_count = forms.IntegerField(label=_("Domain Controllers Count"), + dc_count = forms.IntegerField(label=_("Instances Count"), required=True, min_value=1, max_value=100, @@ -108,7 +108,7 @@ class ConfigureWinDCAction(workflows.Action): "Recovery Mode.")) class Meta: - name = _("Domain Controllers") + name = _("Active Directory") help_text_template = ("project/windc/_dc_help.html")