Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 1024)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 1025)
@@ -246,4 +246,37 @@
 
 
+###)
+
+class StudyCourseWidget(CPSStringWidget): ###(
+    """ StudyCourse Widget"""
+    meta_type = "StudyCourse Widget"
+
+    def validate(self, datastructure, **kw):
+        """Validate datastructure and update datamodel."""
+        #from Products.zdb import set_trace
+        #set_trace()
+        valid = CPSStringWidget.validate(self, datastructure, **kw)
+        id_pat_str = r"\S"
+        inv_id_pat = compile(r"^%s$" % id_pat_str)
+        if not valid:
+            return 0
+        else:
+            widget_id = self.getWidgetId()
+            value = datastructure[widget_id].upper()
+            err = 0
+            if len(value.split()) > 1:
+                err = 'Invalid Id, Id contains space(s).'
+            elif not self.portal_catalog(portal_type='Certificate',id=value):
+                err = 'No such certificate'
+            if err:
+                datastructure.setError(widget_id, err)
+            else:
+                datamodel = datastructure.getDataModel()
+                datamodel[self.fields[0]] = value
+            return not err
+
+InitializeClass(StudyCourseWidget)
+
+widgetRegistry.register(StudyCourseWidget)
 ###)
 
@@ -471,7 +504,7 @@
         pin = "%(prefix)s%(b)s%(n)s" % vars()
         do = 1
-        s_id = ''
+        s_id = str(self.portal_membership.getAuthenticatedMember())
         if self.reference == "":
-            ref = str(self.portal_membership.getAuthenticatedMember())
+            ref = s_id 
         else:
             ref = datastructure[self.reference]
Index: WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml	(revision 1024)
+++ WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml	(revision 1025)
@@ -19,5 +19,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="study_course" meta_type="String Widget">
+ <widget name="study_course" meta_type="StudyCourse Widget">
   <property name="title">Certificate Code</property>
   <property name="fields">
@@ -31,183 +31,8 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="end_level" meta_type="Select Widget">
-  <property name="title">End Level</property>
-  <property name="fields">
-   <element value="end_level"/>
-  </property>
-  <property name="label">End Level</property>
-  <property name="label_edit">End Level</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
-  <property name="vocabulary">courselevel</property>
- </widget>
- <widget name="max_elect" meta_type="String Widget">
-  <property name="title">Max Elect</property>
-  <property name="fields">
-   <element value="max_elect"/>
-  </property>
-  <property name="label">Max Elect</property>
-  <property name="label_edit">Max Elect</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="max_load" meta_type="Int Widget">
-  <property name="title">Maximum Load</property>
-  <property name="fields">
-   <element value="max_load"/>
-  </property>
-  <property name="is_required">False</property>
-  <property name="label">Maximum Load</property>
-  <property name="label_edit">Maximum Load</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="max_pass" meta_type="Int Widget">
-  <property name="title">Maximum Pass</property>
-  <property name="fields">
-   <element value="max_pass"/>
-  </property>
-  <property name="is_required">False</property>
-  <property name="label">Maximum Pass</property>
-  <property name="label_edit">Maximum Pass</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="n_core" meta_type="Int Widget">
-  <property name="title">NCore</property>
-  <property name="fields">
-   <element value="n_core"/>
-  </property>
-  <property name="label">NCore</property>
-  <property name="label_edit">NCore</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="nr_years" meta_type="Int Widget">
-  <property name="title">Nr of Years</property>
-  <property name="fields">
-   <element value="nr_years"/>
-  </property>
-  <property name="label">Nr of Years</property>
-  <property name="label_edit">Nr of Years</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="probation_credits" meta_type="Int Widget">
-  <property name="title">Probation  Credits</property>
-  <property name="fields">
-   <element value="probation_credits"/>
-  </property>
-  <property name="label">Probation  Credits</property>
-  <property name="label_edit">Probation  Credits</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="promotion_credits" meta_type="Int Widget">
-  <property name="title">Promotion  Credits</property>
-  <property name="fields">
-   <element value="promotion_credits"/>
-  </property>
-  <property name="label">Promotion  Credits</property>
-  <property name="label_edit">Promotion  Credits</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="start_level" meta_type="Select Widget">
-  <property name="title">Start Level</property>
-  <property name="fields">
-   <element value="start_level"/>
-  </property>
-  <property name="label">Start Level</property>
-  <property name="label_edit">Start Level</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
-  <property name="vocabulary">courselevel</property>
- </widget>
- <widget name="end_level" meta_type="Select Widget">
-  <property name="title">End Level</property>
-  <property name="fields">
-   <element value="end_level"/>
-  </property>
-  <property name="label">End Level</property>
-  <property name="label_edit">End Level</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
-  <property name="vocabulary">courselevel</property>
- </widget>
- <widget name="department" meta_type="String Widget">
-  <property name="title">Department Code</property>
-  <property name="fields">
-   <element value="department"/>
-  </property>
-  <property name="is_required">False</property>
-  <property name="label">Department Code</property>
-  <property name="label_edit">Department Code</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
- <widget name="faculty" meta_type="String Widget">
-  <property name="title">Faculty Code</property>
-  <property name="fields">
-   <element value="faculty"/>
-  </property>
-  <property name="is_required">False</property>
-  <property name="label">Faculty Code</property>
-  <property name="label_edit">Faculty Code</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
- </widget>
  <table>
-  <row>
-   <cell name="title"/>
-  </row>
   <row>
    <cell name="study_course"/>
   </row>
