Index: main/waeup.aaue/trunk/src/waeup/aaue/locales/en/LC_MESSAGES/waeup.kofa.po
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/locales/en/LC_MESSAGES/waeup.kofa.po	(revision 14224)
+++ main/waeup.aaue/trunk/src/waeup/aaue/locales/en/LC_MESSAGES/waeup.kofa.po	(revision 14227)
@@ -137,2 +137,6 @@
 msgid "<b>Credits: ${a}</b>"
 msgstr "<b>Units: ${a}</b>"
+
+msgid "Course ${a} cannot be registered."
+msgstr ""
+"Course ${a} cannot be registered. You have to pay for the 2nd semester first."
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py	(revision 14224)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py	(revision 14227)
@@ -28,4 +28,5 @@
 from waeup.kofa.utils.helpers import attrs_to_fields
 from waeup.kofa.interfaces import CREATED
+from waeup.kofa.students.browser import TicketError
 from waeup.kofa.students.studylevel import (
     StudentStudyLevel, CourseTicket,
@@ -160,4 +161,15 @@
         return 'N/A'
 
+    def _schoolfeePaymentMade(self):
+        if len(self.student['payments']):
+            for ticket in self.student['payments'].values():
+                if ticket.p_state == 'paid' and \
+                    ticket.p_category in (
+                        'schoolfee', 'schoolfee_incl', 'schoolfee_2',)  and \
+                    ticket.p_session == self.student[
+                        'studycourse'].current_session:
+                    return True
+        return False
+
     def addCourseTicket(self, ticket, course):
         """Add a course ticket object.
@@ -166,4 +178,8 @@
             raise TypeError(
                 'StudentStudyLeves contain only ICourseTicket instances')
+        # Raise TicketError if course is in 2nd semester but
+        # schoolfee has not yet been fully paid.
+        if course.semester == 2 and not self._schoolfeePaymentMade():
+            raise TicketError
         ticket.code = course.code
         ticket.title = course.title
@@ -179,4 +195,22 @@
         return
 
+    def addCertCourseTickets(self, cert):
+        """Collect all certificate courses and create course
+        tickets automatically.
+        """
+        if cert is not None:
+            for key, val in cert.items():
+                if val.level != self.level:
+                    continue
+                ticket = createObject(u'waeup.CourseTicket')
+                ticket.automatic = True
+                ticket.mandatory = val.mandatory
+                ticket.carry_over = False
+                try:
+                    self.addCourseTicket(ticket, val.course)
+                except TicketError:
+                    pass
+        return
+
 CustomStudentStudyLevel = attrs_to_fields(
     CustomStudentStudyLevel, omit=[
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 14224)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 14227)
@@ -709,4 +709,36 @@
         print "Sample PDF pg_course_registration_slip.pdf written to %s" % path
 
+    def test_student_2nd_semester_course_registration(self):
+        IWorkflowState(self.student).setState('school fee paid')
+        self.course.semester = 2
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        self.browser.getLink("Study Course").click()
+        self.browser.getLink("Add course list").click()
+        self.browser.getControl("Create course list now").click()
+        self.assertFalse('COURSE1' in self.browser.contents)
+        # 2nd semester tickets can't be added manually
+        self.browser.getLink("Edit course list").click()
+        self.browser.getLink("here").click()
+        self.browser.getControl(name="form.course").value = ['COURSE1']
+        self.browser.getControl("Add course ticket").click()
+        self.assertTrue(
+            'Course COURSE1 cannot be registered. '
+            'You have to pay for the 2nd semester first.'
+            in self.browser.contents)
+        # 2nd instalment has to be paid first
+        self.certificate.school_fee_3 = 678.0
+        self.browser.open(self.payments_path + '/addop')
+        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
+        self.browser.getControl("Create ticket").click()
+        self.student['payments'].values()[0].approve()
+        self.browser.open(self.studycourse_path + '/100/ctadd')
+        self.browser.getControl(name="form.course").value = ['COURSE1']
+        self.browser.getControl("Add course ticket").click()
+        self.assertTrue('Successfully added COURSE1' in self.browser.contents)
+        return
+
     def test_student_clearance(self):
         # Student cant login if their password is not set
