1 | ## Script (Python) "apply_pume_manage" |
---|
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 | |
---|
32 | if not context.isSectionOfficer(): |
---|
33 | return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.absolete_url()) |
---|
34 | |
---|
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 |
---|
40 | |
---|
41 | reg_no = request.get('reg_no','').upper() |
---|
42 | new_reg_no = request.get('new_reg_no','').upper() |
---|
43 | |
---|
44 | if reset: |
---|
45 | reg_no = reg_no |
---|
46 | elif new_reg_no: |
---|
47 | reg_no = new_reg_no |
---|
48 | |
---|
49 | res = '' |
---|
50 | psm = '' |
---|
51 | object = {} |
---|
52 | data = {} |
---|
53 | if reset and reg_no: |
---|
54 | data['reg_no'] = reg_no |
---|
55 | psm = "You successfully reset the record! The applicant will be able to edit and resubmit the data." |
---|
56 | data['status'] = "reset" |
---|
57 | context.applicants_catalog.modifyRecord(**data) |
---|
58 | logger.info('%s reset application record of %s' % (member,reg_no)) |
---|
59 | |
---|
60 | #set_trace() |
---|
61 | |
---|
62 | ds = [] |
---|
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) |
---|
68 | res,psm_dummy,ds = lt.renderLayout(layout_id= 'application', |
---|
69 | schema_id= 'application', |
---|
70 | layout_mode = "view_slip", |
---|
71 | context=context, |
---|
72 | ob=object, |
---|
73 | commit = False, |
---|
74 | ) |
---|
75 | else: |
---|
76 | psm = "reg no %s not found" % reg_no |
---|
77 | |
---|
78 | return context.apply_pume_manage_form(rendered = res, |
---|
79 | psm = psm, |
---|
80 | reg_no = reg_no, |
---|
81 | ds = ds |
---|
82 | ) |
---|
83 | |
---|
84 | |
---|