-  <row>
-   <cell name="faculty"/>
-  </row>
-  <row>
-   <cell name="department"/>
-  </row>
-  <row>
-   <cell name="start_level"/>
-  </row>
-  <row>
-   <cell name="end_level"/>
-  </row>
-  <row>
-   <cell name="max_pass"/>
-  </row>
-  <row>
-   <cell name="max_load"/>
-  </row>
-  <row>
-   <cell name="promotion_credits"/>
-  </row>
-  <row>
-   <cell name="probation_credits"/>
-  </row>
-  <row>
-   <cell name="nr_years"/>
-  </row>
-  <row>
-   <cell name="n_core"/>
-  </row>
-  <row>
-   <cell name="max_elect"/>
-  </row>
  </table>
 </object>
Index: WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py	(revision 1024)
+++ WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py	(revision 1025)
@@ -23,4 +23,12 @@
 # (We don't call getEditableContent here, validate does it when needed.)
 doc = context.getContent()
+if context.portal_type == "StudentStudyCourse":
+    if len(context.objectIds()) > 0:
+        psm = 'Edit of StudyCourse is only possible if there are no levels'
+        args = getFormUidUrlArg(REQUEST)
+        args['portal_status_message'] = psm
+        url = context.absolute_url() + '?' + urlencode(args)
+        REQUEST.RESPONSE.redirect(url)
+        
 is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
                             use_session=True)
@@ -36,4 +44,17 @@
     comments = REQUEST.get('comments')
     context.cpsdocument_notify_modification(comments=comments)
+    if context.portal_type == "StudentStudyCourse":
+        course = ds.get('study_course')
+        student_id = context.getStudentId()
+        res = context.portal_catalog(portal_type='Certificate',id = course)
+        if res:
+            c_brain = res[0]
+            c_path = c_brain.getPath().split('/')
+            student_id = context.getStudentId()
+            context.students_catalog.modifyRecord(id = student_id,
+                                                  course = course,
+                                                  faculty = c_path[-4],
+                                                  department = c_path[-3],
+                                                  )
     if cpsdocument_edit_and_view_button is not None:
         action = ''
Index: WAeUP_SRP/trunk/skins/waeup_student/application_edit_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/application_edit_form.pt	(revision 1024)
+++ WAeUP_SRP/trunk/skins/waeup_student/application_edit_form.pt	(revision 1025)
@@ -1,4 +1,8 @@
-<metal:html tal:define="info context/getStudentInfo;
-            rendered_main python:info['app_doc'].render(
+<metal:html tal:define="info context/getStudentInfo">
+  <span tal:condition="not: info">
+    <metal:block use-macro="here/error_not_found/macros/not_found" />
+  </span>
+<metal:block tal:condition="info"> 
+<metal:block tal:define="rendered_main python:info['app_doc'].render(
                       layout_mode='edit',
                       schema_id = 'student_application',
@@ -50,3 +54,5 @@
     </metal:main>
   </metal:body>
+</metal:block>
+</metal:block>
 </metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentId.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentId.py	(revision 1025)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentId.py	(revision 1025)
@@ -0,0 +1,18 @@
+## Script (Python) "getStudentId"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=
+##title=
+##
+# $Id$
+"""
+return StudentId from request
+"""
+ptl = context.REQUEST.get('PATH_TRANSLATED').split('/')
+id_index = ptl.index('students')
+if len(ptl) > id_index + 2:
+    return ptl[id_index + 1]
+return None
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 1024)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py	(revision 1025)
@@ -43,5 +43,5 @@
             logger.info("student %s tried to access %s" % (member_id,requested_id))
             student_id = member_id
-            #mtool.assertViewable(context)
+            mtool.assertViewable(context)
             break
         student_id = member_id
@@ -78,7 +78,19 @@
         info['sex'] = 'female'
 course = getattr(student,'study_course',None)
-info['course'] = course
 if course:
-    info['course_doc'] = student.study_course.getContent()
+    cert_id = course.getContent().study_course
+    res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
+    ci = {}
+    if len(res) > 0:
+        info['course'] = course
+        brain = res[0]
+        ci['study_course'] = brain.getId
+        ci['title'] = brain.Title
+        pl = brain.getPath().split('/')
+        ci['faculty'] = pl[-4]
+        ci['department'] = pl[-3]
+        info['course_doc'] = ci
+    else:
+        info['course'] = None
 #
 acco = getattr(student,'accommodation_2006',None)
Index: WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt	(revision 1024)
+++ WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt	(revision 1025)
@@ -19,6 +19,30 @@
     </metal:block>
     <metal:main fill-slot="main">
-      <span tal:omit-tag=""  
+      <span tal:omit-tag="" tal:condition="nothing"
             tal:content="structure python: info['doc'].render(layout_mode='view')" />
+      <table tal:define="sc python: s_info['course_doc']">
+        <tr>
+          <td width="180px">Certificate:</td> 
+          <td><span tal:content="sc/title" /></td>
+        </tr>
+        <tr>
+          <td>Certificate ID:</td>
+          <td tal:content="sc/study_course" />
+        </tr>
+          <span tal:define="f_id sc/faculty;
+          d_id sc/department;
+          f_title context/academics/?f_id/Title|string:Faculty not yet in Prospectus;
+          d_title context/academics/?f_id/?d_id/Title|string:Department not yet in Prospectus"
+          >
+            <tr>
+              <td>Faculty:</td>
+              <td tal:content="f_title" />
+            </tr>
+            <tr>
+              <td>Department:</td> 
+              <td><span tal:content="d_title" /></td>
+            </tr>
+          </span>
+        </table>        
       
       <form action="" method="post" class="group"
