Ignore:
Timestamp:
16 Jun 2011, 09:53:26 (13 years ago)
Author:
uli
Message:

Reenable application start workflow on login.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6375 r6377  
    421421            # Don't care if user is already authenticated as non-applicant
    422422            return
     423
     424        # From here we handle an applicant (not an officer browsing)
    423425        pin = self.request.principal.access_code
    424426
     
    426428        invalidate_accesscode(pin)
    427429
    428         if pin in self.context.keys():
    429             self.redirect(self.url(self.context[pin], 'edit'))
    430             return
    431 
    432         # Create applicant record
    433         applicant = Applicant()
    434         applicant.access_code = pin
    435         self.context[pin] = applicant
    436 
    437         # Assign current principal the owner role on created applicant
    438         # record
     430        if not pin in self.context.keys():
     431            # Create applicant record
     432            applicant = Applicant()
     433            applicant.access_code = pin
     434            self.context[pin] = applicant
     435
    439436        role_manager = IPrincipalRoleManager(self.context[pin])
    440         role_manager.assignRoleToPrincipal(
    441             'waeup.local.ApplicationOwner', self.request.principal.id)
    442         # Assign current principal the PortalUser role
    443         role_manager = IPrincipalRoleManager(grok.getSite()['faculties'])
    444         role_manager.assignRoleToPrincipal(
    445             'waeup.PortalUser', self.request.principal.id)
     437        roles = role_manager.getRolesForPrincipal(self.request.principal.id)
     438        if not 'waeup.local.ApplicationOwner' in map(lambda x, y: x, roles):
     439            # Assign current principal the owner role on created applicant
     440            # record
     441            role_manager.assignRoleToPrincipal(
     442                'waeup.local.ApplicationOwner', self.request.principal.id)
     443
     444            # Assign current principal the PortalUser role
     445            role_manager = IPrincipalRoleManager(grok.getSite()['faculties'])
     446            role_manager.assignRoleToPrincipal(
     447                'waeup.PortalUser', self.request.principal.id)
     448
     449        # Mark application as started
     450        if IWorkflowState(self.context[pin]).getState() is INITIALIZED:
     451            IWorkflowInfo(self.context[pin]).fireTransition('start')
     452
    446453        self.redirect(self.url(self.context[pin], 'edit'))
    447454        return
Note: See TracChangeset for help on using the changeset viewer.