Ignore:
Timestamp:
10 Jun 2011, 06:58:09 (14 years ago)
Author:
Henrik Bettermann
Message:
  • Use user_data attribute to display more appropriate workflow messages.
  • confirm_passport must not be an attribute of Applicant. Use confirm_passport only in form to allow submission.
  • application_state must not be an attribute of Applicant.
Location:
main/waeup.sirp/trunk/src/waeup/sirp/applicants
Files:
5 edited

Legend:

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

    r6314 r6322  
    4747    def __init__(self):
    4848        super(Applicant, self).__init__()
     49        timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
    4950        #Initialize workflow state...
    5051        IWorkflowInfo(self).fireTransition('init')
    51         timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
    52         self.messages = u'%s - Initialize application' % timestamp
    5352
    5453# Set all attributes of Applicant required in IApplicant as field
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py

    r6321 r6322  
    7676TRANSITION_OBJECTS = create_workflow()
    7777
    78 TRANSITION_DICT = dict([
    79     (transition_object.transition_id,transition_object.title)
    80     for transition_object in TRANSITION_OBJECTS])
     78#TRANSITION_DICT = dict([
     79#    (transition_object.transition_id,transition_object.title)
     80#    for transition_object in TRANSITION_OBJECTS])
    8181
    8282class ApplicantsRootPage(WAeUPPage):
     
    419419        if state == INITIALIZED:
    420420            IWorkflowInfo(self.context[pin]).fireTransition('start')
    421             timestamp = datetime.now().strftime("%d/%m/%Y %H:%M")
    422             transition_title = TRANSITION_DICT['start']
    423             self.context[pin].messages += '<br />%s - %s' % (
    424                 timestamp,transition_title)
    425421        self.redirect(self.url(self.context[pin], 'edit'))
    426422        return
     
    496492    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    497493    grok.template('form_edit')
     494    manage_applications = True
    498495    pnav = 3
    499496
     
    551548    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
    552549    grok.template('form_edit')
     550    manage_applications = False
     551
    553552
    554553    def emitLockMessage(self):
     
    566565
    567566    def dataNotComplete(self):
    568         if self.context.confirm_passport is not True:
     567        #import pdb; pdb.set_trace()
     568        if not self.request.form.get('confirm_passport', False):
    569569            return 'Passport confirmation box not ticked.'
    570570        if len(self.errors) > 0:
     
    572572        return False
    573573
    574     @property
    575     def getTransitions(self):
    576         return None
    577 
    578574    @grok.action('Save')
    579575    def save(self, **data):
     
    597593            return
    598594        state = IWorkflowState(self.context).getState()
    599         # Cannot happen but anyway ...
     595        # This shouldn't happen, but the application officer
     596        # might have forgotten to lock the form after changing the state
    600597        if state != STARTED:
    601             self.flash('This form cannot be submitted.')
     598            self.flash('This form cannot be submitted. Wrong state!')
    602599            return
    603600        IWorkflowInfo(self.context).fireTransition('submit')
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/form_edit.pt

    r6307 r6322  
    5454        </tr>
    5555      </tal:block>
    56         <tr tal:condition="view/getTransitions">
     56        <tr tal:condition="view/manage_applications">
    5757        <td class="label"><label>Application Transition:</label></td>
    5858        <td>
     
    6868  </table>
    6969
     70  <p tal:condition="not: view/manage_applications">
     71    <input class="checkboxType" id="confirm_passport" name="confirm_passport" type="checkbox" value="True"/>
     72    I confirm that the Passport Photograph uploaded on this form is a true picture of me.
     73  </p>
     74
    7075  <div id="actionsView">
    7176    <span class="actionButtons" tal:condition="view/availableActions">
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/interfaces.py

    r6313 r6322  
    347347        max_size = 20480,
    348348        )
    349     confirm_passport = schema.Bool(
    350         title = u"Passport picture confirmed",
    351         default = False,
    352         required = True,
    353         )
     349
    354350    #
    355351    # Process Data
     
    408404    omit fields. This has to be done in the respective form page.
    409405    """
    410     application_state = Attribute("The workflow state of an applicant object.")
    411 
    412406    screening_score = schema.Int(
    413407        title = u'Screening Score',
     
    427421        readonly = True,
    428422        )
    429     entry_session = schema.TextLine(
    430         # XXX: should be choice
     423    entry_session = schema.Choice(
     424        source = entry_session_vocab,
    431425        title = u'Entry Session',
    432426        required = False,
    433         readonly = True,
     427        readonly = True
    434428        )
    435429    notice = schema.Text(
     
    437431        required = False,
    438432        readonly = True,
    439         )
    440     confirm_passport = schema.Bool(
    441         title = u"I confirm that the Passport Photograph uploaded on this form is a true picture of me.",
    442         default = False,
    443         required = True,
    444433        )
    445434
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/workflow.py

    r6318 r6322  
    2525        source = None,
    2626        condition = NullCondition,
     27        msg = 'appplication process initialized',
    2728        destination = INITIALIZED)
    2829
     
    3031        transition_id = 'start',
    3132        title = 'Start application',
     33        msg = 'appplication process started',
    3234        source = INITIALIZED,
    3335        destination = STARTED)
     
    3638        transition_id = 'submit',
    3739        title = 'Submit application',
     40        msg = 'appplication record submitted',
    3841        source = STARTED,
    3942        destination = SUBMITTED)
     
    4245        transition_id = 'admit',
    4346        title = 'Admit applicant',
     47        msg = 'appplicant admitted',
    4448        source = SUBMITTED,
    4549        destination = ADMITTED)
     
    4852        transition_id = 'refuse1',
    4953        title = 'Refuse application',
     54        msg = 'appplication refused',
    5055        source = SUBMITTED,
    5156        destination = NOT_ADMITTED)
     
    5459        transition_id = 'refuse2',
    5560        title = 'Refuse application',
     61        msg = 'appplication refused',
    5662        source = ADMITTED,
    5763        destination = NOT_ADMITTED)
     
    6066        transition_id = 'create',
    6167        title = 'Create student record',
     68        msg = 'student record created',
    6269        source = ADMITTED,
    6370        destination = CREATED)
     
    6673        transition_id = 'reset1',
    6774        title = 'Reset application',
     75        msg = 'appplication record reset',
    6876        source = SUBMITTED,
    6977        destination = STARTED)
     
    7280        transition_id = 'reset2',
    7381        title = 'Reset application',
     82        msg = 'appplication record reset',
    7483        source = ADMITTED,
    7584        destination = STARTED)
     
    7887        transition_id = 'reset3',
    7988        title = 'Reset application',
     89        msg = 'appplication record reset',
    8090        source = NOT_ADMITTED,
    8191        destination = STARTED)
     
    8494        transition_id = 'reset4',
    8595        title = 'Reset application',
     96        msg = 'appplication record reset',
    8697        source = CREATED,
    8798        destination = STARTED)
     
    161172    """
    162173    timestamp = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
    163     comment = event.comment or '(no comment)'
    164174    # XXX: `messages` is meta data which shouldn't really be part of
    165175    #      the Applicant class. Furthermore we should not store HTML
     
    169179    #      to finetune transitions instead of doing that manually in
    170180    #      UI stuff.
    171     msg = '%s - %s to %s: %s: %s' % (
    172         timestamp, event.source, event.destination, event.transition.title,
    173         comment)
     181    msg = '%s - %s (new state: %s)' % (
     182        timestamp, event.transition.user_data['msg'], event.destination)
    174183    msgs = getattr(obj, 'messages', None)
    175     if msgs != '':
     184    if msgs:
    176185        msgs += '<br />'
    177     obj.messages += msg
     186        msgs += msg
     187    else:
     188        msgs = msg
     189    obj.messages = msgs
    178190    return
Note: See TracChangeset for help on using the changeset viewer.