Index: /WAeUP_SRP/trunk/doc/srp_documentation.mm
===================================================================
--- /WAeUP_SRP/trunk/doc/srp_documentation.mm	(revision 2016)
+++ /WAeUP_SRP/trunk/doc/srp_documentation.mm	(revision 2017)
@@ -7,6 +7,6 @@
 <node CREATED="1172588791669" ID="Freemind_Link_832896495" LINK="../profiles/default/layouts.xml" MODIFIED="1173007318993" TEXT="Labels (Titles)"/>
 </node>
-<node CREATED="1172489529057" FOLDED="true" ID="Freemind_Link_43083883" MODIFIED="1172489545651" POSITION="right" TEXT="SRP Data Structure">
-<node CREATED="1170079621592" FOLDED="true" ID="Freemind_Link_1297017754" MODIFIED="1170079640872" TEXT="Campus">
+<node CREATED="1172489529057" ID="Freemind_Link_43083883" MODIFIED="1172489545651" POSITION="right" TEXT="SRP Data Structure">
+<node CREATED="1170079621592" ID="Freemind_Link_1297017754" MODIFIED="1170079640872" TEXT="Campus">
 <node CREATED="1171710559043" ID="Freemind_Link_1592396213" MODIFIED="1171710565212" TEXT="Id: campus"/>
 <node CREATED="1170079643589" FOLDED="true" ID="Freemind_Link_1231068129" MODIFIED="1171710686426" TEXT="Academic Section">
@@ -48,11 +48,11 @@
 </node>
 </node>
-<node CREATED="1170082138244" FOLDED="true" ID="Freemind_Link_1354366927" MODIFIED="1171710679266" TEXT="Student Section">
+<node CREATED="1170082138244" ID="Freemind_Link_1354366927" MODIFIED="1171710679266" TEXT="Student Section">
 <node CREATED="1171709784119" ID="_" MODIFIED="1171709937449" TEXT="Type: StudentsFolder" VSHIFT="104"/>
 <node CREATED="1171710545564" ID="Freemind_Link_221165828" MODIFIED="1171710551332" TEXT="Id: students"/>
-<node CREATED="1170082147831" FOLDED="true" ID="Freemind_Link_115332414" MODIFIED="1171709774415" TEXT="{Student}">
-<node CREATED="1171114205479" ID="Freemind_Link_1051911128" LINK="../profiles/default/types/Student.xml" MODIFIED="1171353141707" TEXT="Type: Student"/>
-<node CREATED="1171124926993" ID="Freemind_Link_1838352082" LINK="../profiles/default/schemas/student.xml" MODIFIED="1171353152905" TEXT="Schema: student"/>
-<node CREATED="1171124982312" ID="Freemind_Link_1037588671" LINK="../profiles/default/layouts/student.xml" MODIFIED="1171353165422" TEXT="Layout: student"/>
+<node CREATED="1170082147831" ID="Freemind_Link_115332414" MODIFIED="1171709774415" TEXT="{Student}">
+<node CREATED="1171114205479" ID="Freemind_Link_1051911128" LINK="../profiles/default/types/Student.xml" MODIFIED="1184064751825" TEXT="Type: Student"/>
+<node CREATED="1171124926993" ID="Freemind_Link_1838352082" LINK="../profiles/default/schemas/student.xml" MODIFIED="1184064617631" TEXT="Schema: student"/>
+<node CREATED="1171124982312" ID="Freemind_Link_1037588671" LINK="../profiles/default/layouts/student.xml" MODIFIED="1184064687002" TEXT="Layout: student"/>
 <node CREATED="1171353188624" FOLDED="true" ID="Freemind_Link_1032185087" LINK="../profiles/default/workflows/waeup_student_wf/definition.xml" MODIFIED="1171353319663" TEXT="Workflow: waeup_student_wf">
 <node CREATED="1172156481009" ID="Freemind_Link_615926152" LINK="waeup_student_wf.gif" MODIFIED="1172486913476" TEXT="Diagram"/>
@@ -284,11 +284,11 @@
 </node>
 </node>
