[2156] | 1 | ## Script (Python) "apply_pume" |
---|
| 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 2156 2007-08-23 17:40:45Z joachim $ |
---|
| 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 | |
---|
| 32 | if not context.isStaff(): |
---|
| 33 | return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.absolete_url()) |
---|
| 34 | #type_name = 'StudentApplication' |
---|
| 35 | #ti = context.portal_types[type_name] |
---|
| 36 | #REQUEST.set('type_name',type_name) |
---|
| 37 | reset = "reset" in request.keys() |
---|
| 38 | lt = context.portal_layouts |
---|
| 39 | reg_no = request.form.get('reg_no','') |
---|
| 40 | if same_type(reg_no, []): |
---|
| 41 | if reset: |
---|
| 42 | reg_no = reg_no[0] |
---|
| 43 | elif reg_no[1]: |
---|
| 44 | reg_no = reg_no[1] |
---|
| 45 | res = '' |
---|
| 46 | psm = '' |
---|
| 47 | object = {} |
---|
| 48 | data = {} |
---|
| 49 | if reset and reg_no: |
---|
| 50 | data['reg_no'] = reg_no |
---|
| 51 | psm = "You successfully reset!" |
---|
| 52 | data['status'] = "edited" |
---|
| 53 | context.applicants_catalog.modifyRecord(**data) |
---|
| 54 | logger.info('%s reset application record of %s' % (member,reg_no)) |
---|
| 55 | if reg_no: |
---|
| 56 | brains = context.applicants_catalog(reg_no = reg_no) |
---|
| 57 | if len(brains) == 1: |
---|
| 58 | for field in context.applicants_catalog.schema(): |
---|
| 59 | object[field] = getattr(brains[0],field,None) |
---|
| 60 | res,psm,ds = lt.renderLayout(layout_id= 'application', |
---|
| 61 | schema_id= 'application', |
---|
| 62 | layout_mode = "view", |
---|
| 63 | context=context, |
---|
| 64 | ob=object, |
---|
| 65 | commit = False, |
---|
| 66 | ) |
---|
| 67 | else: |
---|
| 68 | psm = "reg no %s not found" % reg_no |
---|
| 69 | return context.apply_pume_manage_form(rendered = res, |
---|
| 70 | psm = psm, |
---|
| 71 | reg_no = reg_no, |
---|
| 72 | ) |
---|
| 73 | |
---|
| 74 | |
---|