Changeset 9402


Ignore:
Timestamp:
24 Oct 2012, 05:58:57 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize SPECIAL_HANDLING_DICT and getAccommodationDetails.

Location:
main/waeup.futminna/trunk/src/waeup/futminna
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.futminna/trunk/src/waeup/futminna/students/tests/test_browser.py

    r9298 r9402  
    2525from zope.interface import verify
    2626from waeup.kofa.app import University
     27from waeup.kofa.university.faculty import Faculty
     28from waeup.kofa.university.department import Department
    2729from waeup.kofa.students.tests.test_browser import StudentsFullSetup
    2830from waeup.kofa.testing import FunctionalTestCase
     
    7072    layer = FunctionalLayer
    7173
     74    def setUp(self):
     75        super(StudentUITests, self).setUp()
     76
     77        # Create SSE faculty with certificate
     78        self.app['faculties']['SSE'] = Faculty(code='SSE')
     79        self.app['faculties']['SSE']['dep1'] = Department(code='dep1')
     80        self.certificate2 = createObject('waeup.Certificate')
     81        self.certificate2.code = u'CERT2'
     82        self.certificate2.application_category = 'basic'
     83        self.certificate2.study_mode = 'ug_ft'
     84        self.certificate2.start_level = 100
     85        self.certificate2.end_level = 300
     86        self.app['faculties']['SSE']['dep1'].certificates.addCertificate(
     87            self.certificate2)
     88        # Set study course attributes of test student
     89        self.student['studycourse'].certificate = self.certificate2
     90        self.student['studycourse'].current_session = 2004
     91        self.student['studycourse'].entry_session = 2004
     92        self.student['studycourse'].current_verdict = 'A'
     93        self.student['studycourse'].current_level = 100
     94
    7295    def test_get_returning_data(self):
    7396        # Student is in level 100, session 2004 with verdict A
     
    99122        self.assertEqual(payment.p_session, 2004)
    100123        self.assertEqual(payment.amount_auth, 37000.0)
    101         self.assertEqual(payment.p_item, u'CERT1')
     124        self.assertEqual(payment.p_item, u'CERT2')
    102125        self.assertEqual(error, None)
    103126
    104         self.certificate.study_mode = 'jm_ft'
     127        self.certificate2.study_mode = 'jm_ft'
    105128        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    106129        self.assertEqual(payment.amount_auth, 72700.0)
     
    111134        self.assertEqual(payment.p_session, 2005)
    112135        self.assertEqual(payment.amount_auth, 37000.0)
    113         self.assertEqual(payment.p_item, u'CERT1')
     136        self.assertEqual(payment.p_item, u'CERT2')
    114137        self.assertEqual(error, None)
    115138
    116         self.certificate.study_mode = 'ug_ft'
     139        self.certificate2.study_mode = 'ug_ft'
    117140        error, payment = utils.setPaymentDetails('schoolfee',self.student)
    118141        self.assertEqual(payment.amount_auth, 20000.0)
    119 
    120142
    121143        error, payment = utils.setPaymentDetails('clearance',self.student)
     
    123145        self.assertEqual(payment.p_session, 2004)
    124146        self.assertEqual(payment.amount_auth, 20000.0)
    125         self.assertEqual(payment.p_item, u'CERT1')
     147        self.assertEqual(payment.p_item, u'CERT2')
    126148        self.assertEqual(error, None)
    127149
     
    129151        self.assertEqual(error, u'Previous session payment not yet implemented.')
    130152        return
     153
     154    def test_get_accommodation_details(self):
     155        self.app['configuration']['2004'].gown_fee = 150.0
     156        self.app['configuration']['2004'].transfer_fee = 90.0
     157        self.app['configuration']['2004'].booking_fee = 150.0
     158        self.app['configuration']['2004'].maint_fee = 180.0
     159        self.app['configuration']['2004'].clearance_fee = 120.0
     160        utils = getUtility(IStudentsUtils)
     161
     162        details = utils.getAccommodationDetails(self.student)
     163        self.assertEqual(details['bt'], u'sse_male_fr')
  • main/waeup.futminna/trunk/src/waeup/futminna/students/utils.py

    r9298 r9402  
    131131        return None, payment
    132132
     133    def getAccommodationDetails(self, student):
     134        """Determine the accommodation data of a student.
     135        """
     136        d = {}
     137        d['error'] = u''
     138        hostels = grok.getSite()['hostels']
     139        d['booking_session'] = hostels.accommodation_session
     140        d['allowed_states'] = hostels.accommodation_states
     141        d['startdate'] = hostels.startdate
     142        d['enddate'] = hostels.enddate
     143        d['expired'] = hostels.expired
     144        # Determine bed type
     145        studycourse = student['studycourse']
     146        certificate = getattr(studycourse,'certificate',None)
     147        entry_session = studycourse.entry_session
     148        current_level = studycourse.current_level
     149        if None in (entry_session, current_level, certificate):
     150            return d
     151        end_level = certificate.end_level
     152        if current_level == 10:
     153            bt = 'pr'
     154        elif entry_session == grok.getSite()['hostels'].accommodation_session:
     155            bt = 'fr'
     156        elif current_level >= end_level:
     157            bt = 'fi'
     158        else:
     159            bt = 're'
     160        sex = 'male'
     161        if student.sex == 'f':
     162            sex = 'female'
     163        special_handling = 'regular'
     164        if student.faccode == 'SSE':
     165            special_handling = 'sse'
     166        d['bt'] = u'%s_%s_%s' % (special_handling,sex,bt)
     167        return d
     168
    133169
    134170    # FUTMinna prefix
  • main/waeup.futminna/trunk/src/waeup/futminna/utils/utils.py

    r8833 r9402  
    2626    PREFERRED_LANGUAGES_DICT = {
    2727        }
     28
     29    SPECIAL_HANDLING_DICT = {
     30        'regular': 'Regular Hostel',
     31        'blocked': 'Blocked Hostel',
     32        'sse': 'SSE Hostel'
     33        }
Note: See TracChangeset for help on using the changeset viewer.