[SCM] live-studio branch, master, updated. be51da814fb12d25dce46a7f078a46f5c89bd777

Chris Lamb lamby at debian.org
Fri Jul 30 02:52:34 UTC 2010


The following commit has been merged in the master branch:
commit d4c764334a65697d26948b9fc35d95537cfa4ebc
Author: Chris Lamb <lamby at debian.org>
Date:   Wed Jul 28 19:58:07 2010 -0400

    Add stub for adding wizard.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>

diff --git a/live_studio_www/config/forms.py b/live_studio_www/config/forms.py
index 19a080e..a9c47e8 100644
--- a/live_studio_www/config/forms.py
+++ b/live_studio_www/config/forms.py
@@ -6,3 +6,21 @@ class ConfigForm(forms.ModelForm):
     class Meta:
         model = Config
         exclude = ('created', 'user')
+
+PAGES = (
+    ('base',),
+    ('distribution',),
+    ('media_type',),
+    ('architecture',),
+    ('installer',),
+    ('locale', 'keyboard_layout'),
+)
+
+WIZARD_FORMS = []
+for fields in PAGES:
+    meta = type('Meta', (), {
+        'model': Config,
+        'fields': fields,
+    })
+
+    WIZARD_FORMS.append(type('', (forms.ModelForm,), {'Meta': meta}))
diff --git a/live_studio_www/config/urls.py b/live_studio_www/config/urls.py
index d0b42f4..872c5af 100644
--- a/live_studio_www/config/urls.py
+++ b/live_studio_www/config/urls.py
@@ -1,6 +1,7 @@
 from django.conf.urls.defaults import *
 
 urlpatterns = patterns('live_studio_www.config.views',
+    url(r'config/add$', 'add', name='add'),
     url(r'configs$', 'configs', name='configs'),
     url(r'config/(?P<config_id>\d+)$', 'view', name='view'),
     url(r'config/(?P<config_id>\d+)/edit$', 'edit', name='edit'),
diff --git a/live_studio_www/config/views.py b/live_studio_www/config/views.py
index 41a40c8..962df61 100644
--- a/live_studio_www/config/views.py
+++ b/live_studio_www/config/views.py
@@ -1,9 +1,11 @@
 from django.http import HttpResponseRedirect
 from django.shortcuts import get_object_or_404
+from django.contrib.formtools.wizard import FormWizard
 
 from live_studio_www.utils import render_response
 
-from .forms import ConfigForm
+from .forms import ConfigForm, WIZARD_FORMS
+from .models import Config
 
 def configs(request):
     return render_response(request, 'config/configs.html')
@@ -31,3 +33,19 @@ def edit(request, config_id):
         'form': form,
         'config': config,
     })
+
+class NewConfigWizard(FormWizard):
+    def done(self, request, form_list):
+        data = {}
+        for form in form_list:
+            data.update(form.cleaned_data)
+
+        config = Config(user=request.user, **data)
+        config.save()
+
+        return HttpResponseRedirect(config.get_absolute_url())
+
+    def get_template(self, step):
+        return 'config/add_%s.html' % step
+
+add = NewConfigWizard(WIZARD_FORMS)
diff --git a/templates/config/add.html b/templates/config/add.html
new file mode 100644
index 0000000..c8d333c
--- /dev/null
+++ b/templates/config/add.html
@@ -0,0 +1,19 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+<h1>Add new configuration</h1>
+
+<p>Step {{ step }} of {{ step_count }}</p>
+<form action="" method="POST">{% csrf_token %}
+
+<table>
+{% block add-content %}{{ form }}{% endblock %}
+</table>
+
+<input type="hidden" name="{{ step_field }}" value="{{ step0 }}" />
+{{ previous_fields|safe }}
+<input type="submit" value="Next">
+</form>
+
+{% endblock %}
diff --git a/templates/config/add_0.html b/templates/config/add_0.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_0.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/add_1.html b/templates/config/add_1.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_1.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/add_2.html b/templates/config/add_2.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_2.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/add_3.html b/templates/config/add_3.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_3.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/add_4.html b/templates/config/add_4.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_4.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/add_5.html b/templates/config/add_5.html
new file mode 100644
index 0000000..c21af50
--- /dev/null
+++ b/templates/config/add_5.html
@@ -0,0 +1 @@
+{% extends "config/add.html" %}
diff --git a/templates/config/configs.html b/templates/config/configs.html
index 46cb039..58a2277 100644
--- a/templates/config/configs.html
+++ b/templates/config/configs.html
@@ -3,6 +3,8 @@
 {% block content %}
 <h1>List of configurations</h1>
 
+<p><strong><a href="{% url config:add %}">Add new configuration</a></strong></p>
+
 <table>
 
 {% for config in request.user.configs.all %}

-- 
live-studio



More information about the debian-live-changes mailing list