Changeset 2454


Ignore:
Timestamp:
27 Oct 2007, 21:53:04 (17 years ago)
Author:
Henrik Bettermann
Message:

rebuild getNextInfo.py completely
fetch session from portal properties.xml
change all scripts using getSessionId
remove StudentCourseResult? relevant code from event services
make pay_by_sc.py and interswitch_cb.py work (rebuild both)

Location:
WAeUP_SRP
Files:
2 added
1 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/Accommodation.py

    r2443 r2454  
    196196                accommodation.modifyRecord(bed=already[0].bed,student='')
    197197                student_obj = getattr(students_folder, student.id)
    198                 acco_id = "accommodation_%s" % self.getSessionId()
     198                acco_id = "accommodation_%s" % self.getSessionId()[0]
    199199                if acco_id in student_obj.objectIds():
    200200                    acco_doc = getattr(student_obj, acco_id).getContent()
  • WAeUP_SRP/base/Students.py

    r2128 r2454  
    353353            da["jamb_middlename"] = middlename
    354354            da["jamb_lastname"] = lastname
    355             catalog_entry['entry_session'] = da["entry_session"] = self.getSessionId()[-2:]
     355            catalog_entry['entry_session'] = da["entry_session"] = self.getSessionId()[0]
    356356            catalog_entry['sex'] = sex = result.get(csv_d['jamb_sex']).startswith('F')
    357357            da_fields = ('jamb_reg_no',
  • WAeUP_SRP/base/WAeUPTables.py

    r2448 r2454  
    985985                                             import_record.Lastname)
    986986                data['jamb_reg_no'] = import_record.Entryregno
    987             if reindex_special and 'registered_courses' in reindex_special:
    988                 try:
    989                     study_course = getattr(student_object,"study_course")
    990                     level_ids = study_course.objectIds()
    991                 except:
    992                     continue
    993                 if not level_ids:
    994                     continue
    995                 modified = True
    996                 level_ids.sort()
    997                 course_ids = getattr(study_course,level_ids[-1]).objectIds()
    998                 courses = []
    999                 for c in course_ids:
    1000                     if c.endswith('_co'):
    1001                         courses.append(c[:-3])
    1002                     else:
    1003                         courses.append(c)
    1004                 data['registered_courses'] = courses
     987            #if reindex_special and 'registered_courses' in reindex_special:
     988            #    try:
     989            #        study_course = getattr(student_object,"study_course")
     990            #        level_ids = study_course.objectIds()
     991            #    except:
     992            #        continue
     993            #    if not level_ids:
     994            #        continue
     995            #    modified = True
     996            #    level_ids.sort()
     997            #    course_ids = getattr(study_course,level_ids[-1]).objectIds()
     998            #    courses = []
     999            #    for c in course_ids:
     1000            #        if c.endswith('_co'):
     1001            #            courses.append(c[:-3])
     1002            #        else:
     1003            #            courses.append(c)
     1004            #    data['registered_courses'] = courses
    10051005            if modified:
    10061006                self.modifyRecord(**data)
     
    10521052                                             import_record.Lastname)
    10531053                data['jamb_reg_no'] = import_record.Entryregno
    1054             else:
    1055                 study_course = getattr(student_object,'study_course',None)
    1056                 current_level = data.get('level',None)
    1057                 data['registered_courses'] = []
    1058                 if study_course and current_level and current_level in study_course.objectIds():
    1059                     level_obj = getattr(study_course,current_level)
    1060                     courses = []
    1061                     for c in level_obj.objectIds():
    1062                         if c.endswith('_co'):
    1063                             courses.append(c[:-3])
    1064                         else:
    1065                             courses.append(c)
    1066                     data['registered_courses'] = courses
     1054            #else:
     1055            #    study_course = getattr(student_object,'study_course',None)
     1056            #    current_level = data.get('level',None)
     1057            #    data['registered_courses'] = []
     1058            #    if study_course and current_level and current_level in study_course.objectIds():
     1059            #        level_obj = getattr(study_course,current_level)
     1060            #        courses = []
     1061            #        for c in level_obj.objectIds():
     1062            #            if c.endswith('_co'):
     1063            #                courses.append(c[:-3])
     1064            #            else:
     1065            #                courses.append(c)
     1066            #        data['registered_courses'] = courses
    10671067            self.addRecord(**data)
    10681068        if pghandler: pghandler.finish()
     
    10971097                self.deleteRecord(student_id)
    10981098                #import pdb;pdb.set_trace()
    1099         elif pt == 'StudentCourseResult' and mt == 'CPS Proxy Folder':
    1100             if event_type not in ("sys_add_object","sys_del_object"):
    1101                 return
    1102             level_session = getattr(object.aq_parent.getContent(),'session','unknown')
    1103             if level_session not in (self.getSessionId()[-2:],'2006/2007'):
    1104                 return
    1105             course_id = object.getId()
    1106             if course_id.endswith('_co'):
    1107                 course_id = course_id[:-3]
    1108             student_id = object.absolute_url_path().split('/')[-4]
    1109             res = students_catalog(id = student_id)
    1110             if not res:
    1111                 return
    1112             student_rec = res[0]
    1113             registered_courses = getattr(student_rec,'registered_courses',None)
    1114             if not registered_courses:
    1115                 registered_courses = []
    1116             if event_type == "sys_add_object":
    1117                 if course_id not in registered_courses:
    1118                     registered_courses.append(course_id)
    1119                 else:
    1120                     return
    1121             elif registered_courses and event_type == "sys_del_object":
    1122                 removed = False
    1123                 while course_id in registered_courses:
    1124                     removed = True
    1125                     registered_courses.remove(course_id)
    1126                 if not removed:
    1127                     return
    1128             data['id'] = student_id
    1129             data['registered_courses'] = registered_courses
    1130             self.modifyRecord(record = student_rec, **data)
    1131             return
     1099        #elif pt == 'StudentCourseResult' and mt == 'CPS Proxy Folder':
     1100        #    if event_type not in ("sys_add_object","sys_del_object"):
     1101        #        return
     1102        #    level_session = getattr(object.aq_parent.getContent(),'session','unknown')
     1103        #    if level_session not in (self.getSessionId()[-2:],'2006/2007'):
     1104        #        return
     1105        #    course_id = object.getId()
     1106        #    if course_id.endswith('_co'):
     1107        #        course_id = course_id[:-3]
     1108        #    student_id = object.absolute_url_path().split('/')[-4]
     1109        #    res = students_catalog(id = student_id)
     1110        #    if not res:
     1111        #        return
     1112        #    student_rec = res[0]
     1113        #    registered_courses = getattr(student_rec,'registered_courses',None)
     1114        #    if not registered_courses:
     1115        #        registered_courses = []
     1116        #    if event_type == "sys_add_object":
     1117        #        if course_id not in registered_courses:
     1118        #            registered_courses.append(course_id)
     1119        #        else:
     1120        #            return
     1121        #    elif registered_courses and event_type == "sys_del_object":
     1122        #        removed = False
     1123        #        while course_id in registered_courses:
     1124        #            removed = True
     1125        #            registered_courses.remove(course_id)
     1126        #        if not removed:
     1127        #            return
     1128        #    data['id'] = student_id
     1129        #    data['registered_courses'] = registered_courses
     1130        #    self.modifyRecord(record = student_rec, **data)
     1131        #    return
    11321132        if pt not in self.affected_types.keys():
    11331133            return
  • WAeUP_SRP/base/WAeUPTool.py

    r2436 r2454  
    458458
    459459        entry_session = dict.get('entry_session')
    460         if entry_session == self.getSessionId()[-2:]:
     460        if entry_session == self.getSessionId()[0]:
    461461            wfaction = 'admit'
    462462            wft = 'wf_transition_admit'
     
    554554            level = "%d00" % lnr
    555555            verdict,eligible = self.getVerdict(s_results[0].Verdict)
    556             if eligible:
    557                 level = "%d00" % (lnr + 1)
     556            #if eligible:
     557            #    level = "%d00" % (lnr + 1)
    558558        else:
    559559            logger.info('matric_no %s not found in results_import' % student.matric_no)
     
    579579        da['jamb_reg_no'] = student.Entryregno
    580580        em = self.getEntryMode(student.Entryregno)
    581 ##        em = student.Mode_of_Entry
    582 ##        if em in ('DIRECT', 'DIRECT ENTRY',):
    583 ##            em = 'DE'
    584 ##        elif em in ('U.M.E', 'UNE',):
    585 ##            em = 'UME'
    586 ##        elif not em:
    587 ##            em = "unknown"
    588581        da['entry_mode'] = em
    589582        personal = student_obj.personal
     
    616609        clearance.getContent().edit(mapping=dc)
    617610        self.portal_workflow.doActionFor(clearance,'close',dest_container=clearance)
    618 ##        catd = {}
    619 ##        catd['id'] = sid
    620 ##        catd['entry_mode']= da['entry_mode']
    621 ##        catd['matric_no'] = matric_no
    622 ##        catd['jamb_reg_no'] = da['jamb_reg_no']
    623 ##        catd['name'] = "%(firstname)s %(middlename)s %(lastname)s" % dp
    624 ##        catd['sex'] = dp['sex']
    625 ##        catd['level'] = level
    626 ##        catd['verdict'] = verdict
    627 ##        if certificate_brain:
    628 ##            cpath = certificate_brain.getPath().split('/')
    629 ##            catd['faculty'] = cpath[-4]
    630 ##            catd['department'] = cpath[-3]
    631 ##            catd['course'] = certcode
    632 ##        self.students_catalog.modifyRecord(**catd)
    633611        #
    634612        # Study Course
     
    12951273            for field in f2t[pt]['fields']:
    12961274                d[field] = mapping.get(field,'')
    1297                
    1298             if pt == "StudentApplication":   
     1275
     1276            if pt == "StudentApplication":
    12991277                d['jamb_sex']  = 'M'
    13001278                if mapping.get('sex'):
  • WAeUP_SRP/base/Widgets.py

    r2433 r2454  
    277277            v = value = '0%c' % v
    278278        elif not value:
    279             v = value = self.getSessionId()[-2:]
     279            v = value = self.getSessionId()[0]
    280280        #import pdb;pdb.set_trace()
    281281        sessions = self._getSessions()
  • WAeUP_SRP/base/skins/cps_custom/config_form.pt

    r2288 r2454  
    7171      <tr>
    7272        <th>
     73          <label>
     74            Current Session
     75          </label>
     76        </th>
     77        <td>
     78          <input name="session" id="portal_session" value=""
     79                 tal:attributes="value pprops/session" />
     80        </td>
     81      </tr>     
     82      <tr>
     83        <th>
    7384          <label for="portal_description"
    7485                 i18n:translate="label_portal_description">
  • WAeUP_SRP/base/skins/waeup_accommodation/allocate_reserved_bed.py

    r1566 r2454  
    6464students = context.portal_url.getPortalObject().campus.students
    6565student_obj = getattr(students,sid)
    66 acco_id = "accommodation_%s" % context.getSessionId()
     66acco_id = "accommodation_%s" % context.getSessionId()[0]
    6767while True:
    6868    if not res:
  • WAeUP_SRP/base/skins/waeup_accommodation/change_bed.py

    r2000 r2454  
    6060        return redirect("%s/%s/%s" % (students.absolute_url(),student,info['acco_id']))
    6161    student_obj = getattr(students,student_id)
    62     acco_id = "accommodation_%s" % context.getSessionId()
     62    acco_id = "accommodation_%s" % context.getSessionId()[0]
    6363    if acco_id in student_obj.objectIds():
    6464        acco_doc = getattr(student_obj, acco_id).getContent()
  • WAeUP_SRP/base/skins/waeup_accommodation/getAccommodationInfo.py

    r2427 r2454  
    8080            booking_allowed = info['verdict'] in ("A",
    8181                                                 "B",)
    82                                                  
     82
    8383booking_allowed = False # booking temporarily disabled
    8484                        # the algorithm must be adapted to new course_results catalog
    8585                        # and/or FCEOkene modalities
    86                        
    87                        
    88                        
    89                        
    90                        
    91                        
    92                        
    93                                                                          
    94                                                  
     86
     87
    9588info['booking_allowed'] = booking_allowed
    9689if not booking_allowed:
    9790    info['acco'] = None
    9891    return info
    99 acco_id = 'accommodation_2006'
     92info['session'] = session = context.getSessionId() 
     93acco_id = 'accommodation_' + session[0]
    10094acco = getattr(student,acco_id,None)
    10195info['acco'] = acco
  • WAeUP_SRP/base/skins/waeup_accommodation/reserve_accommodation.py

    r2000 r2454  
    2727student = info['student']
    2828acco_id = info['acco_id']
    29 session = acco_id[-4:]
     29session = info['session'][1]
     30#session = acco_id[-4:]
    3031validate = REQUEST.has_key("cpsdocument_create_button")
    3132if info.has_key('acco') and info['acco']:
  • WAeUP_SRP/base/skins/waeup_default/getSessionId.py

    r2133 r2454  
    1515# must be changed in 2007/2008; should return only the last two digits
    1616
    17 import DateTime
    18 now = DateTime.DateTime()
    19 if now.month() > 11:
    20     s = "%s" % now.year()
    21 else:
    22     s = "%s" % (now.year() - 1)
    23 return s
     17#import DateTime
     18#now = DateTime.DateTime()
     19#if now.month() > 11:
     20#    s = "%s" % now.year()
     21#else:
     22#    s = "%s" % (now.year() - 1)
     23#return s
     24
     25session_id = context.portal_properties.session[2:4]
     26session_str = context.portal_properties.session
     27
     28return [session_id, session_str]
  • WAeUP_SRP/base/skins/waeup_epayment/getPaymentsFolderInfo.py

    r2249 r2454  
    7171info['prod_id'] = '61'
    7272session = s_brain.session
    73 info['next_session'], info['next_session_str'] = context.getNextSessionId(session)
     73next_info = context.getNextInfo(s_brain)
     74info['next_session'] = next_info['next_session_id']
     75info['next_session_str'] = next_info['next_session_str']
    7476
    7577info['student_name'] = s_brain.name
  • WAeUP_SRP/base/skins/waeup_epayment/interswitch_cb.py

    r2135 r2454  
    5252    pd[pdk] = request.get(rc,'')
    5353
    54 # for testing purposes
     54## for testing purposes
    5555#pd['resp_desc'] = 'Simulated Callback'
    5656#pd['resp_pay_reference'] = 'XXXX'
     
    7474s_brain = context.students_catalog(id=student_id)[0]
    7575session = s_brain.session
    76 next_session, next_session_str = context.getNextSessionId(session)
     76#next_session, next_session_str = context.getNextSessionId(session)
     77
     78next_info = context.getNextInfo(s_brain)
     79next_session_id = next_info['next_session_id']
     80next_session_str = next_info['next_session_str']
     81next_level_id = next_info['next_level_id']
     82next_transition = next_info['next_transition']
    7783
    7884if  resp == '00':
     
    8086        logger.info('%s paid school_fee in state school_fee_paid' % (student_id))
    8187    else:
    82         if next_session == context.getSessionId()[-2:]:
    83             wftool.doActionFor(student,'pay_school_fee')
    84         else:
    85             study_course = getattr(student,'study_course')
    86             try:
    87                 wftool.doActionFor(study_course,'open')
    88             except:
    89                 pass
    90             study_course_doc = study_course.getContent()
    91             next_level = "%s" % (int(s_brain.level) + 100)
    92             study_course_doc.edit(mapping= {'current_level': next_level,
    93                                             'current_session': next_session,})
     88        study_course = getattr(student,'study_course')
     89        try:
     90            wftool.doActionFor(study_course,'open')
     91        except:
     92            pass
     93        study_course.getContent().edit(mapping= {'current_level': next_level_id,
     94                                                 'current_session': next_session_id,})
     95        if next_transition:
     96            wftool.doActionFor(student,next_transition)   
     97
    9498    logger.info('%s received valid callback' % student_id)
    9599    referer = request.get('HTTP_REFERER','none')
  • WAeUP_SRP/base/skins/waeup_epayment/pay_by_sc.py

    r2451 r2454  
    2424if context.portal_membership.isAnonymousUser():
    2525    return None
    26 
     26wftool = context.portal_workflow
    2727lt = context.portal_layouts
    2828request = context.REQUEST
     
    3434student = getattr(students,student_id)
    3535s_brain = context.students_catalog(id=student_id)[0]
    36 next_info = context.getNextInfo(s_brain)
    37 next_session_id = next_info['next_session_id']
    38 next_session_str = next_info['next_session_str']
    39 next_level_id = next_info['next_level_id']
    40 next_transition = next_info['next_transition']
    41 study_course = getattr(student,'study_course')
    42 study_course.getContent().edit(mapping= {'current_level': next_level_id,
    43                                          'current_session': next_session_id,})
    44 if next_transition:
    45     wftool.doActionFor(student,next_transition)
    4636
    4737# session = s_brain.session
    4838# next_session, next_session_str = context.getNextSessionId(session)
    49 # validate = request.has_key("cpsdocument_create_button")
     39
     40next_info = context.getNextInfo(s_brain)
     41next_session_id = next_info['next_session_id']
     42next_session_str = next_info['next_session_str']
     43next_level_id = next_info['next_level_id']
     44next_transition = next_info['next_transition']
     45
     46validate = request.has_key("cpsdocument_create_button")
    5047res,psm,ds = lt.renderLayout(layout_id= 'student_schoolfee',
    5148                      schema_id= 'payment',
     
    113110    payment.getContent().edit(mapping=info)
    114111    wftool.doActionFor(payment,'close')
    115     if next_session == context.getSessionId()[-2:]:
    116         wftool.doActionFor(student,'pay_school_fee')
    117     else:
    118         study_course = getattr(student,'study_course')
    119         #wftool.doActionFor(study_course,'open')
    120         study_course_doc = study_course.getContent()
    121         next_level = "%s" % (int(s_brain.level) + 100)
    122         study_course_doc.edit(mapping= {'current_level': next_level,
    123                                         'current_session': next_session,})
     112
     113    study_course = getattr(student,'study_course')
     114    study_course.getContent().edit(mapping= {'current_level': next_level_id,
     115                                             'current_session': next_session_id,})
     116    if next_transition:
     117        wftool.doActionFor(student,next_transition)   
     118   
     119    #if next_session == context.getSessionId()[-2:]:
     120    #    wftool.doActionFor(student,'pay_school_fee')
     121    #else:
     122    #    study_course = getattr(student,'study_course')
     123    #    #wftool.doActionFor(study_course,'open')
     124    #    study_course_doc = study_course.getContent()
     125    #    next_level = "%s" % (int(s_brain.level) + 100)
     126    #    study_course_doc.edit(mapping= {'current_level': next_level,
     127    #                                    'current_session': next_session,})
     128   
    124129    logger.info('%s paid school fee by scratch card' % student_id)
    125130else:
  • WAeUP_SRP/base/skins/waeup_student/create_level.py

    r2448 r2454  
    7272    results = context.results_import(matric_no = student.matric_no)
    7373records = []
    74 if results:
    75     l = []
     74l = []
     75if student.session in ('6', '06') and results:
    7676    carry_overs = results
    7777    for co in carry_overs:
     
    154154logger.info('%s finished to create level %s' % (student.id,current_level))
    155155
    156 if current_session == '05':
    157     next_session = '06'
    158     next_level = "%s" % (int(current_level) + 100)
    159     study_course = getattr(student,'study_course')
    160     context.portal_workflow.doActionFor(study_course,'open')
    161     study_course_doc = study_course.getContent()
    162     study_course_doc.edit(mapping= {'current_level': next_level,
    163                                     'current_session': next_session,})
    164     context.portal_workflow.doActionFor(study_course,'close_for_edit')
     156#if current_session == '05':
     157#    next_session = '06'
     158#    next_level = "%s" % (int(current_level) + 100)
     159#    study_course = getattr(student,'study_course')
     160#    context.portal_workflow.doActionFor(study_course,'open')
     161#    study_course_doc = study_course.getContent()
     162#    study_course_doc.edit(mapping= {'current_level': next_level,
     163#                                    'current_session': next_session,})
     164#    context.portal_workflow.doActionFor(study_course,'close_for_edit')
    165165
    166166return response.redirect("%s/%s" % (context.absolute_url(),current_level))
  • WAeUP_SRP/base/skins/waeup_student/getNextInfo.py

    r2451 r2454  
    1 ## Script (Python) "getSessionId"
     1## Script (Python) "getNextInfo"
    22##bind container=container
    33##bind context=context
     
    1212return the students next info
    1313"""
     14
    1415info = {}
     16
     17session_id = student_brain.session
     18level_id = student_brain.level
     19review_state = student_brain.review_state
     20verdict = student_brain.verdict
    1521info['next_transition'] = None
    16 session_id = student_brain.session
    17 if int(session_id) > int(context.getSessionId()[3:4]) -2:
     22info['next_session_id'] = next_session_id = session_id
     23info['next_level_id'] = next_level_id = level_id
     24
     25if review_state == 'cleared_and_validated':
    1826    info['next_transition'] = "pay_school_fee"
     27elif review_state == 'returning':
     28    info['next_level_id'] = "%s" % (int(level_id) + 100)
     29    info['next_session_id'] = next_session_id = "%02d" % (int(session_id)+1)
     30    if int(session_id) > int(context.getSessionId()[0]) -2:
     31        info['next_transition'] = "pay_school_fee"
     32        if verdict not in ('A','B',):
     33            info['next_level_id'] = level_id
    1934
    20 if student_brain.review_state == "returning":
    21     session_id info['next_session_id'] = "%02d" % int(session_id) + 1
    22 info['next_session_str'] = context.session_voc(session_id)
    23 next_level_id = student_brain.level
    24 if student_brain.review_state not in ('cleared_and_validated',)
    25     next_level_id = "%s" % (int(next_level_id) + 100)
    26 info['next_level_id'] = next_level_id
    27 
     35info['next_session_str'] = context.sessions_voc(next_session_id)
    2836
    2937return info
  • WAeUP_SRP/base/skins/waeup_student/getStudyLevelInfo.py

    r2451 r2454  
    9797info['credits_exceeded'] = credits_total > 51
    9898current_session = student.session
    99 info['submission_allowed']= not info['credits_exceeded'] and current_session == context.getSessionId()[-2:]
     99info['submission_allowed']= not info['credits_exceeded'] and current_session == context.getSessionId()[0]
    100100# carry_overs.sort(cmp_semester_id)
    101101info['carry_overs'] = carry_overs
  • WAeUP_SRP/base/skins/waeup_utilities/fixReservedBeds.py

    r1567 r2454  
    1717students = context.portal_url.getPortalObject().campus.students
    1818hostels = context.portal_url.getPortalObject().campus.accommodation.objectItems()
    19 acco_id = "accommodation_%s" % context.getSessionId()
     19acco_id = "accommodation_%s" % context.getSessionId()[0]
    2020logger.info('%s starts fixReservedBeds' % (member))
    2121#from Products.zdb import set_trace;set_trace()
  • WAeUP_SRP/base/skins/waeup_utilities/fixReturningSession.py

    r2453 r2454  
    3636brains = aq_students(query)
    3737total = len(brains)
    38 logger.info('editet %d students with session 06 and returning' % total)
     38logger.info('editet %d students with session 06 and state returning' % total)
    3939count = 0
    4040commit_after = 100
     
    5555    except:
    5656        rwrite('>>>> not found %s study_course' % (brain.id))
    57        
     57
  • WAeUP_SRP/fceokene/profiles/default/properties.xml

    r486 r2454  
    44 <property name="enable_password_reset" type="boolean">True</property>
    55 <property name="enable_portal_joining" type="boolean">False</property>
     6 <property name="session" type="string">06</property>
    67</site>
Note: See TracChangeset for help on using the changeset viewer.