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

Last change on this file since 2217 was 2170, checked in by Henrik Bettermann, 17 years ago

psm fixed

  • Property svn:keywords set to Id
File size: 3.7 KB
RevLine 
[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 2170 2007-08-30 06:20:15Z henrik $
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
[2158]32if 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)
[2169]38
39search = "search" in request.keys()
[2156]40reset = "reset" in request.keys()
[2168]41edit = "edit" in request.keys()
[2156]42lt = context.portal_layouts
[2157]43
[2160]44reg_no = request.get('reg_no','').upper()
45new_reg_no = request.get('new_reg_no','').upper()
[2157]46
[2168]47if reset or edit:
[2157]48    reg_no = reg_no
49elif new_reg_no:
50    reg_no = new_reg_no
51
[2156]52res = ''
53psm = ''
54object = {}
[2168]55ds = []
[2170]56found = False
[2168]57
[2169]58validate = not search
59
[2168]60if reg_no:
61    brains = context.applicants_catalog(reg_no = reg_no)
[2170]62
[2168]63    if len(brains) == 1:
[2170]64        found = True
[2168]65        for field in context.applicants_catalog.schema():
66            object[field] = getattr(brains[0],field,None)
67        res,psm,ds = lt.renderLayout(layout_id= 'application_manage',
68                                     schema_id= 'application',
69                                     layout_mode = "edit",
70                                     context=context,
[2169]71                                     mapping=validate and REQUEST,
[2168]72                                     ob=object,
73                                     commit = False,
74                                    )
[2170]75
76
77
[2168]78if psm == 'invalid':
79    return context.apply_pume_manage_form(rendered = res,
80                                   psm = "Please correct your input!",
81                                   #psm = "%s, %s" % (psm,ds),
82                                   ds = ds,
83                                  )
84elif psm == '':
[2170]85    if search and not found:
86        psm = 'Registration Number not found!'
[2168]87    return context.apply_pume_manage_form(rendered = res,
88                                   psm = psm,
89                                   ds = ds,
90                                  )
91elif psm == 'valid':
92    psm = ''
93    pass
[2170]94
[2156]95data = {}
[2168]96dm = ds.getDataModel()
97for field in context.applicants_catalog.schema():
98    if dm.has_key("%s" % field):
99        data[field] = dm.get(field)
100
101
[2156]102if reset and reg_no:
[2168]103    #data['reg_no'] = reg_no
[2157]104    psm = "You successfully reset the record! The applicant will be able to edit and resubmit the data."
[2161]105    data['status'] = "reset"
[2156]106    context.applicants_catalog.modifyRecord(**data)
107    logger.info('%s reset application record of %s' % (member,reg_no))
[2157]108
[2168]109if edit and reg_no:
110    #data['reg_no'] = reg_no
111    psm = "Content changed!"
112    context.applicants_catalog.modifyRecord(**data)
113    logger.info('%s edited application record of %s' % (member,reg_no))
114
[2158]115
[2170]116for field in context.applicants_catalog.schema():
117    object[field] = getattr(brains[0],field,None)
[2168]118
[2170]119res,psm_dummy,ds = lt.renderLayout(layout_id= 'application_manage',
120                             schema_id= 'application',
121                             layout_mode = "edit",
122                             context=context,
123                             ob=object,
124                             commit = False,
125                            )
126   
[2158]127
[2156]128return context.apply_pume_manage_form(rendered = res,
129                                      psm = psm,
130                                      reg_no = reg_no,
[2157]131                                      ds = ds
[2156]132                                     )
133
134
Note: See TracBrowser for help on using the repository browser.