Changeset 6296


Ignore:
Timestamp:
7 Jun 2011, 12:16:27 (13 years ago)
Author:
Henrik Bettermann
Message:

Move workflow methods from certificates to applicants.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
5 edited

Legend:

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

    r6198 r6296  
    2525from zope.interface import implementedBy
    2626from zope.schema.fieldproperty import FieldProperty
     27from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2728from waeup.sirp.interfaces import IWAeUPSIRPPluggable
    2829from waeup.sirp.app import University
     
    4344    grok.implements(IApplicant,IApplicantEdit)
    4445    grok.provides(IApplicant)
     46
     47    def __init__(self):
     48        super(Applicant, self).__init__()
     49        #Initialize workflow state...
     50        self.setApplicationState('initialized')
     51
     52    def getApplicationState(self):
     53        return IWorkflowState(self).getState()
     54
     55    def setApplicationState(self, state=None):
     56        """Try to set new state.
     57
     58        Instead of simply setting a value, we fire a transition of a
     59        workflow. This might fail if, for instance, the required state
     60        is not part of the workflow or unreachable from current state.
     61        """
     62        if state == self.getApplicationState():
     63            # Accept staying in the same state, even if workflow does
     64            # not allow this.
     65            return
     66        info = IWorkflowInfo(self)
     67        info.fireTransitionToward(state)
     68        return
     69
     70    #application_state = property(getApplicationState, setApplicationState)
    4571
    4672# Set all attributes of Applicant required in IApplicant as field
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r6290 r6296  
    291291        #readonly = True,
    292292        )
     293
    293294    reg_no = schema.TextLine(
    294295        title = u'JAMB Registration Number',
     
    366367        readonly = True,
    367368        )
    368     status = schema.TextLine(
    369         # XXX: should be 'status' type
    370         title = u'Application Status',
    371         required = False,
    372         readonly = True,
    373         )
     369
     370    #application_state = schema.Choice(
     371    #    title = u'Application Status',
     372    #    default = 'created',
     373    #    values = ['unchecked', 'checked']
     374    #    readonly = True,
     375    #    )
     376
    374377    screening_score = schema.Int(
    375378        title = u'Screening Score',
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/browser.txt

    r6247 r6296  
    853853
    854854  >>> open('certificates.csv', 'wb').write(
    855   ... """code,title,faculty_code,department_code,study_mode,end_level,m_prefix,start_level,application_category,review_state
    856   ... LBA,BACHELOR OF LITERATURE,FA,LIT,UG,ug_ft,500,LIT,100,basic,checked
    857   ... LMA,MASTER OF LITERATURE,FA,LIT,UG,ug_pt,500,LIT,100,cest,checked
    858   ... DME,DIPLOMA OF MATH,FS,MAT,DP,dp_ft,200,DME,100,cest,unchecked
     855  ... """code,title,faculty_code,department_code,study_mode,end_level,m_prefix,start_level,application_category
     856  ... LBA,BACHELOR OF LITERATURE,FA,LIT,UG,ug_ft,500,LIT,100,basic
     857  ... LMA,MASTER OF LITERATURE,FA,LIT,UG,ug_pt,500,LIT,100,cest
     858  ... DME,DIPLOMA OF MATH,FS,MAT,DP,dp_ft,200,DME,100,cest
    859859  ... """)
    860860
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py

    r6008 r6296  
    22"""
    33import grok
    4 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    5 try:
    6     from zope.catalog.interfaces import ICatalog
    7 except ImportError:
    8     # BBB
    9     from zope.app.catalog.interfaces import ICatalog
     4from zope.catalog.interfaces import ICatalog
    105from zope.component import getUtility
    116from zope.component.interfaces import IFactory, ComponentLookupError
     
    3025        self.end_level = end_level
    3126        self.application_category = application_category
    32         # Initialize workflow state...
    33         # self.setReviewState('unchecked')
    3427
    35     #def check(self):
    36     #    """Set Review State to ``checked``.
    37     #    """
    38     #    self.setReviewState(state='checked')
    39 
    40     #def getReviewState(self):
    41     #    return IWorkflowState(self).getState()
    42 
    43     #def setReviewState(self, state=None):
    44     #    """Try to set new state.
    45 
    46     #    Instead of simply setting a value, we fire a transition of a
    47     #    workflow. This might fail if, for instance, the required state
    48     #    is not part of the workflow or unreachable from current state.
    49     #    """
    50     #    if state == self.getReviewState():
    51     #        # Accept staying in the same state, even if workflow does
    52     #        # not allow this.
    53     #        return
    54     #    info = IWorkflowInfo(self)
    55     #    info.fireTransitionToward(state)
    56     #    return
    57 
    58     #review_state = property(getReviewState, setReviewState)
    59    
    6028    def longtitle(self):
    6129        return "%s (%s)" % (self.title,self.code) 
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r6189 r6296  
    184184        )
    185185
    186     #review_state = schema.Choice(
    187     #    title = u'Review State',
    188     #    default = 'unchecked',
    189     #    values = ['unchecked', 'checked']
    190     #    )
    191 
    192186    title = schema.TextLine(
    193187        title = u'Title',
Note: See TracChangeset for help on using the changeset viewer.