Changeset 3048 for WAeUP_SRP


Ignore:
Timestamp:
25 Jan 2008, 14:45:17 (17 years ago)
Author:
joachim
Message:

streamlined getAccommodationInfo should resolve #453

Location:
WAeUP_SRP/uniben
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/uniben/profiles/default/vocabularies/acco_special_handling.xml

    r1449 r3048  
    88 <item key="no" msgid="">---</item>
    99 <item key="pg" msgid="">Postgraduate</item>
    10  <item key="med" msgid="">Medical (Level 500/600)</item>
     10 <item key="no_med" msgid="">Medical (Level 500/600)</item>
    1111 <item key="no_ekenhuan" msgid="">Ekenhuan Campus</item>
    1212 <item key="no_pti" msgid="">PTI</item>
  • WAeUP_SRP/uniben/waeup_custom/getAccommodationInfo.py

    r2914 r3048  
    3535    else:
    3636        student_id = member_id
    37 res = context.students_catalog(id=student_id)
    38 if len(res) != 1:
     37student_record = context.students_catalog.getRecordByKey(student_id)
     38if student_record is None:
    3939    logger.info('%s not found in students_catalog' % student_id)
    4040    return None
     
    5757                    'BENGMEP',
    5858                    )
    59 s_brain = res[0]
    6059info['error'] = None
    61 info['matric_no']=s_brain.matric_no
    62 info['jamb_reg_no']=s_brain.jamb_reg_no
    63 info['name']=s_brain.name
    64 info['email']=s_brain.email
    65 info['level']=s_brain.level
    66 info['verdict']=getattr(s_brain,'verdict','')
    67 review_state = info['review_state'] = s_brain.review_state
     60info['matric_no']=student_record.matric_no
     61info['jamb_reg_no']=student_record.jamb_reg_no
     62info['name']=student_record.name
     63info['email']=student_record.email
     64info['level']=student_record.level
     65info['verdict']=getattr(student_record,'verdict','')
     66review_state = info['review_state'] = student_record.review_state
    6867
    6968info['session'] = session = context.getSessionId()
     
    7574
    7675booking_allowed = False
    77 if review_state in ('cleared_and_validated','returning','school_fee_paid','courses_registered', 'courses_validated',) and s_brain.session == session[0]:
     76if review_state in ('cleared_and_validated','returning','school_fee_paid','courses_registered', 'courses_validated',) and student_record.session == session[0]:
    7877    booking_allowed = True
    79     if s_brain.matric_no:
    80         res = context.results_import(matric_no = s_brain.matric_no)
     78    if student_record.matric_no:
     79        res = context.results_import(matric_no = student_record.matric_no)
    8180        if res:
    8281            booking_allowed = info['verdict'] in ("A",
     
    8887if not booking_allowed:
    8988    info['acco'] = None
    90     return info
     89#    return info
    9190
    9291acco_id = 'accommodation_' + session[0]
     
    105104if review_state == "cleared_and_validated":
    106105    bt = 'fr'
    107 elif int(s_brain.level) < 300:
     106elif int(student_record.level) < 100:
     107    bt = 'pr'
     108elif int(student_record.level) < int(student_record.end_level):
    108109    bt = 're'
    109 elif int(s_brain.level) < 100:
    110     bt = 'pr'
    111 elif s_brain.faculty in ('MED') and int(s_brain.level) >= 400:
    112     bt = "med"
    113110else:
    114     res = context.portal_catalog(portal_type = "Certificate", id = s_brain.course)
    115     if res:
    116         c_brain = res[0]
    117         #from Products.zdb import set_trace; set_trace()
    118         certificate = c_brain.getObject().getContent()
    119         try:
    120             certlevel = int(certificate.end_level)
    121         except:
    122             info["error"] = '"no end_level for","%s"' % c_brain.getId
    123             return info
    124         try:
    125             studentlevel = int(s_brain.level)
    126         except:
    127             info["error"] = '"no level for","%s"' % s_brain.getId
    128             return info
    129         if studentlevel >= certlevel:
    130             bt = "fi"
     111    bt = 'fi'
     112# else:
     113#     res = context.portal_catalog(portal_type = "Certificate", id = student_record.course)
     114#     if res:
     115#         c_brain = res[0]
     116#         #from Products.zdb import set_trace; set_trace()
     117#         certificate = c_brain.getObject().getContent()
     118#         try:
     119#             certlevel = int(certificate.end_level)
     120#         except:
     121#             info["error"] = '"no end_level for","%s"' % c_brain.getId
     122#             return info
     123#         try:
     124#             studentlevel = int(student_record.level)
     125#         except:
     126#             info["error"] = '"no level for","%s"' % student_record.getId
     127#             return info
     128#         if studentlevel >= certlevel:
     129#             bt = "fi"
    131130d['sex'] = 'male'
    132 if s_brain.sex:
     131if student_record.sex:
    133132    d['sex'] = 'female'
    134 if s_brain.course in ekehuan_certificates:
     133if student_record.faculty in ('MED') and int(student_record.level) > 400:
     134    bt += "_med"
     135elif student_record.course in ekehuan_certificates:
    135136    bt += "_ekenhuan"
    136 elif s_brain.course in pti_certificates:
     137elif student_record.course in pti_certificates:
    137138    bt += "_pti"
    138139
     
    142143
    143144d['bt'] = bt
    144 #from Products.zdb import set_trace
    145 #set_trace()
    146145student_status = "%(sex)s_%(bt)s" % d
    147146info['student_status'] = student_status
Note: See TracChangeset for help on using the changeset viewer.