update modal management for create project.
authorcavaliet
Wed, 09 Mar 2011 18:42:58 +0100
changeset 44 20ab9a7f1849
parent 43 21cbaab383ce
child 45 c3048a2c0758
child 47 4ed054be603f
update modal management for create project.
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html
src/ldt/ldt/ldt_utils/views.py
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html	Wed Mar 09 17:41:16 2011 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/create_ldt.html	Wed Mar 09 18:42:58 2011 +0100
@@ -32,7 +32,7 @@
 {% block body %}
 	<div id="add_contribution" class="span-12 last">
 	<div class="projectscontentstitle span-12 last">{% if ldt_id %}{% trans "Update your project" %}{% else %}{% trans "Create your project" %}{% endif %}</div>
-	<form action="{{create_project_action}}" method="POST">
+	<form action="{{create_project_action}}" method="POST" {% if target_parent %}target="_parent"{% endif %}>
 	{% csrf_token %} 
 	<input type="hidden" name="form_status" value="{{form_status}}" id="project_form_status" />
 	<label for="title">{% trans "Title" %}:</label>
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html	Wed Mar 09 17:41:16 2011 +0100
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/partial/ldt_div.html	Wed Mar 09 18:42:58 2011 +0100
@@ -32,7 +32,7 @@
 
 	var attributes = {  id: "ldtInitSwf",  name: "ldtInitSwf"};
 
-	swfobject.embedSWF("{{LDT_MEDIA_PREFIX}}swf/ldt/LignesDeTempsFlex.swf", "ldtInit", "1001", "631", "9.0.0", "{{LDT_MEDIA_PREFIX}}swf/expressInstall.swf", flashvars, params, attributes);
+	swfobject.embedSWF("{{LDT_MEDIA_PREFIX}}swf/ldt/LignesDeTempsFlex.swf", "ldtInit", "1000", "630", "9.0.0", "{{LDT_MEDIA_PREFIX}}swf/expressInstall.swf", flashvars, params, attributes);
 
 </script>
 
--- a/src/ldt/ldt/ldt_utils/views.py	Wed Mar 09 17:41:16 2011 +0100
+++ b/src/ldt/ldt/ldt_utils/views.py	Wed Mar 09 18:42:58 2011 +0100
@@ -547,10 +547,17 @@
         if form.is_valid():
             user = request.user
             project = Project.create_project(title=form.cleaned_data['title'], user=user, contents=contents)
-            return HttpResponseRedirect(reverse('ldt.ldt_utils.views.indexProject', args=[project.ldt_id]))
+            # Modal window is not used with firefox
+            is_gecko = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
+            if is_gecko :
+                return HttpResponseRedirect(reverse('ldt.ldt_utils.views.indexProjectFull', args=[project.ldt_id]))
+            else:
+                return HttpResponseRedirect(reverse('ldt.ldt_utils.views.indexProject', args=[project.ldt_id]))
     else:
         form = AddProjectForm()
-    return render_to_response('ldt/ldt_utils/create_ldt.html', {'form':form, 'contents':contents, 'create_project_action':reverse("ldt.ldt_utils.views.create_project", args=[iri_id])}, context_instance=RequestContext(request))
+    # Modal window is not used with firefox, so we ask to submit the form in _parent in firefox case.
+    target_parent = ((request.META['HTTP_USER_AGENT'].lower().find("firefox")) > -1);
+    return render_to_response('ldt/ldt_utils/create_ldt.html', {'form':form, 'contents':contents, 'create_project_action':reverse("ldt.ldt_utils.views.create_project", args=[iri_id]), 'target_parent':target_parent}, context_instance=RequestContext(request))
 
 @login_required
 def update_project(request, ldt_id):