-<node CREATED="1170082542534" FOLDED="true" ID="Freemind_Link_243354429" MODIFIED="1171710670383" TEXT="Pin Section">
-<node CREATED="1171710956294" ID="Freemind_Link_1564638284" MODIFIED="1171710960600" TEXT="Type: ScratchCardBatchesFolder"/>
+<node CREATED="1170082542534" ID="Freemind_Link_243354429" MODIFIED="1171710670383" TEXT="Pin Section">
+<node CREATED="1171710956294" ID="Freemind_Link_1564638284" LINK="../profiles/default/types/ScratchCardBatchesFolder.xml" MODIFIED="1184064861155" TEXT="Type: ScratchCardBatchesFolder"/>
 <node CREATED="1171710648131" ID="Freemind_Link_1115846656" MODIFIED="1171710654941" TEXT="Id: pins"/>
-<node CREATED="1170082553111" FOLDED="true" ID="Freemind_Link_1225342224" MODIFIED="1171884067639" TEXT="ScratchCardBatches">
-<node CREATED="1171711021738" ID="Freemind_Link_1373462759" MODIFIED="1171711030451" TEXT="Type: ScratchCardBatch"/>
-<node CREATED="1171711043239" ID="Freemind_Link_215893748" MODIFIED="1171711075966" TEXT="Schema: scratch_card_batch"/>
-<node CREATED="1171711076978" ID="Freemind_Link_1234518938" MODIFIED="1171711086892" TEXT="Layout: scratch_card_batch"/>
+<node CREATED="1170082553111" ID="Freemind_Link_1225342224" MODIFIED="1171884067639" TEXT="ScratchCardBatches">
+<node CREATED="1171711021738" ID="Freemind_Link_1373462759" LINK="../profiles/default/types/ScratchCardBatch.xml" MODIFIED="1184064778686" TEXT="Type: ScratchCardBatch"/>
+<node CREATED="1171711043239" ID="Freemind_Link_215893748" LINK="../profiles/default/schemas/scratch_card_batch.xml" MODIFIED="1184064671398" TEXT="Schema: scratch_card_batch"/>
+<node CREATED="1171711076978" ID="Freemind_Link_1234518938" LINK="../profiles/default/layouts/scratch_card_batch.xml" MODIFIED="1184064714987" TEXT="Layout: scratch_card_batch"/>
 </node>
 </node>
