Index: main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6807)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 6808)
@@ -486,22 +486,4 @@
     target = 'manage'
 
-class AddStudyLevelActionButton(AddActionButton):
-    grok.order(1)
-    grok.context(IStudentStudyCourse)
-    grok.view(StudyCourseDisplayFormPage)
-    grok.require('waeup.handleStudent')
-    text = 'Add course list'
-    target = 'add'
-
-    @property
-    def target_url(self):
-        student = self.view.context.getStudent()
-        condition1 = student.state != 'school fee paid'
-        condition2 = str(student['studycourse'].current_level) in \
-            self.view.context.keys()
-        if condition1 or condition2:
-            return ''
-        return self.view.url(self.view.context, self.target)
-
 class StudyCourseManageFormPage(WAeUPEditFormPage):
     """ Page to edit the student study course data
@@ -668,5 +650,5 @@
 
 class CourseTicketAddFormPage(WAeUPAddFormPage):
-    """Add a department to a faculty.
+    """Add a course ticket.
     """
     grok.context(IStudentStudyLevel)
@@ -674,5 +656,6 @@
     grok.require('waeup.manageStudents')
     label = 'Add course ticket'
-    form_fields = grok.AutoFields(ICourseTicketAdd).omit('grade', 'score')
+    form_fields = grok.AutoFields(ICourseTicketAdd).omit(
+        'grade', 'score', 'automatic')
     pnav = 4
 
@@ -1021,4 +1004,22 @@
         return
 
