Changeset 5949 for main/waeup.sirp/trunk


Ignore:
Timestamp:
15 Apr 2011, 06:03:44 (14 years ago)
Author:
Henrik Bettermann
Message:

The implementation of a workflow for certificates is an interesting case study and should thus be kept in the source code as comment. We don't need a workflow in the academics section.

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

Legend:

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

    r5948 r5949  
    11001100    def addCertificate(self, **data):
    11011101        certificate = createObject(u'waeup.Certificate')
    1102         try:
    1103             self.applyData(certificate, **data)
    1104         except NoTransitionAvailableError:
    1105             self.status = Invalid('Review state cannot be changed to '
    1106                                   'requested state: no such transition '
    1107                                   'available in workflow.')
    1108             return
     1102        self.applyData(certificate, **data)
     1103       
     1104        #try:
     1105        #    self.applyData(certificate, **data)
     1106        #except NoTransitionAvailableError:
     1107        #    self.status = Invalid('Review state cannot be changed to '
     1108        #                          'requested state: no such transition '
     1109        #                          'available in workflow.')
     1110        #    return
     1111       
    11091112        try:
    11101113            self.context.certificates.addCertificate(certificate)
     
    12441247    @grok.action('Save')
    12451248    def save(self, **data):
    1246         try:
    1247             self.applyData(self.context, **data)
    1248         except NoTransitionAvailableError:
    1249             self.status = Invalid('Review state cannot be changed to '
    1250                                   'requested state: no such transition '
    1251                                   'available in workflow.')
    1252         return
     1249        self.applyData(self.context, **data)
     1250       
     1251        #try:
     1252        #    self.applyData(self.context, **data)
     1253        #except NoTransitionAvailableError:
     1254        #    self.status = Invalid('Review state cannot be changed to '
     1255        #                          'requested state: no such transition '
     1256        #                          'available in workflow.')
     1257        #return
    12531258   
    12541259    @grok.action('Save and return')
    12551260    def saveAndReturn(self, **data):
    1256         try:
    1257             self.applyData(self.context, **data)
    1258         except NoTransitionAvailableError:
    1259             self.status = Invalid('Review state cannot be changed to '
    1260                                   'requested state: no such transition '
    1261                                   'available in workflow.')
    1262             return
     1261        self.applyData(self.context, **data)
     1262       
     1263        #try:
     1264        #    self.applyData(self.context, **data)
     1265        #except NoTransitionAvailableError:
     1266        #    self.status = Invalid('Review state cannot be changed to '
     1267        #                          'requested state: no such transition '
     1268        #                          'available in workflow.')
     1269        #    return
     1270       
    12631271        self.redirect(self.url(self.context))
    12641272        return
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py

    r5947 r5949  
    3030        self.application_category = application_category
    3131        # Initialize workflow state...
    32         self.setReviewState('unchecked')
     32        # self.setReviewState('unchecked')
    3333
    34     def check(self):
    35         """Set Review State to ``checked``.
    36         """
    37         self.setReviewState(state='checked')
     34    #def check(self):
     35    #    """Set Review State to ``checked``.
     36    #    """
     37    #    self.setReviewState(state='checked')
    3838
    39     def getReviewState(self):
    40         return IWorkflowState(self).getState()
     39    #def getReviewState(self):
     40    #    return IWorkflowState(self).getState()
    4141
    42     def setReviewState(self, state=None):
    43         """Try to set new state.
     42    #def setReviewState(self, state=None):
     43    #    """Try to set new state.
    4444
    45         Instead of simply setting a value, we fire a transition of a
    46         workflow. This might fail if, for instance, the required state
    47         is not part of the workflow or unreachable from current state.
    48         """
    49         if state == self.getReviewState():
    50             # Accept staying in the same state, even if workflow does
    51             # not allow this.
    52             return
    53         info = IWorkflowInfo(self)
    54         info.fireTransitionToward(state)
    55         return
     45    #    Instead of simply setting a value, we fire a transition of a
     46    #    workflow. This might fail if, for instance, the required state
     47    #    is not part of the workflow or unreachable from current state.
     48    #    """
     49    #    if state == self.getReviewState():
     50    #        # Accept staying in the same state, even if workflow does
     51    #        # not allow this.
     52    #        return
     53    #    info = IWorkflowInfo(self)
     54    #    info.fireTransitionToward(state)
     55    #    return
    5656
    57     review_state = property(getReviewState, setReviewState)
     57    #review_state = property(getReviewState, setReviewState)
    5858   
    5959    def addCourseRef(self, course, level=100, core_or_elective=True):
  • main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.txt

    r5947 r5949  
    5858        u'NA'
    5959
    60    .. attribute:: review_state
    61 
    62       The review state can have one of the ``checking`` states defined
    63       in the WAeUP workflow. These are at least the states ``checked``
    64       and ``unchecked``. After a certificate is created, the review
    65       state is ``unchecked``:
    66 
    67         >>> mycertificate.review_state
    68         'unchecked'
    69 
    70       .. seealso::
    71          :meth:`Certificate.check` -- mark a certificate as ``checked``
    72 
    7360
    7461   .. attribute:: study_mode
     
    10895
    10996      .. XXX: This is not a proper description
    110 
    111    
    112    .. method:: check()
    113 
    114       Mark a certificate instance's review state as ``checked``:
    115 
    116         >>> mycertificate.review_state
    117         'unchecked'
    118 
    119         >>> mycertificate.check()
    120         >>> mycertificate.review_state
    121         'checked'
    122 
    123       We cannot uncheck a certificate:
    124 
    125         >>> mycertificate.review_state = 'unchecked'
    126         Traceback (most recent call last):
    127         ...
    128         NoTransitionAvailableError
    129 
    130       The only states accepted at all are ``checked`` and
    131       ``unchecked``. If we want to set something else this won't work:
    132 
    133         >>> mycertificate.review_state = 'nonsense'
    134         Traceback (most recent call last):
    135         ...
    136         NoTransitionAvailableError
    137 
    13897
    13998   .. method:: addCourseRef(course[, level=100,[ core_or_elective=True]])
  • main/waeup.sirp/trunk/src/waeup/sirp/university/interfaces.py

    r5948 r5949  
    144144        )
    145145
    146     review_state = schema.Choice(
    147         title = u'Review State',
    148         default = 'unchecked',
    149         values = ['unchecked', 'checked']
    150         )
     146    #review_state = schema.Choice(
     147    #    title = u'Review State',
     148    #    default = 'unchecked',
     149    #    values = ['unchecked', 'checked']
     150    #    )
    151151
    152152    title = schema.TextLine(
     
    171171   
    172172    application_category = schema.TextLine(
    173         title = u'aApplication Category',
     173        title = u'Application Category',
    174174        required = False,
    175175        )   
Note: See TracChangeset for help on using the changeset viewer.