Index: /WAeUP_SRP/trunk/skins/waeup_default/cpsdocument.js.dtml
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/cpsdocument.js.dtml	(revision 2017)
+++ /WAeUP_SRP/trunk/skins/waeup_default/cpsdocument.js.dtml	(revision 2017)
@@ -0,0 +1,313 @@
+/*
+<dtml-let last_modified="_.DateTime()-14" expires="_.DateTime()+1" >
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Content-Type', 'text/javascript' )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Last-Modified', last_modified.toZone('GMT').rfc822() )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Cache-Control', 'max-age=36000, must-revalidate' )">
+<dtml-call "REQUEST.RESPONSE.setHeader( 'Expires', expires.toZone('GMT').rfc822() )" >
+</dtml-let>
+*/
+/*
+# (C) Copyright 2003 Nuxeo SARL <http://nuxeo.com>
+# Author: Tarek Ziadé <tz@nuxeo.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+# $Id:$
+
+CPSDocument javascript layer
+
+XXX need to find a way to upload file, it is very
+restrictive as it does'nt allow to send simple
+types like Document, flexible, etc...
+
+*/
+
+var CPSDocumentEditor = Class.create();
+
+CPSDocumentEditor.prototype = {
+  initialize: function(form_id, form_action, rendered_id, buttons,
+                       reloadbuttons, title_id, translations, last_error,
+                       blockers) {
+    // if any blocker is found, we don't ajaxify
+    if (blockers) {
+      for (var i = 0; i < blockers.length; i += 1) {
+        var blocker = blockers[i];
+        if ($(blocker)) {
+          this.enabled = false;
+          return;
+        }
+      }
+    }
+    this.form_id = form_id;
+    this.blockers = blockers;
+    this.effects = Effect;
+    this.rendered_id = rendered_id;
+    this.title_id = title_id;
+    this.last_error = last_error;
+    this.sender = null;
+    this.translations = translations;
+
+    var edit_form = $(form_id);
+    var rendered_node = $(rendered_id);
+    if (!edit_form || !rendered_node) {
+      this.enabled = false;
+    }
+    else {
+
+      // getting the action value
+      this.edit_form = edit_form;
+
+      if (!this.canSendForm()) {
+        this.enabled = false;
+      }
+      else
+      {
+        this.rendered_node = rendered_node;
+        this.buttons = buttons;
+        this.reloadbuttons = reloadbuttons;
+        this.form_action = form_action;
+        // linking action to buttons
+        var count = 0;
+        if (buttons)
+        {
+            for (var i = 0; i < buttons.length; i += 1) {
+            var button = buttons[i];
+            var button_node = $(button);
+            if (button_node) {
+                button_node.type = 'button';
+                button_node.onclick = this.sendForm.bindAsEventListener(this);
+                count += 1;
+            }
+            }
+        }
+        if (reloadbuttons)
+        {
+            for (var i = 0; i < reloadbuttons.length; i += 1) {
+            var button = reloadbuttons[i];
+            var button_node = $(button);
+            if (button_node) {
+                button_node.type = 'button';
+                button_node.onclick = this.sendFormReload.bindAsEventListener(this);
+                count += 1;
+            }
+            }
+        }
+        if (count>0) {
+            this.enabled = true;
+            edit_form.action = ''; // disabling direct sending
+        }
+        else {
+            this.enabled = false;
+        }
+      }
+    }
+  },
+
+  onCreate: function() {
+    if ($('ajax_psm')) {
+      var elt = $('ajax_psm');
+      elt.innerHTML = this.translations.working;
+      Effect.Appear('ajax_psm', {duration:1, queue:'end'});
+    }
+  },
+
+  onComplete: function() {
+    if ($('ajax_psm')) {
+      Effect.Fade('ajax_psm', {duration:1.5, queue:'end'});
+    }
+  },
+
+  sendForm: function(evt) {
+    if (this.enabled) {
+      this.onCreate();
+      // let's serialize the content of the form
+      // and send it to the server
+      params = Form.serialize(this.edit_form);
+      if (params!='') {
+        params += '&ajax_edit=1';
+      }
+      var sendFormCompletedFn = this.sendFormCompleted.bind(this);
+      var options = {parameters: params, onComplete: sendFormCompletedFn};
+      if (!this.sender) {
+        this.sender = new Ajax.Request(this.form_action, options);
+      }
+      else {
+        this.sender.setOptions(options);
+        this.sender.request(this.form_action);
+      }
+    }
+  },
+
+  sendFormReload: function(evt) {
+    if (this.enabled) {
+      this.onCreate();
+      // let's serialize the content of the form
+      // and send it to the server
+      params = Form.serialize(this.edit_form);
+      if (params!='') {
+        params += '&cpsdocument_edit_and_view_button=1';
+        params += '&ajax_edit=1';
+      }
+      var sendFormCompletedFn = this.sendFormCompleted.bind(this);
+      var options = {parameters: params, onComplete: sendFormCompletedFn};
+      if (!this.sender) {
+        this.sender = new Ajax.Request(this.form_action, options);
+      }
+      else {
+        this.sender.setOptions(options);
+        this.sender.request(this.form_action);
+      }
+    }
+  },
+
+  sendFormCompleted: function(originalRequest) {
+    var result = originalRequest.responseXML;
+
+    // result comes in three node, under ajax-response
+    result = result.childNodes[0];
+    var action = '';
+    var layout = '';
+    var form_result = false;
+
+    for (var i = 0; i < result.childNodes.length; i++) {
+      var node = result.childNodes[i];
+      if (node.nodeName=='result') {
+        if (node.childNodes[0].nodeValue=='True')
+          form_result = true;
+      }
+      if (node.nodeName=='layout') {
+        layout = node.childNodes[0].nodeValue;
+      }
+      if (node.nodeName=='action') {
+        if (node.childNodes.length>0) {
+          action = node.childNodes[0].nodeValue;
+        }
+      }
+    }
+
+    if (form_result) {
+      psm = this.translations.content_changed;
+      if (this.last_error)
+        this.rendered_node.innerHTML = layout;
+    }
+    else {
+      psm = this.translations.content_error;
+      // need to reload form here
+      this.rendered_node.innerHTML = layout;
+      // we also want to scroll to the first error
+      this.scrollTo('error');
+    }
+
+    // feedback, in any case
+    feedback = $('ajax_psm');
+    if (feedback) {
+     feedback.innerHTML = psm;
+    }
+
+    // reload elements
+    if (!action) {
+      this.initialize(this.form_id, this.form_action, this.rendered_id,
+                      this.buttons, this.reloadbuttons, this.title_id,
+                      this.translations, !form_result, this.blockers);
+      if (form_result)
+        this.reloadTitleFromForm();
+
+    }
+    else {
+      this.gotoUrl(action);
+    }
+    this.onComplete();
+  },
+
+  gotoUrl: function(dest) {
+    self.location.href = dest;
+  },
+
+  canSendForm: function() {
+    // trying to see if there are files in the form
+    var inputs = this.edit_form.getElementsByTagName('input');
+    for (var i = 0; i < inputs.length; i++) {
+      var input = inputs[i];
+      // if (input.type == 'file' && input.value != '') {
+      if (input.type == 'file') {
+        return false;
+      }
+    }
+    return true;
+  },
+
+  reloadTitleFromForm: function() {
+    if ($('widget__Title')) {
+        this.reloadTitle($('widget__Title').value);
+      }
+  },
+
+  reloadTitle: function(new_title) {
+    // reloading title
+    title_node = $(this.title_id);
+    if (title_node)
+      title_node.innerHTML = new_title;
+    document.title = new_title;
+  },
+
+  scrollTo: function(classname) {
+    elements = document.getElementsByClassName(classname, document);
+    if (elements.length>0) {
+      var element = elements[0];
+      var x = element.x ? element.x : element.offsetLeft,
+          y = element.y ? element.y : element.offsetTop;
+      window.scrollTo(x, y);
+    }
+  }
+}
+
+/*--------------------------------------------------------------------------*/
+
+if (!window.CPSFlexibleEdit) {
+  var CPSFlexibleEdit = new Object();
+  }
+  
+Object.extend(CPSFlexibleEdit, {
+  buttonClick: function(button, message) {
+  /*
+  this function will simulate a click on a submit button, by setting a hidden
+  field with the name/value of the clicked button and then submitting the form
+  */
+    if (message) {
+      if (window.confirm(message))
+        flag = true;
+    }
+    else
+      flag = true;
+    if (flag) {
+      buttonName = button.name;
+      buttonValue = button.value;
+      myform = button.form;
+      placeholder = document.getElementById('button_placeholder');
+      if (document.all) { // what follows should work
+                          // with Opera/IE but doesn't in Firefox
+        placeholder.name = buttonName;
+        placeholder.value = buttonValue;
+      }
+      else if (document.getElementById) { // so here is the
+                                          // Firefox workaround
+        placeholder.setAttribute('name', buttonName);
+        placeholder.setAttribute('value', buttonValue);
+      }
+      myform.submit();
+    }
+  }
+});
+
Index: /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit_ajax.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit_ajax.py	(revision 2017)
+++ /WAeUP_SRP/trunk/skins/waeup_default/waeup_edit_ajax.py	(revision 2017)
@@ -0,0 +1,46 @@
+##parameters=REQUEST, cluster=None
+# $Id$
+"""
+Called when a document form is posted for AJAX validation.
+
+Returns the validation result and the rendered page in an XML-RPC response.
+"""
+from Products.CPSDocument.utils import cleanAjaxParams
+
+# cleaning incoming params
+cleanAjaxParams(REQUEST)
+
+doc = context.getContent()
+res = doc.renderEditDetailed(request=REQUEST, proxy=context, cluster=cluster)
+layout, is_valid = str(res[0]), res[1]
+
+# AJAX tries to change the doc and just needs to know if there were errors
+# for feedback without a new form rendering.
+# XXX TODO: avoid here an extra HTML rendering
+# by calling renderEditDetailed() with the right parameters
+
+# At this time we do XML-RPC answers.
+# We'll see later how to automate it to avoid a manual serialization here.
+#from Products.zdb import set_trace
+#set_trace()
+
+if is_valid:
+    comments = REQUEST.get('comments')
+    context.cpsdocument_notify_modification(comments=comments)
+
+if is_valid and 'cpsdocument_edit_and_view_button' in REQUEST:
+    action = 'view'
+else:
+    action = ''
+
+
+REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml')
+REQUEST.RESPONSE.setHeader('Cache-Control', 'no-cache')
+response = '<?xml version="1.0" encoding="utf-8" ?>'
+response += '<ajax-response>'
+response += '<result>%s</result>' % str(bool(is_valid))
+response += '<layout><![CDATA[%s]]></layout>' % layout
+response += '<action>%s</action>' % action
+response += '</ajax-response>'
+
+return response
