source: WAeUP_SRP/trunk/skins/waeup_student/apply_pume_manage.py @ 2156

Last change on this file since 2156 was 2156, checked in by joachim, 17 years ago

please test, works in principle

  • Property svn:keywords set to Id
File size: 2.1 KB
Line 
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"""
12search for  Pume Applications
13"""
14
15try:
16    from Products.zdb import set_trace
17except:
18    def set_trace():
19        pass
20
21import DateTime
22import logging
23logger = logging.getLogger('Skins.apply_pume_manage')
24mtool = context.portal_membership
25member = mtool.getAuthenticatedMember()
26
27current = DateTime.DateTime()
28pr = context.portal_registration
29request = REQUEST
30
31
32if 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)
37reset = "reset" in request.keys()
38lt = context.portal_layouts
39reg_no = request.form.get('reg_no','')
40if same_type(reg_no, []):
41    if reset:
42        reg_no = reg_no[0]
43    elif reg_no[1]:
44        reg_no = reg_no[1]
45res = ''
46psm = ''
47object = {}
48data = {}
49if 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))
55if 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
69return context.apply_pume_manage_form(rendered = res,
70                                      psm = psm,
71                                      reg_no = reg_no,
72                                     )
73
74
Note: See TracBrowser for help on using the repository browser.