Changeset 7249 for main/waeup.sirp/trunk/src/waeup/sirp/applicants
- Timestamp:
- 1 Dec 2011, 15:41:31 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r7247 r7249 405 405 def delLocalRoles(self, **data): 406 406 return del_local_roles(self,3,**data) 407 408 # Not used anymore409 class ApplicantLoginPage(WAeUPPage):410 grok.context(IApplicantsContainer)411 grok.name('login')412 grok.require('waeup.Public')413 414 @property415 def title(self):416 return u"Applicant Login: %s" % self.context.title417 418 @property419 def label(self):420 return u"Login for '%s' applicants only" % self.context.title421 422 pnav = 3423 424 @property425 def ac_prefix(self):426 return self.context.ac_prefix427 428 def update(self, SUBMIT=None):429 self.ac_series = self.request.form.get('form.ac_series', None)430 self.ac_number = self.request.form.get('form.ac_number', None)431 if SUBMIT is None:432 return433 if self.request.principal.id == 'zope.anybody':434 self.flash('Entered credentials are invalid.')435 return436 # if not IApplicantPrincipal.providedBy(self.request.principal):437 # # Don't care if user is already authenticated as non-applicant438 return439 440 # From here we handle an applicant (not an officer browsing)441 pin = self.request.principal.access_code442 443 # If application has not yet started,444 # logout without marking AC as used445 if not self.context.startdate or self.context.startdate > date.today():446 self.flash('Application has not yet started.')447 auth = getUtility(IAuthentication)448 ILogout(auth).logout(self.request)449 self.redirect(self.url(self.context, 'login'))450 return451 452 # If application has ended and applicant record doesn't exist,453 # logout without marking AC as used454 if not pin in self.context.keys() and (not self.context.enddate or455 self.context.enddate < date.today()):456 self.flash('Application has ended.')457 auth = getUtility(IAuthentication)458 ILogout(auth).logout(self.request)459 self.redirect(self.url(self.context, 'login'))460 return461 462 # Mark AC as used (this also fires a pin related transition)463 if get_access_code(pin).state != USED:464 comment = u"AC invalidated"465 # Here we know that the ac is in state initialized so we do not466 # expect an exception467 invalidate_accesscode(pin,comment)468 469 if not pin in self.context.keys():470 # Create applicant record471 applicant = Applicant()472 applicant.access_code = pin473 self.context[pin] = applicant474 475 role_manager = IPrincipalRoleManager(self.context[pin])476 role_manager.assignRoleToPrincipal(477 'waeup.local.ApplicationOwner', self.request.principal.id)478 479 # Assign current principal the global Applicant role480 role_manager = IPrincipalRoleManager(grok.getSite())481 role_manager.assignRoleToPrincipal(482 'waeup.Applicant', self.request.principal.id)483 484 # Mark application as started485 #if IWorkflowState(self.context[pin]).getState() is INITIALIZED:486 # IWorkflowInfo(self.context[pin]).fireTransition('start')487 488 self.redirect(self.url(self.context[pin], 'edit'))489 return490 491 def render(self):492 return493 407 494 408 class ApplicantAddFormPage(WAeUPAddFormPage):
Note: See TracChangeset for help on using the changeset viewer.