Changeset 3458 for WAeUP_SRP


Ignore:
Timestamp:
21 Apr 2008, 16:31:47 (17 years ago)
Author:
joachim
Message:

trying to make a more clearer getMemberInfo,
do not use student.Title
basic function tested, not tested for student without data.

Location:
WAeUP_SRP/base/skins/waeup_student
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/skins/waeup_student/getMemberInfo.py

    r3456 r3458  
    2121member_id = str(member)
    2222path_info = request.get('PATH_INFO').split('/')
    23 if mtool.isAnonymousUser():
     23# if mtool.isAnonymousUser():
     24#     return None
     25# info = {}
     26# requested_id = context.getStudentId()
     27# if requested_id and not context.isStaff() and member_id != requested_id:
     28#     logger.info('%s tried to access personal object of %s' % (member_id,requested_id))
     29#     student_id = requested_id
     30#     return None
     31# elif context.isStaff():
     32#     student_id = requested_id
     33# else:
     34#     student_id = member_id
     35
     36info = context.waeup_tool.getAccessInfo(context)
     37student_id = info['student_id']
     38if student_id is None:
    2439    return None
    25 info = {}
    26 requested_id = context.getStudentId()
    27 if requested_id and not context.isStaff() and member_id != requested_id:
    28     logger.info('%s tried to access personal object of %s' % (member_id,requested_id))
    29     student_id = requested_id
    30     return None
    31 elif context.isStaff():
    32     student_id = requested_id
    33 else:
    34     student_id = member_id
    35 
    3640
    3741students_object = context.portal_url.getPortalObject().campus.students
    3842student = getattr(students_object, student_id)
    3943
    40 if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"):
    41     info['student'] = student
    42     info['id'] = student_id
    43     info['review_state'] = context.getStudentReviewState()
    44     info['per'] = getattr(student,'personal',None)
    45     info['app'] = student.application
    46     per_doc = info['per_doc'] = student.personal.getContent()
    47     info['app_doc'] = student.application.getContent()
    48     info['clear_doc'] = student.clearance.getContent()
    49     info['password'] = context.waeup_tool.getCredential(student_id)
    50     info['student_name'] = "%s %s %s" % (per_doc.firstname,per_doc.middlename,per_doc.lastname)
    51    
    52 #    if info['per_doc'].email:
    53 #        info['email'] = info['per_doc'].email
    54 #    else:
    55 #        info['email'] = info['app_doc'].app_email
    56 
    57     if info['app_doc'].app_email:
    58         info['email'] = info['app_doc'].app_email
    59     else:
    60         info['email'] = info['per_doc'].email
    61 
    62     msg="""
     44complete_msg="""
    6345Your SRP Member Details
    6446-----------------------
    6547
    66 Fullname: %s
    67 Student Id: %s
    68 Matriculation Number: %s
    69 Registration Number: %s
    70 Registration Status: %s
    71 Email Address in Application Data: %s
    72 Email Address in Personal Data: %s
    73 Date of Birth: %s
    74 Password: '%s'
     48Fullname: %(student_name)s
     49Student Id: %(id)s
     50Matriculation Number: %(matric_no)s
     51Registration Number: %(jamb_reg_no)s
     52Registration Status: %(review_state)s
     53Email Address in Application Data: %(app_email)s
     54Email Address in Personal Data: %(per_email)s
     55Date of Birth: %(birthday)s
     56Password: '%(password)s'
    7557
    7658"""
     59short_msg="""
     60Your SRP Member Details
     61-----------------------
    7762
    78     info['message'] = msg % (
    79         info['student_name'],
    80         student_id,                     
    81         info['clear_doc'].matric_no,
    82         info['app_doc'].jamb_reg_no,
    83         info['review_state'],
    84         info['app_doc'].app_email,
    85         info['per_doc'].email,
    86         info['clear_doc'].birthday,
    87         info['password']
    88         )
     63Fullname: %(student_name)s
     64Student Id: %(id)s
     65Password: %(password)s
     66
     67"""
     68student_record = context.students_catalog.getRecordByKey(student_id)
     69if hasattr(student,"application") and hasattr(student,"personal") and hasattr(student,"clearance"):
     70    #info['student'] = student
     71    info['id'] = student_id
     72    info['review_state'] = student_record.review_state
     73    #info['per'] = getattr(student,'personal',None)
     74    #per_doc = info['per_doc'] = student.personal.getContent()
     75    #info['app_doc'] = student.application.getContent()
     76    info['jamb_reg_no'] = student_record.jamb_reg_no
     77    #info['clear_doc'] = student.clearance.getContent()
     78    info['matric_no'] = student_record.matric_no
     79    info['password'] = context.waeup_tool.getCredential(student_id)
     80    info['student_name'] = student_record.name
     81    info['birthday'] = student.clearance.getContent().birthday
     82    app_email = info['app_email'] = student.application.getContent().app_email
     83    per_email = info['per_email'] = student_record.email
     84    if app_email:
     85        info['email'] = app_email
     86    else:
     87        info['email'] = per_email
     88    info['message'] = complete_msg % info
     89    info['with_email'] = bool(info['email'])
    8990else:
    90 
    91     info['student'] = student
     91    info['student_name'] = 'N/A'
    9292    info['id'] = student_id
    9393    info['review_state'] = wf.getInfoFor(student,'review_state',None)
    9494    info['password'] = context.waeup_tool.getCredential(student_id)
    9595    info['email'] = 'N/A'
    96 
    97     msg="""
    98 Your SRP Member Details
    99 -----------------------
    100 
    101 Fullname: %s
    102 Student Id: %s
    103 Password: %s
    104 
    105 """
    106 
    107     info['message'] = msg % (
    108         'N/A',
    109         student_id,
    110         info['password']
    111         )
    112 
    113 
    114 
    115 
    116 
     96    info['message'] = short_msg % info
     97    info['with_email'] = False
    11798return info
  • WAeUP_SRP/base/skins/waeup_student/mail_password_form.pt

    r2059 r3458  
    2727          </td>
    2828          <td>
    29              <span tal:condition="info/student/Title" tal:content="info/student/Title" />
    30              <span tal:condition="not:info/student/Title">N/A</span>
     29             <span tal:replace="info/student_name"></span>
    3130          </td>
    3231        </tr>
     
    6160          </td>
    6261        </tr>
    63         <tr tal:condition="python: info['email'] and info['email']!='N/A'">
     62        <tr tal:condition="info/with_email">
    6463          <td>&nbsp;</td>
    6564          <td><input name="Submit" type="submit" class="standalone" value="Submit" /><br /><br /></td>
    6665        </tr>
    6766
    68         <tr tal:condition="not:info/email">
     67        <tr tal:condition="not:info/with_email">
    6968          <td>&nbsp;</td>
    7069          <td><strong tal:condition="not:info/email">
Note: See TracChangeset for help on using the changeset viewer.