- Timestamp:
- 3 Apr 2008, 12:26:10 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/skins/waeup_student/apply_admission.py
r3410 r3411 104 104 if apply_admission or edit or manage: 105 105 mode = "edit" 106 elif slip: 107 mode = "view_slip" 106 108 else: 107 109 mode = "create" … … 114 116 115 117 lt = context.portal_layouts 116 118 object = {} 117 119 pin = request.form.get('pin','') 118 120 # reg_no = request.get('widget__reg_no','').upper() 119 121 # if not reg_no: 120 122 # reg_no = request.form.get('reg_no','').upper() 121 reg_no = request.form.get('reg_no','').upper() 122 # if not reg_no: 123 # reg_no = request.get('widget__pin_n','').upper() 124 object = {} 125 if reg_no: 126 brains = context.applicants_catalog(reg_no = reg_no) 127 if len(brains) == 1: 128 for field in context.applicants_catalog.schema(): 129 object[field] = getattr(brains[0],field,None) 130 if not object['passport']: 131 object['passport'] = '' 132 if object['status'] and ('submitted' in object['status'] or 'admitted' in object['status'] or 'created' in object['status']): 133 submitted = True 134 135 if not (create or slip) and (pin != object['pin'] and not context.isSectionOfficer()): 136 logger.info('%s/%s entered wrong pin %s' % (member,reg_no,pin)) 137 return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 138 139 # For the next application session it should be reverted to 140 # (see comment 09/06/07 16:40:52 in ticket #328): 141 142 #if not create and (pin != object['pin'] and not context.isSectionOfficer()): 143 #logger.info('%s/%s entered wrong pin %s' % (member,reg_no,pin)) 144 #return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 123 124 125 screening_type = 'pume' 126 if traverse_subpath and traverse_subpath[0] in screening_types: 127 screening_type = traverse_subpath[0] 128 layout = "application_%s" % screening_type 145 129 info = {} 146 info['status'] = object.get('status','')147 if traverse_subpath and traverse_subpath[0] in screening_types:148 screening_type = info['screening_type'] = traverse_subpath[0]149 elif manage:150 if object['screening_type']:151 st = object['screening_type']152 else:153 st = 'pume'154 screening_type = info['screening_type'] = st155 156 for co_name,co_dict in configuration:157 info[co_name] = co_dict[screening_type]158 layout = "application_%s" % screening_type159 130 without_reg_no = screening_type in ('prence','cest','sandwich') 160 131 info['expired'] = current.greaterThan(deaddates[screening_type]) 161 132 info['expiration_date'] = deaddates[screening_type] 162 163 164 if slip: 165 mode = "view_slip" 166 logger.info('%s/%s views application slip' % (member,reg_no)) 167 168 res,psm,ds = lt.renderLayout(layout_id= layout, 169 schema_id= 'import_application', 170 layout_mode = mode, 171 context=context, 172 mapping=validate and REQUEST, 173 ob=object, 174 commit = False, 175 ) 176 if slip: 177 return context.apply_admission_slip(rendered = res, 178 psm = "", 179 mode = mode, 180 ds = ds, 181 info = info, 182 ) 183 if psm == 'invalid': 184 return context.apply_admission_form(rendered = res, 185 psm = "Please correct your input!", 186 mode = mode, 187 ds = ds, 188 info = info, 189 ) 190 info['reg_no'] = ds.get('reg_no') 191 info['pin'] = ds.get('pin') 192 if psm == '' and not manage: 193 return context.apply_admission_form(rendered = res, 194 psm = psm, 195 ds = ds, 196 mode = mode, 197 info = info, 198 ) 199 # elif psm == 'valid' or (psm == '' and manage): 200 # pass 201 if without_reg_no: 202 reg_no = ds.get('reg_no') 133 info['status'] = object.get('status','') 134 #set_trace() 135 # the reg_no is a hidden field in the form 136 reg_no = request.form.get('reg_no','').upper() 137 if not reg_no: 138 # validate form if no reg_no specified 139 res,psm,ds = lt.renderLayout(layout_id= layout, 140 schema_id= 'import_application', 141 layout_mode = mode, 142 context=context, 143 mapping=validate and REQUEST, 144 ob={}, 145 commit = False, 146 ) 147 if psm == 'invalid': 148 return context.apply_admission_form(rendered = res, 149 psm = "Please correct your input!", 150 mode = mode, 151 ds = ds, 152 info = info, 153 ) 154 elif psm == '': 155 return context.apply_admission_form(rendered = res, 156 psm = psm, 157 ds = ds, 158 mode = mode, 159 info = info, 160 ) 161 if without_reg_no: 162 reg_no = ds.get('pin_n','').upper() 163 else: 164 reg_no = ds.get('reg_no') 165 info['reg_no'] = reg_no 166 brains = context.applicants_catalog(reg_no = reg_no) 167 if len(brains) == 1: 168 for field in context.applicants_catalog.schema(): 169 object[field] = getattr(brains[0],field,None) 170 screening_type = info['screening_type'] = object['screening_type'] 171 for co_name,co_dict in configuration: 172 info[co_name] = co_dict[screening_type] 173 if not object['passport']: 174 object['passport'] = '' 175 if object['status'] and ('submitted' in object['status'] or 'admitted' in object['status'] or 'created' in object['status']): 176 submitted = True 177 178 if not (create or slip) and (pin != object['pin'] and not context.isSectionOfficer()): 179 logger.info('%s/%s entered wrong pin %s' % (member,reg_no,pin)) 180 return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 181 182 #rerender with current object = application-record 183 res,psm,ds = lt.renderLayout(layout_id= layout, 184 schema_id= 'import_application', 185 layout_mode = mode, 186 context=context, 187 mapping=validate and REQUEST, 188 ob=object, 189 commit = False, 190 ) 191 # For the next application session it should be reverted to 192 # (see comment 09/06/07 16:40:52 in ticket #328): 193 194 #if not create and (pin != object['pin'] and not context.isSectionOfficer()): 195 #logger.info('%s/%s entered wrong pin %s' % (member,reg_no,pin)) 196 #return request.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 197 info['status'] = object.get('status','') 198 203 199 data = {} 204 200 dm = ds.getDataModel() … … 207 203 data[field] = dm.get(field) 208 204 data['reg_no'] = reg_no 209 if apply_admission: 205 if manage: 206 if submitted: 207 mode = "view" 208 psm = "You are now assuming the applicant's role!" 209 logger.info('%s/%s entered application record' % (member,reg_no)) 210 # res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout, 211 # schema_id= 'import_application', 212 # layout_mode = mode, 213 # context=context, 214 # mapping={}, 215 # ob=object, 216 # commit = False, 217 # ) 218 else: 219 mode = "edit" 220 psm = "You are now assuming the applicant's role!" 221 logger.info('%s/%s entered application record' % (member,reg_no)) 222 elif apply_admission: 210 223 if submitted: 211 224 mode = "view" 212 225 psm = "The form has already been submitted and you are not allowed to resubmit the data!" 213 226 logger.info('%s/%s tried to resubmit application record' % (member,reg_no)) 214 res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,215 schema_id= 'import_application',216 layout_mode = mode,217 context=context,218 mapping={},219 ob=object,220 commit = False,221 )227 # res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout, 228 # schema_id= 'import_application', 229 # layout_mode = mode, 230 # context=context, 231 # mapping={}, 232 # ob=object, 233 # commit = False, 234 # ) 222 235 elif not request.has_key('confirm'): 223 236 mode = "edit" … … 236 249 object['status'] = data['status'] 237 250 context.applicants_catalog.modifyRecord(**data) 238 251 # rerendering neccessary since object changed 239 252 res,psm_dummy,ds = lt.renderLayout(layout_id= layout, 240 253 schema_id= 'import_application', … … 256 269 object['reg_no'] = reg_no 257 270 object['pin'] = str(ds.get('pin')) 271 # rerendering neccessary since object changed 258 272 res,psm,ds_dummy = lt.renderLayout(layout_id= layout, 259 273 schema_id= 'import_application', … … 265 279 ) 266 280 elif edit: 267 #set_trace()268 281 if submitted: 269 282 mode = "view" 270 283 psm = "The form has already been submitted and you are not allowed to modify the data!" 271 284 logger.info('%s/%s tried to edit submitted application record' % (member,reg_no)) 272 res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,273 schema_id= 'import_application',274 layout_mode = mode,275 context=context,276 mapping={},277 ob=object,278 commit = False,279 )285 # res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout, 286 # schema_id= 'import_application', 287 # layout_mode = mode, 288 # context=context, 289 # mapping={}, 290 # ob=object, 291 # commit = False, 292 # ) 280 293 else: 281 294 mode = "edit" … … 285 298 context.applicants_catalog.modifyRecord(**data) 286 299 logger.info('%s/%s modified application record' % (member,reg_no)) 287 288 elif manage:289 if submitted:290 mode = "view"291 psm = "You are now assuming the applicant's role!"292 logger.info('%s/%s entered application record' % (member,reg_no))293 res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,294 schema_id= 'import_application',295 layout_mode = mode,296 context=context,297 mapping={},298 ob=object,299 commit = False,300 )301 else:302 mode = "edit"303 psm = "You are now assuming the applicant's role!"304 logger.info('%s/%s entered application record' % (member,reg_no))305 306 300 307 301 try:
Note: See TracChangeset for help on using the changeset viewer.