Ignore:
Timestamp:
25 Feb 2017, 17:59:16 (8 years ago)
Author:
Henrik Bettermann
Message:

Customize warnCreditsOOR and IStudentStudyLevel.

Location:
main/waeup.fceokene/trunk/src/waeup/fceokene/students
Files:
6 edited

Legend:

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

    r13060 r14591  
    2424from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2525from waeup.kofa.students.browser import (
    26     StartClearancePage, BedTicketAddPage, ExportPDFAdmissionSlip)
     26    StartClearancePage, BedTicketAddPage,
     27    ExportPDFAdmissionSlip, StudyLevelDisplayFormPage)
    2728from kofacustom.nigeria.students.browser import (
    2829    NigeriaOnlinePaymentDisplayFormPage,
     
    3031    NigeriaExportPDFPaymentSlip,
    3132    NigeriaStudentClearanceEditFormPage,
    32     NigeriaExportPDFClearanceSlip
     33    NigeriaExportPDFClearanceSlip,
     34    NigeriaExportPDFCourseRegistrationSlip
    3335    )
    3436
    3537from waeup.fceokene.students.interfaces import (
    36     ICustomStudentOnlinePayment, ICustomUGStudentClearance)
     38    ICustomStudentOnlinePayment, ICustomUGStudentClearance,
     39    ICustomStudentStudyLevel)
    3740
    3841class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
     
    141144    notice = ''
    142145    with_ac = False
     146
     147class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
     148    """ Page to display student study levels
     149    """
     150    grok.context(ICustomStudentStudyLevel)
     151    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
     152    form_fields[
     153        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     154
     155class CustomExportPDFCourseRegistrationSlip(
     156    NigeriaExportPDFCourseRegistrationSlip):
     157    """Deliver a PDF slip of the context.
     158    """
     159    grok.context(ICustomStudentStudyLevel)
     160    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit('level')
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/interfaces.py

    r14018 r14591  
    250250    """
    251251
     252    total_credits_s1 = schema.Int(
     253        title = _(u'1st Semester Credits'),
     254        required = False,
     255        )
     256
     257    total_credits_s2 = schema.Int(
     258        title = _(u'2nd Semester Credits'),
     259        required = False,
     260        )
     261
     262    total_credits = schema.Int(
     263        title = _(u'Total Credits'),
     264        required = False,
     265        )
     266
    252267class ICustomStudentOnlinePayment(ICustomOnlinePayment):
    253268    """A student payment via payment gateways.
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/studylevel.py

    r14408 r14591  
    5252    grok.provides(ICustomStudentStudyLevel)
    5353
     54    @property
     55    def total_credits_s1(self):
     56        total = 0
     57        for ticket in self.values():
     58            if ticket.semester == 1 and not ticket.outstanding:
     59                total += ticket.credits
     60        return total
     61
     62    @property
     63    def total_credits_s2(self):
     64        total = 0
     65        for ticket in self.values():
     66            if ticket.semester == 2 and not ticket.outstanding:
     67                total += ticket.credits
     68        return total
     69
    5470CustomStudentStudyLevel = attrs_to_fields(
    55     CustomStudentStudyLevel, omit=['total_credits', 'gpa'])
     71    CustomStudentStudyLevel, omit=[
     72    'total_credits', 'total_credits_s1', 'total_credits_s2', 'gpa'])
    5673
    5774class CustomStudentStudyLevelFactory(StudentStudyLevelFactory):
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_browser.py

    r14406 r14591  
    2929from waeup.kofa.students.accommodation import BedTicket
    3030from waeup.kofa.testing import FunctionalTestCase
     31from waeup.kofa.browser.tests.test_pdf import samples_dir
    3132from waeup.kofa.interfaces import (
    3233    IExtFileStore, IFileStoreNameChooser)
     
    416417                           self.browser.contents)
    417418        return
     419
     420    def test_student_course_registration(self):
     421        IWorkflowState(self.student).setState('school fee paid')
     422        self.browser.open(self.login_path)
     423        self.browser.getControl(name="form.login").value = self.student_id
     424        self.browser.getControl(name="form.password").value = 'spwd'
     425        self.browser.getControl("Login").click()
     426        # Now students can add the current study level
     427        self.browser.getLink("Study Course").click()
     428        self.browser.getLink("Add course list").click()
     429        self.assertMatches('...Add current level 100 (Year 1)...',
     430                           self.browser.contents)
     431        self.browser.getControl("Create course list now").click()
     432        # Students can't open the customized pdf course registration slip
     433        self.browser.open(
     434            self.student_path + '/studycourse/100/course_registration_slip.pdf')
     435        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     436        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     437        path = os.path.join(samples_dir(), 'course_registration_slip.pdf')
     438        open(path, 'wb').write(self.browser.contents)
     439        print "Sample PDF course_registration_slip.pdf written to %s" % path
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/tests/test_utils.py

    r14586 r14591  
    3131        return
    3232
    33     def test_maxCreditsExceeded(self):
     33    def test_warnCreditsOOR(self):
    3434        students_utils = getUtility(IStudentsUtils)
    3535        studylevel = grok.Container()
    36         studylevel.total_credits = 40
     36        studylevel.total_credits_s1 = 17
     37        studylevel.total_credits_s2 = 17
    3738        course = grok.Model()
    38         course.credits = 18
     39        course.credits = 7
     40        course.semester = 1
    3941        warning = students_utils.warnCreditsOOR(studylevel, course)
    4042        self.assertEqual(warning, None)
    41         course.credits = 19
     43        course.credits = 8
    4244        warning = students_utils.warnCreditsOOR(studylevel, course)
    43         self.assertEqual(warning, 'Maximum credits exceeded.')
     45        self.assertEqual(warning, 'Maximum credits in 1st semester exceeded.')
     46        course.semester = 2
     47        warning = students_utils.warnCreditsOOR(studylevel, course)
     48        self.assertEqual(warning, 'Maximum credits in 2nd semester exceeded.')
     49        warning = students_utils.warnCreditsOOR(studylevel)
     50        self.assertEqual(warning, 'Minimum credits in 1st semester not reached.')
     51        studylevel.total_credits_s1 = 18
     52        warning = students_utils.warnCreditsOOR(studylevel)
     53        self.assertEqual(warning, 'Minimum credits in 2nd semester not reached.')
    4454        return
    4555
  • main/waeup.fceokene/trunk/src/waeup/fceokene/students/utils.py

    r14586 r14591  
    362362
    363363    def warnCreditsOOR(self, studylevel, course=None):
    364         """Return message if credits are out of range. In the base
    365         package only maximum credits is set.
    366         """
    367         if course and studylevel.total_credits + course.credits > 58:
    368             return _('Maximum credits exceeded.')
    369         elif studylevel.total_credits > 58:
    370             return _('Maximum credits exceeded.')
     364        """Return message if credits are out of range.
     365        """
     366        # adding a course ticket
     367        if course:
     368            if course.semester == 1:
     369                if studylevel.total_credits_s1 + course.credits > 24:
     370                    return _('Maximum credits in 1st semester exceeded.')
     371            if course.semester == 2:
     372                if studylevel.total_credits_s2 + course.credits > 24:
     373                    return _('Maximum credits in 2nd semester exceeded.')
     374        # registering course list
     375        else:
     376            if studylevel.total_credits_s1 > 24:
     377                return _('Maximum credits in 1st semester exceeded.')
     378            if studylevel.total_credits_s1 < 18:
     379                return _('Minimum credits in 1st semester not reached.')
     380            if studylevel.total_credits_s2 > 24:
     381                return _('Maximum credits in 2nd semester exceeded.')
     382            if studylevel.total_credits_s2 < 18:
     383                return _('Minimum credits in 2nd semester not reached.')
    371384        return
    372385
Note: See TracChangeset for help on using the changeset viewer.