[2160] | 1 | ## Script (Python) "apply_pume_manage" |
---|
[2156] | 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=REQUEST |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: apply_pume_manage.py 2161 2007-08-24 14:23:50Z henrik $ |
---|
| 11 | """ |
---|
| 12 | search for Pume Applications |
---|
| 13 | """ |
---|
| 14 | |
---|
| 15 | try: |
---|
| 16 | from Products.zdb import set_trace |
---|
| 17 | except: |
---|
| 18 | def set_trace(): |
---|
| 19 | pass |
---|
| 20 | |
---|
| 21 | import DateTime |
---|
| 22 | import logging |
---|
| 23 | logger = logging.getLogger('Skins.apply_pume_manage') |
---|
| 24 | mtool = context.portal_membership |
---|
| 25 | member = mtool.getAuthenticatedMember() |
---|
| 26 | |
---|
| 27 | current = DateTime.DateTime() |
---|
| 28 | pr = context.portal_registration |
---|
| 29 | request = REQUEST |
---|
| 30 | |
---|
| 31 | |
---|
[2158] | 32 | if not context.isSectionOfficer(): |
---|
[2156] | 33 | return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.absolete_url()) |
---|
[2158] | 34 | |
---|
[2156] | 35 | #type_name = 'StudentApplication' |
---|
| 36 | #ti = context.portal_types[type_name] |
---|
| 37 | #REQUEST.set('type_name',type_name) |
---|
| 38 | reset = "reset" in request.keys() |
---|
| 39 | lt = context.portal_layouts |
---|
[2157] | 40 | |
---|
[2160] | 41 | reg_no = request.get('reg_no','').upper() |
---|
| 42 | new_reg_no = request.get('new_reg_no','').upper() |
---|
[2157] | 43 | |
---|
| 44 | if reset: |
---|
| 45 | reg_no = reg_no |
---|
| 46 | elif new_reg_no: |
---|
| 47 | reg_no = new_reg_no |
---|
| 48 | |
---|
[2156] | 49 | res = '' |
---|
| 50 | psm = '' |
---|
| 51 | object = {} |
---|
| 52 | data = {} |
---|
| 53 | if reset and reg_no: |
---|
| 54 | data['reg_no'] = reg_no |
---|
[2157] | 55 | psm = "You successfully reset the record! The applicant will be able to edit and resubmit the data." |
---|
[2161] | 56 | data['status'] = "reset" |
---|
[2156] | 57 | context.applicants_catalog.modifyRecord(**data) |
---|
| 58 | logger.info('%s reset application record of %s' % (member,reg_no)) |
---|
[2157] | 59 | |
---|
[2158] | 60 | #set_trace() |
---|
| 61 | |
---|
| 62 | ds = [] |
---|
[2156] | 63 | if reg_no: |
---|
| 64 | brains = context.applicants_catalog(reg_no = reg_no) |
---|
| 65 | if len(brains) == 1: |
---|
| 66 | for field in context.applicants_catalog.schema(): |
---|
| 67 | object[field] = getattr(brains[0],field,None) |
---|
[2157] | 68 | res,psm_dummy,ds = lt.renderLayout(layout_id= 'application', |
---|
[2156] | 69 | schema_id= 'application', |
---|
[2157] | 70 | layout_mode = "view_slip", |
---|
[2156] | 71 | context=context, |
---|
| 72 | ob=object, |
---|
| 73 | commit = False, |
---|
| 74 | ) |
---|
| 75 | else: |
---|
| 76 | psm = "reg no %s not found" % reg_no |
---|
[2158] | 77 | |
---|
[2156] | 78 | return context.apply_pume_manage_form(rendered = res, |
---|
| 79 | psm = psm, |
---|
| 80 | reg_no = reg_no, |
---|
[2157] | 81 | ds = ds |
---|
[2156] | 82 | ) |
---|
| 83 | |
---|
| 84 | |
---|