Changeset 5655


Ignore:
Timestamp:
21 Jan 2011, 15:02:44 (14 years ago)
Author:
Henrik Bettermann
Message:

Extend login procedure by copying passport pictures of transfer students after first-time login.

Location:
WAeUP_SRP/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/WAeUPTool.py

    r5564 r5655  
    653653    ###)
    654654
     655    security.declarePublic('loadTransferStudentFoto') ###(
     656    def loadTransferStudentFoto(self,student_old,student_new):
     657        "return a student passport picture"
     658        images_dir_new = getImagesDir(student_new)
     659        images_dir_old = getImagesDir(student_old)       
     660        if not os.path.exists(images_dir_new):
     661            os.mkdir(images_dir_new)               
     662        image_name_new = os.path.join(images_dir_new,"passport_%(student_new)s.jpg" % vars())
     663        image_name_old = os.path.join(images_dir_old,"passport_%(student_old)s" % vars())
     664        #import pdb;pdb.set_trace()
     665        for extension in ('.jpg','.JPG'):
     666            fullname = "%(image_name_old)s%(extension)s" % vars()
     667            if os.path.exists(fullname):
     668                copy2(fullname,image_name_new)
     669                return "successfully copied passport picture"
     670        return "passport picture not found: %s.jpg or .JPG" % image_name_old
     671    ###)
    655672
    656673    security.declareProtected(ModifyPortalContent,'createOne') ###(
  • WAeUP_SRP/trunk/skins/cps_custom/logged_in.py

    r5517 r5655  
    1919        pass
    2020import DateTime
     21import os
    2122current = DateTime.DateTime()
    2223import logging
     
    3637is_anon = mtool.isAnonymousUser()
    3738member = mtool.getAuthenticatedMember()
     39member_id = str(member)
    3840
    3941if context.isStaff():
    40     is_unsecure = context.waeup_tool.checkGenericPassword(str(member))
     42    is_unsecure = context.waeup_tool.checkGenericPassword(member_id)
    4143    if is_unsecure:
    4244        response.expireCookie('__ac', path='/')
     
    4749if not is_anon:
    4850    if "Student" in member.getRoles():
    49         to_waeup_student_home = True
    5051        students = context.portal_url.getPortalObject().campus.students
    51         student = getattr(students,str(member))
     52        student = getattr(students,member_id)
    5253        student_app = getattr(student,'application',None)
    5354        student_per = getattr(student,'personal',None)
     55     
    5456
    5557        #########################################################
     
    6163            email=request.get("email")
    6264            phone=request.get("phone_nr")
    63             context.waeup_tool.makeStudentData(str(member),
     65            context.waeup_tool.makeStudentData(member_id,
    6466                                                   email=email,
    6567                                                   phone_nr=phone,
    6668                                                   )
    6769            #d = {}
    68             #d['id'] = str(member)
     70            #d['id'] = member_id
    6971            #d['email'] = email
    7072            #d['phone'] = phone
    7173            #context.students_catalog.modifyRecord(**d)
    7274        elif student_per is None:
    73             context.waeup_tool.makeStudentData(str(member))
    74 
    75         #########################################################
    76 
    77         student_app = getattr(student,'application',None)
     75            context.waeup_tool.makeStudentData(member_id)
    7876
    7977        #########################################################
     
    10199        else:
    102100            app_doc = student_app.getContent()
     101       
     102        res = context.students_catalog(id = member_id)
     103        matric_no = res[0].matric_no
     104        jamb_reg_no = res[0].jamb_reg_no
     105        entry_mode = res[0].entry_mode
     106        verdict = res[0].verdict
     107        level = res[0].level
     108        has_level = level
     109        has_verdict = verdict and not verdict == 'N/A'     
    103110
    104111        #########################################################
     
    124131        # look for passport pictures of returning students
    125132
    126         #if s_review_state == 'returning' and 'passport' not in app_doc.objectIds():
    127         # use new test
    128133        if s_review_state == 'returning' and\
    129            not context.waeup_tool.picturesExist(('passport',), student.getId()):
     134           not context.waeup_tool.picturesExist(('passport',), member_id):
    130135            folder = 'pictures_returning'
    131             res = context.students_catalog(id = str(member))
     136            #res = context.students_catalog(id = member_id)
    132137            filename = res[0].matric_no.upper()
    133138            msg = context.waeup_tool.loadStudentFoto(student,filename,folder)
    134139            logger.info('%s (%s), %s' % (member,s_review_state,msg))
    135140
    136 
    137         #########################################################
     141        #########################################################
     142       
     143        # look for passport pictures of transfer students
     144
     145        if entry_mode == 'transfer' and\
     146           s_review_state in ('returning','school_fee_paid',) and\
     147           not context.waeup_tool.picturesExist(('passport',), member_id):
     148            res_both = context.students_catalog(jamb_reg_no = jamb_reg_no)
     149            #set_trace()
     150            if len(res_both) == 2:
     151                for ts in res_both:
     152                    if ts.id != member_id:
     153                        msg = context.waeup_tool.loadTransferStudentFoto(ts.id,member_id)
     154                        logger.info('%s (%s on transfer), %s' % (member,s_review_state,msg))
     155
     156        #########################################################       
    138157
    139158        # look for passport pictures of new students
     
    144163                              'clearance_requested'
    145164                             )  and not context.waeup_tool.picturesExist(('passport',),
    146                                                                          student.getId()):
     165                                                                         member_id):
    147166            folder = 'pictures_admitted_latest'
    148167            filename = app_doc.jamb_reg_no.replace('/','_')
     
    220239            wftool.doActionFor(student_per,'open')
    221240
    222         #########################################################
    223 
    224         res = context.students_catalog(id = str(member))
    225         matric_no = res[0].matric_no
    226         verdict = res[0].verdict
    227         level = res[0].level
    228         has_level = level
    229         has_verdict = verdict and not verdict == 'N/A'
    230241
    231242        #########################################################
Note: See TracChangeset for help on using the changeset viewer.