In the creation wizard (for account creation), added step title and counter.

fixes #216
This commit is contained in:
Antoine Nguyen
2012-04-06 15:31:45 +02:00
parent 1d38e89007
commit 342196b935
4 changed files with 17 additions and 10 deletions
+9 -6
View File
@@ -293,19 +293,21 @@ def newaccount(request, tplname='admin/newaccount.html'):
submit_label=_("Create")
)
cwizard = CreationWizard(create_account)
cwizard.add_step(AccountFormGeneralPwd,
buttons=[dict(classes="btn-inverse next", label=_("Next"))],
cwizard.add_step(AccountFormGeneralPwd, _("General"),
[dict(classes="btn-inverse next", label=_("Next"))],
new_args=[request.user])
cwizard.add_step(AccountFormMail,
buttons=[dict(classes="btn-primary submit", label=_("Create")),
dict(classes="btn-inverse prev", label=_("Previous"))])
cwizard.add_step(AccountFormMail, _("Mail"),
[dict(classes="btn-primary submit", label=_("Create")),
dict(classes="btn-inverse prev", label=_("Previous"))])
if request.method == "POST":
retcode, data = cwizard.validate_step(request)
if retcode == -1:
raise AdminError(data)
if retcode == 1:
return ajax_simple_response(dict(status="ok"))
return ajax_simple_response(dict(
status="ok", title=cwizard.get_title(data + 1)
))
if retcode == 2:
messages.info(request, _("Account created"))
return ajax_simple_response(dict(status="ok"))
@@ -314,6 +316,7 @@ def newaccount(request, tplname='admin/newaccount.html'):
cwizard.create_forms()
ctx.update(steps=cwizard.steps)
ctx.update(subtitle="1. %s" % cwizard.steps[0]['title'])
return _render(request, tplname, ctx)
@login_required
+6 -3
View File
@@ -11,8 +11,8 @@ class CreationWizard(object):
self.steps = []
self.done_cb = done_cb
def add_step(self, cls, buttons, new_args=None):
self.steps += [dict(cls=cls, buttons=buttons, new_args=new_args)]
def add_step(self, cls, title, buttons, new_args=None):
self.steps += [dict(cls=cls, title=title, buttons=buttons, new_args=new_args)]
def create_forms(self, data=None):
for step in self.steps:
@@ -37,9 +37,12 @@ class CreationWizard(object):
if stepid == len(self.steps) - 1:
self.done_cb(self.steps)
return 2, None
return 1, None
return 1, stepid
return 0, stepid
def get_title(self, stepid):
return "%d. %s" % (stepid + 1, self.steps[stepid]["title"])
class DynamicForm(object):
def _create_field(self, typ, name, value=None, pos=None):
+1
View File
@@ -22,6 +22,7 @@
$.post($form.attr("action"), data, $.proxy(function(resp) {
if (resp.status == "ok") {
if (!last) {
$(".modal-header").find("small").html(resp.title);
this.$element.carousel('next');
} else {
$("#modalbox").modal('hide').remove();
+1 -1
View File
@@ -1,7 +1,7 @@
{% load i18n libextras %}
<div class="modal-header">
<a class="close" data-dismiss="modal">x</a>
<h3>{{ title }}</h3>
<h3>{{ title }} / <small>{{ subtitle }}</small></h3>
</div>
<div class="modal-body">
<form class="form-horizontal" action="{{ action }}" enctype="{{ enctype }}"