Index: /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py
===================================================================
--- /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 7641)
+++ /main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py	(revision 7642)
@@ -27,6 +27,4 @@
 from zope.component import queryUtility, getUtility, createObject
 from zope.formlib.textwidgets import BytesDisplayWidget
-#from hurry.query import Eq
-#from hurry.query.query import Query
 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
 from waeup.sirp.accesscodes import (
@@ -85,4 +83,6 @@
 
 def emit_lock_message(view):
+    """Flash a lock message.
+    """
     view.flash('The requested form is locked (read-only).')
     view.redirect(view.url(view.context))
@@ -94,10 +94,8 @@
     grok.context(IStudentsContainer)
     title = 'Students'
-    #grok.implements(IBreadcrumbIgnorable)
 
     @property
     def target(self):
         user = get_current_principal()
-        #import pdb; pdb.set_trace()
         if getattr(user, 'user_type', None) == 'student':
             return None
@@ -226,5 +224,7 @@
             return
         elif student_pw:
-            self.flash('Password has already been set. You are using the wrong Access Code.')
+            self.flash(
+                'Password has already been set. You are using the '
+                'wrong Access Code.')
             return
         # Mark pin as used (this also fires a pin related transition)
@@ -237,5 +237,4 @@
             # Here we know that the ac is in state initialized so we do not
             # expect an exception
-            #import pdb; pdb.set_trace()
             invalidate_accesscode(pin,comment)
             IUserAccount(student).setPassword(self.ac_number)
@@ -595,5 +594,5 @@
             return current_mode
         return
-        
+
     @property
     def department(self):
@@ -816,5 +815,6 @@
             self.flash('This level does not correspond current level.')
         elif self.context.getStudent().state == REGISTERED:
-            IWorkflowInfo(self.context.getStudent()).fireTransition('validate_courses')
+            IWorkflowInfo(self.context.getStudent()).fireTransition(
+                'validate_courses')
             self.flash('Course list has been validated.')
         else:
@@ -929,7 +929,8 @@
         return
 
-# This manage form page is for both students and students officers.
 class PaymentsManageFormPage(SIRPEditFormPage):
     """ Page to manage the student payments
+
+    This manage form page is for both students and students officers.
     """
     grok.context(IStudentPaymentsContainer)
@@ -997,5 +998,5 @@
     label = 'Add online payment'
     pnav = 4
-    
+
     @action('Create ticket', style='primary')
     def createTicket(self, **data):
@@ -1006,5 +1007,6 @@
             'configuration'].accommodation_session:
                 self.flash(
-                    'Your current session does not match accommodation session.')
+                    'Your current session does not match '
+                    'accommodation session.')
                 self.redirect(self.url(self.context))
                 return
@@ -1031,5 +1033,4 @@
         self.applyData(payment, **data)
         timestamp = "%d" % int(time()*1000)
-        #order_id = "%s%s" % (student_id[1:],timestamp)
         payment.p_id = "p%s" % timestamp
         payment.p_item = p_item
@@ -1051,6 +1052,8 @@
     grok.require('waeup.viewStudent')
     form_fields = grok.AutoFields(IStudentOnlinePayment)
-    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
-    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+    form_fields[
+        'creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+    form_fields[
+        'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     pnav = 4
 
@@ -1136,22 +1139,9 @@
             self.context.getStudent(), studentview)
 
-# We don't need the display form page yet
-#class AccommodationDisplayFormPage(SIRPDisplayFormPage):
-#    """ Page to display the student accommodation data
-#    """
-#    grok.context(IStudentAccommodation)
-#    grok.name('xxx')
-#    grok.require('waeup.viewStudent')
-#    form_fields = grok.AutoFields(IStudentAccommodation)
-#    #grok.template('accommodationpage')
-#    pnav = 4
-
-#    @property
-#    def label(self):
-#        return '%s: Accommodation Data' % self.context.__parent__.display_fullname
-
-# This manage form page is for both students and students officers.
+
 class AccommodationManageFormPage(SIRPEditFormPage):
     """ Page to manage bed tickets.
+
+    This manage form page is for both students and students officers.
     """
     grok.context(IStudentAccommodation)