+class AddStudyLevelActionButton(AddActionButton):
+    grok.order(1)
+    grok.context(IStudentStudyCourse)
+    grok.view(StudyCourseDisplayFormPage)
+    grok.require('waeup.handleStudent')
+    text = 'Add course list'
+    target = 'add'
+
+    @property
+    def target_url(self):
+        student = self.view.context.getStudent()
+        condition1 = student.state != 'school fee paid'
+        condition2 = str(student['studycourse'].current_level) in \
+            self.view.context.keys()
+        if condition1 or condition2:
+            return ''
+        return self.view.url(self.view.context, self.target)
+
 class AddStudyLevelFormPage(WAeUPEditFormPage):
     """ Page for students to add current study levels
@@ -1063,2 +1064,111 @@
         self.redirect(self.url(self.context))
         return
+
+class StudyLevelEditActionButton(ManageActionButton):
+    grok.order(1)
+    grok.context(IStudentStudyLevel)
+    grok.view(StudyLevelDisplayFormPage)
+    grok.require('waeup.handleStudent')
+    text = 'Add and remove courses'
+    target = 'edit'
+
+    @property
+    def target_url(self):
+        student = self.view.context.getStudent()
+        condition1 = student.state != 'school fee paid'
+        condition2 = student[
+            'studycourse'].current_level != self.view.context.level
+        if condition1 or condition2:
+            return ''
+        return self.view.url(self.view.context, self.target)
+
+class StudyLevelEditFormPage(WAeUPEditFormPage):
+    """ Page to edit the student study level data by students
+    """
+    grok.context(IStudentStudyLevel)
+    grok.name('edit')
+    grok.require('waeup.handleStudent')
+    grok.template('studyleveleditpage')
+    form_fields = grok.AutoFields(IStudentStudyLevel).omit(
+        'level_session', 'level_verdict')
+    pnav = 4
+
+    def update(self):
+        super(StudyLevelEditFormPage, self).update()
+    #    tabs.need()
+        datatable.need()
+        return
+
+    @property
+    def title(self):
+        return 'Study Level %s' % self.context.level_title
+
+    @property
+    def label(self):
+        return 'Add and remove course tickets of study level %s' % self.context.level_title
+
+    @property
+    def total_credits(self):
+        total_credits = 0
+        for key, val in self.context.items():
+            total_credits += val.credits
+        return total_credits
+
+    @grok.action('Add course ticket')
+    def addCourseTicket(self, **data):
+        self.redirect(self.url(self.context, 'ctadd'))
+
+    @grok.action('Remove selected tickets')
+    def delCourseTicket(self, **data):
+        form = self.request.form
+        if form.has_key('val_id'):
+            child_id = form['val_id']
+        else:
+            self.flash('No ticket selected.')
+            self.redirect(self.url(self.context, '@@edit'))
+            return
+        if not isinstance(child_id, list):
+            child_id = [child_id]
+        deleted = []
+        for id in child_id:
+            # Student are not allowed to remove core tickets
+            if not self.context[id].core_or_elective:
+                try:
+                    del self.context[id]
+                    deleted.append(id)
+                except:
+                    self.flash('Could not delete %s: %s: %s' % (
+                            id, sys.exc_info()[0], sys.exc_info()[1]))
+        if len(deleted):
+            self.flash('Successfully removed: %s' % ', '.join(deleted))
+        self.redirect(self.url(self.context, u'@@edit'))
+        return
+
+class CourseTicketAddFormPage2(CourseTicketAddFormPage):
+    """Add a course ticket by student.
+    """
+    grok.name('ctadd')
+    grok.require('waeup.handleStudent')
+    form_fields = grok.AutoFields(ICourseTicketAdd).omit(
+        'grade', 'score', 'core_or_elective', 'automatic')
+
+    @grok.action('Add course ticket')
+    def addCourseTicket(self, **data):
+        ticket = CourseTicket()
+        course = data['course']
+        ticket.automatic = False
+        ticket.code = course.code
+        ticket.title = course.title
+        ticket.faculty = course.__parent__.__parent__.__parent__.title
+        ticket.department = course.__parent__.__parent__.title
+        ticket.credits = course.credits
+        ticket.passmark = course.passmark
+        ticket.semester = course.semester
+        try:
+            self.context.addCourseTicket(ticket)
+        except KeyError:
+            self.flash('The ticket exists.')
+            return
+        self.flash('Successfully added %s.' % ticket.code)
+        self.redirect(self.url(self.context, u'@@edit'))
+        return
Index: main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt
===================================================================
--- main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt	(revision 6808)
+++ main/waeup.sirp/trunk/src/waeup/sirp/students/browser_templates/studyleveleditpage.pt	(revision 6808)
@@ -0,0 +1,59 @@
+<h2 i18n:translate=""
+tal:condition="view/label"
+tal:content="view/label">Label</h2>
+
+<div class="form-status"
+    tal:define="status view/status"
+    tal:condition="status">
+    Form Status:
+    <span i18n:translate="" tal:content="view/status">
+      Form status summary
+    </span>
+</div>
+
+<form action="." tal:attributes="action request/URL" method="POST"
+      class="edit-form" enctype="multipart/form-data"> 
+
+  <h3>Course Tickets (Total Credits: <span tal:replace="view/total_credits">TOTAL</span>)</h3>
+  <table class="display dataTableManage">
+  <thead>
+    <tr>
+      <th>&nbsp;</th>
+      <th>Code</th>
+      <th>Title</th>
+      <th>Department</th>
+      <th>Faculty</th>
+      <th>Credits</th>
+      <th>Score</th>
+    </tr>
+  </thead>
+  <tbody>
+    <tr tal:repeat="value context/values">
+       <td>
+        <input type="checkbox" name="val_id"
+  		  tal:attributes="value value/__name__"
+        tal:condition="not: value/core_or_elective" />
+      </td>
+      <td> <a tal:attributes="href value/__name__">
+      <span tal:content="value/code">CODE</span>
+      </a></td>
+      <td tal:content="value/title">TITLE</td>
+      <td tal:content="value/department">DEPARTMENT</td>
+      <td tal:content="value/faculty">FACULTY</td>
+      <td tal:content="value/credits">CREDITS</td>
+      <td tal:content="value/score">SCORE</td>
+    </tr>
+  </tbody>
+  </table>
+
+  <div class="actionButtons" tal:condition="view/availableActions">
+    <span tal:repeat="action view/actions"
+          tal:omit-tag="">
+      <input tal:replace="structure action/render"/>
+    </span>
+  </div>
+
+</form>  
+
+
+
