Changeset 9496


Ignore:
Timestamp:
1 Nov 2012, 08:35:49 (12 years ago)
Author:
Henrik Bettermann
Message:

In AAUE students are only allowed to register second semester courses if they have paid second school fee instalment. Tests will follow.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r8911 r9496  
    1919from zope.i18n import translate
    2020from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
     21from waeup.kofa.students.browser import CourseTicketAddFormPage
    2122from kofacustom.nigeria.students.browser import (
    2223    NigeriaOnlinePaymentDisplayFormPage,
     
    2425    NigeriaExportPDFPaymentSlipPage)
    2526
    26 from waeup.aaue.students.interfaces import ICustomStudentOnlinePayment
     27from waeup.aaue.students.interfaces import (
     28    ICustomStudentOnlinePayment, ICustomCourseTicketAdd)
    2729
    2830class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
     
    4951    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    5052    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     53
     54class CourseTicketAddFormPage2(CourseTicketAddFormPage):
     55    """Add a course ticket by student.
     56    """
     57    grok.name('ctadd')
     58    grok.require('waeup.handleStudent')
     59    form_fields = grok.AutoFields(ICustomCourseTicketAdd)
  • main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py

    r9154 r9496  
    1818
    1919from zope import schema
     20from zc.sourcefactory.contextual import BasicContextualSourceFactory
     21from zope.catalog.interfaces import ICatalog
     22from zope.component import getUtility
     23from waeup.kofa.interfaces import IKofaObject
    2024from kofacustom.nigeria.students.interfaces import (
    2125    INigeriaStudentBase, INigeriaUGStudentClearance, INigeriaPGStudentClearance,
     
    2630from waeup.aaue.payments.interfaces import ICustomOnlinePayment
    2731from waeup.aaue.interfaces import MessageFactory as _
     32
     33class CourseSource(BasicContextualSourceFactory):
     34    """A course source delivers all courses inside the portal by looking
     35       up a catalog.
     36    """
     37    def getValues(self, context):
     38        catalog = getUtility(ICatalog, name='courses_catalog')
     39        payments_folder =  context.student['payments']
     40        payments = [(p.p_session, p.p_category, p.p_state)
     41            for p in payments_folder.values()]
     42        courses = sorted(list(catalog.searchResults(
     43            code=(None, None))),key=lambda value: value.code)
     44        if (context.student.current_session, 'schoolfee_2', 'paid') in payments:
     45            pass
     46        else:
     47            courseslist = list(courses)
     48            for course in courseslist:
     49                if course.semester == 2:
     50                    courses.remove(course)
     51        return courses
     52
     53    def getToken(self, context, value):
     54        return value.code
     55
     56    def getTitle(self, context, value):
     57        return "%s - %s (%d)" % (
     58            value.code, value.title[:64], value.semester)
    2859
    2960class ICustomStudentBase(INigeriaStudentBase):
     
    91122    """
    92123
     124class ICustomCourseTicketAdd(IKofaObject):
     125    """An interface for adding course tickets.
     126
     127    """
     128    course = schema.Choice(
     129        title = _(u'Course'),
     130        source = CourseSource(),
     131        readonly = False,
     132        )
     133
    93134class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
    94135    """Representation of a student. Skip regular reg_number validation.
Note: See TracChangeset for help on using the changeset viewer.