@@ -1200,9 +1190,8 @@
     @property
     def selected_actions(self):
-        sa = self.actions
         if getattr(self.request.principal, 'user_type', None) == 'student':
-            sa = [action for action in self.actions
-                  if not action.label in self.officers_only_actions]
-        return sa
+            return [action for action in self.actions
+                    if not action.label in self.officers_only_actions]
+        return self.actions
 
 class BedTicketAddPage(SIRPPage):
@@ -1231,5 +1220,6 @@
             self.redirect(self.url(self.context))
             return
-        if student['studycourse'].current_session != acc_details['booking_session']:
+        if student['studycourse'].current_session != acc_details[
+            'booking_session']:
             self.flash(
                 'Your current session does not match accommodation session.')
@@ -1237,5 +1227,7 @@
             return
         if str(acc_details['booking_session']) in self.context.keys():
-            self.flash('You already booked a bed space in current accommodation session.')
+            self.flash(
+                'You already booked a bed space in current '
+                'accommodation session.')
             self.redirect(self.url(self.context))
             return
@@ -1275,5 +1267,6 @@
             return
         else:
-            comment = u"AC invalidated for %s" % self.context.getStudent().student_id
+            comment = u"AC invalidated for %s" % (
+                self.context.getStudent().student_id,)
             # Here we know that the ac is in state initialized so we do not
             # expect an exception, but the owner might be different
@@ -1385,5 +1378,5 @@
                 self.redirect(self.url(self.context))
                 return
-        # Rlease old bed if exists
+        # Release old bed if exists
         if self.context.bed != None:
             self.context.bed.owner = NOT_OCCUPIED
@@ -1402,5 +1395,4 @@
 
     def render(self):
-        #self.redirect(self.url(self.context, '@@index'))
         return
 
@@ -1567,9 +1559,7 @@
         return
 
-    # To be specified in the customisation package
     def dataNotComplete(self):
-        #store = getUtility(IExtFileStore)
-        #if not store.getFileByContext(self.context, attr=u'xyz.jpg'):
-        #    return 'No xyz scan uploaded.'
+        """To be implemented in the customization package.
+        """
         return False
 
@@ -1577,5 +1567,4 @@
     def requestClearance(self, **data):
         self.applyData(self.context, **data)
-        #self.context._p_changed = True
         if self.dataNotComplete():
             self.flash(self.dataNotComplete())
@@ -1648,5 +1637,6 @@
             return
         else:
-            comment = u"AC invalidated for %s" % self.context.getStudent().student_id
+            comment = u"AC invalidated for %s" % (
+                self.context.getStudent().student_id,)
             # Here we know that the ac is in state initialized so we do not
             # expect an exception, but the owner might be different
@@ -1724,5 +1714,6 @@
     @property
     def label(self):
-        return 'Add and remove course tickets of study level %s' % self.context.level_title
+        return 'Add and remove course tickets of study level %s' % (
+            self.context.level_title,)
 
     @property
@@ -1765,5 +1756,6 @@
     @action('Register course list', style='primary')
     def RegisterCourses(self, **data):
-        IWorkflowInfo(self.context.getStudent()).fireTransition('register_courses')
+        IWorkflowInfo(self.context.getStudent()).fireTransition(
+            'register_courses')
         self.flash('Course list has been registered.')
         self.redirect(self.url(self.context))
@@ -1787,17 +1779,14 @@
     @action('Add course ticket')
     def addCourseTicket(self, **data):
-        # Double bottom ...
+        # Safety belt
         if self.context.getStudent().state != PAID:
             return
         ticket = CourseTicket()
         course = data['course']
+        for name in ['code', 'title', 'credits', 'passmark', 'semester']:
+            setattr(ticket, name, getattr(course, name))
         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)
