source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py @ 6341

Last change on this file since 6341 was 6336, checked in by Henrik Bettermann, 14 years ago

Provide application login button (anonymous users only).

File size: 21.8 KB
RevLine 
[5273]1##
2## browser.py
3## Login : <uli@pu.smp.net>
[6153]4## Started on  Sun Jun 27 11:03:10 2010 Uli Fouquet & Henrik Bettermann
[5273]5## $Id$
[6078]6##
[6063]7## Copyright (C) 2010 Uli Fouquet & Henrik Bettermann
[5273]8## This program is free software; you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation; either version 2 of the License, or
11## (at your option) any later version.
[6078]12##
[5273]13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
[6078]17##
[5273]18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21##
[5824]22"""UI components for basic applicants and related components.
[5273]23"""
[6082]24import sys
[5273]25import grok
26
[6305]27from datetime import datetime
[6081]28from zope.formlib.widget import CustomWidgetFactory
[5937]29from zope.securitypolicy.interfaces import IPrincipalRoleManager
[6153]30from zope.traversing.browser import absoluteURL
[6081]31
[6303]32from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
33
[5273]34from waeup.sirp.browser import (
[6321]35    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, WAeUPDisplayFormPage)
[6081]36from waeup.sirp.browser.breadcrumbs import Breadcrumb
[6103]37from waeup.sirp.browser.layout import NullValidator
[6321]38from waeup.sirp.browser.pages import add_local_role, del_local_roles
[6013]39from waeup.sirp.browser.resources import datepicker, tabs, datatable
[6153]40from waeup.sirp.browser.viewlets import (
41    ManageActionButton, PrimaryNavTab, LeftSidebarLink
42    )
[6081]43from waeup.sirp.image.browser.widget import (
44    ThumbnailWidget, EncodingImageFileWidget,
[5822]45    )
[6184]46from waeup.sirp.interfaces import IWAeUPObject, ILocalRolesAssignable
[6321]47from waeup.sirp.permissions import get_users_with_local_roles
[6254]48from waeup.sirp.university.interfaces import ICertificate
[6054]49from waeup.sirp.widgets.datewidget import (
50    FriendlyDateWidget, FriendlyDateDisplayWidget)
[6084]51from waeup.sirp.widgets.restwidget import ReSTDisplayWidget
[5303]52from waeup.sirp.widgets.objectwidget import (
[5301]53    WAeUPObjectWidget, WAeUPObjectDisplayWidget)
[5303]54from waeup.sirp.widgets.multilistwidget import (
[5273]55    MultiListWidget, MultiListDisplayWidget)
[6153]56from waeup.sirp.applicants import ResultEntry, Applicant, get_applicant_data
[6081]57from waeup.sirp.applicants.interfaces import (
[6321]58    IApplicant, IApplicantPrincipal,IApplicantEdit, IApplicantsRoot,
59    IApplicantsContainer, IApplicantsContainerAdd, application_types_vocab
[5686]60    )
[6303]61from waeup.sirp.applicants.workflow import create_workflow, INITIALIZED, STARTED
[5320]62
[6321]63
[5273]64results_widget = CustomWidgetFactory(
[5301]65    WAeUPObjectWidget, ResultEntry)
[5273]66
67results_display_widget = CustomWidgetFactory(
[5301]68    WAeUPObjectDisplayWidget, ResultEntry)
[5273]69
70list_results_widget = CustomWidgetFactory(
71    MultiListWidget, subwidget=results_widget)
72
73list_results_display_widget = CustomWidgetFactory(
74    MultiListDisplayWidget, subwidget=results_display_widget)
75
[6305]76TRANSITION_OBJECTS = create_workflow()
77
[6322]78#TRANSITION_DICT = dict([
79#    (transition_object.transition_id,transition_object.title)
80#    for transition_object in TRANSITION_OBJECTS])
[6305]81
[6067]82class ApplicantsRootPage(WAeUPPage):
[5822]83    grok.context(IApplicantsRoot)
84    grok.name('index')
[6153]85    grok.require('waeup.Public')
[5822]86    title = 'Applicants'
[6069]87    label = 'Application Section'
[5843]88    pnav = 3
[6012]89
90    def update(self):
[6067]91        super(ApplicantsRootPage, self).update()
[6012]92        datatable.need()
93        return
94
[5828]95class ManageApplicantsRootActionButton(ManageActionButton):
96    grok.context(IApplicantsRoot)
[6067]97    grok.view(ApplicantsRootPage)
[6198]98    grok.require('waeup.manageApplications')
[6069]99    text = 'Manage application section'
[5828]100
[6069]101class ApplicantsRootManageFormPage(WAeUPEditFormPage):
[5828]102    grok.context(IApplicantsRoot)
103    grok.name('manage')
[6107]104    grok.template('applicantsrootmanagepage')
[6069]105    title = 'Applicants'
106    label = 'Manage application section'
[5843]107    pnav = 3
[6198]108    grok.require('waeup.manageApplications')
[6069]109    taboneactions = ['Add applicants container', 'Remove selected','Cancel']
[6184]110    tabtwoactions1 = ['Remove selected local roles']
111    tabtwoactions2 = ['Add local role']
[6069]112    subunits = 'Applicants Containers'
[6078]113
[6069]114    def update(self):
115        tabs.need()
[6108]116        datatable.need()
[6069]117        return super(ApplicantsRootManageFormPage, self).update()
[5828]118
[6184]119    def getLocalRoles(self):
120        roles = ILocalRolesAssignable(self.context)
121        return roles()
122
123    def getUsers(self):
124        """Get a list of all users.
125        """
126        for key, val in grok.getSite()['users'].items():
127            url = self.url(val)
128            yield(dict(url=url, name=key, val=val))
129
130    def getUsersWithLocalRoles(self):
131        return get_users_with_local_roles(self.context)
132
[6069]133    # ToDo: Show warning message before deletion
134    @grok.action('Remove selected')
135    def delApplicantsContainers(self, **data):
136        form = self.request.form
137        child_id = form['val_id']
138        if not isinstance(child_id, list):
139            child_id = [child_id]
140        deleted = []
141        for id in child_id:
142            try:
143                del self.context[id]
144                deleted.append(id)
145            except:
146                self.flash('Could not delete %s: %s: %s' % (
147                        id, sys.exc_info()[0], sys.exc_info()[1]))
148        if len(deleted):
149            self.flash('Successfully removed: %s' % ', '.join(deleted))
[6078]150        self.redirect(self.url(self.context, '@@manage')+'#tab-1')
151        return
[5828]152
[6069]153    @grok.action('Add applicants container', validator=NullValidator)
154    def addApplicantsContainer(self, **data):
155        self.redirect(self.url(self.context, '@@add'))
[6078]156        return
157
[6069]158    @grok.action('Cancel', validator=NullValidator)
159    def cancel(self, **data):
160        self.redirect(self.url(self.context))
[6078]161        return
162
[6184]163    @grok.action('Add local role', validator=NullValidator)
164    def addLocalRole(self, **data):
165        return add_local_role(self,2, **data)
166
167    @grok.action('Remove selected local roles')
168    def delLocalRoles(self, **data):
169        return del_local_roles(self,2,**data)
170
[6069]171class ApplicantsContainerAddFormPage(WAeUPAddFormPage):
[5822]172    grok.context(IApplicantsRoot)
[6198]173    grok.require('waeup.manageApplications')
[5822]174    grok.name('add')
[6107]175    grok.template('applicantscontaineraddpage')
[6069]176    title = 'Applicants'
177    label = 'Add applicants container'
[5843]178    pnav = 3
[6078]179
[6103]180    form_fields = grok.AutoFields(
181        IApplicantsContainerAdd).omit('code').omit('title')
[6083]182    form_fields['startdate'].custom_widget = FriendlyDateWidget('le')
183    form_fields['enddate'].custom_widget = FriendlyDateWidget('le')
[6078]184
[6083]185    def update(self):
186        datepicker.need() # Enable jQuery datepicker in date fields.
[6110]187        #from waeup.sirp.browser.resources import jqueryui
188        #jqueryui.need()
[6083]189        return super(ApplicantsContainerAddFormPage, self).update()
190
[6069]191    @grok.action('Add applicants container')
192    def addApplicantsContainer(self, **data):
[6103]193        year = data['year']
194        code = u'%s%s' % (data['prefix'], year)
195        prefix = application_types_vocab.getTerm(data['prefix'])
196        title = u'%s %s/%s' % (prefix.title, year, year + 1)
[6087]197        if code in self.context.keys():
[6105]198            self.flash(
199                'An applicants container for the same application '
200                'type and entrance year exists already in the database.')
[5822]201            return
202        # Add new applicants container...
[6083]203        provider = data['provider'][1]
[5822]204        container = provider.factory()
[6069]205        self.applyData(container, **data)
[6087]206        container.code = code
207        container.title = title
208        self.context[code] = container
[6105]209        self.flash('Added: "%s".' % code)
[6069]210        self.redirect(self.url(self.context, u'@@manage')+'#tab-1')
[5822]211        return
[6078]212
[6103]213    @grok.action('Cancel', validator=NullValidator)
[6069]214    def cancel(self, **data):
[6103]215        self.redirect(self.url(self.context, '@@manage') + '#tab-1')
[6078]216
[5845]217class ApplicantsRootBreadcrumb(Breadcrumb):
218    """A breadcrumb for applicantsroot.
219    """
220    grok.context(IApplicantsRoot)
[6153]221    title = u'Application Section'
[6078]222
[5845]223class ApplicantsContainerBreadcrumb(Breadcrumb):
224    """A breadcrumb for applicantscontainers.
225    """
226    grok.context(IApplicantsContainer)
[6319]227
[6153]228class ApplicantBreadcrumb(Breadcrumb):
229    """A breadcrumb for applicants.
230    """
231    grok.context(IApplicant)
[6319]232
[6153]233    @property
234    def title(self):
235        """Get a title for a context.
236        """
237        return self.context.access_code
[5828]238
239class ApplicantsTab(PrimaryNavTab):
[6153]240    """Applicants tab in primary navigation.
[5828]241    """
[6078]242
[5828]243    grok.context(IWAeUPObject)
244    grok.order(3)
[6336]245    grok.require('waeup.Public')
[5828]246    grok.template('primarynavtab')
247
[5843]248    pnav = 3
[5828]249    tab_title = u'Applicants'
250
251    @property
252    def link_target(self):
253        return self.view.application_url('applicants')
254
[6029]255class ApplicantsContainerPage(WAeUPDisplayFormPage):
[5830]256    """The standard view for regular applicant containers.
257    """
258    grok.context(IApplicantsContainer)
259    grok.name('index')
[6153]260    grok.require('waeup.Public')
[6029]261    grok.template('applicantscontainerpage')
[5850]262    pnav = 3
[6053]263
[6105]264    form_fields = grok.AutoFields(IApplicantsContainer).omit('title')
[6054]265    form_fields['startdate'].custom_widget = FriendlyDateDisplayWidget('le')
266    form_fields['enddate'].custom_widget = FriendlyDateDisplayWidget('le')
[6084]267    form_fields['description'].custom_widget = ReSTDisplayWidget
[6053]268
[5837]269    @property
270    def title(self):
[6087]271        return "Applicants Container: %s" % self.context.title
[5837]272
273    @property
274    def label(self):
[6087]275        return self.context.title
[5830]276
[6107]277class ApplicantsContainerManageActionButton(ManageActionButton):
[6336]278    grok.order(1)
[5832]279    grok.context(IApplicantsContainer)
280    grok.view(ApplicantsContainerPage)
[6198]281    grok.require('waeup.manageApplications')
[6070]282    text = 'Manage applicants container'
[5832]283
[6336]284class LoginApplicantActionButton(ManageActionButton):
285    grok.order(2)
286    grok.context(IApplicantsContainer)
287    grok.view(ApplicantsContainerPage)
288    grok.require('waeup.Anonymous')
289    icon = 'login.png'
290    text = 'Login for applicants'
291    target = 'login'
[5832]292
[6107]293class ApplicantsContainerManageFormPage(WAeUPEditFormPage):
[5837]294    grok.context(IApplicantsContainer)
[5850]295    grok.name('manage')
[6107]296    grok.template('applicantscontainermanagepage')
[6105]297    form_fields = grok.AutoFields(IApplicantsContainer).omit('title')
298    taboneactions = ['Save','Cancel']
299    tabtwoactions = ['Add applicant', 'Remove selected','Cancel']
[6184]300    tabthreeactions1 = ['Remove selected local roles']
301    tabthreeactions2 = ['Add local role']
[5844]302    # Use friendlier date widget...
[6054]303    form_fields['startdate'].custom_widget = FriendlyDateWidget('le')
304    form_fields['enddate'].custom_widget = FriendlyDateWidget('le')
[6198]305    grok.require('waeup.manageApplications')
[5850]306
307    @property
308    def title(self):
[6087]309        return "Applicants Container: %s" % self.context.title
[6078]310
[5850]311    @property
312    def label(self):
[6087]313        return 'Manage applicants container'
[5850]314
[5845]315    pnav = 3
[5837]316
317    def update(self):
[5850]318        datepicker.need() # Enable jQuery datepicker in date fields.
[5982]319        tabs.need()
[6015]320        datatable.need()  # Enable jQurey datatables for contents listing
[6107]321        return super(ApplicantsContainerManageFormPage, self).update()
[5837]322
[6184]323    def getLocalRoles(self):
324        roles = ILocalRolesAssignable(self.context)
325        return roles()
326
327    def getUsers(self):
328        """Get a list of all users.
329        """
330        for key, val in grok.getSite()['users'].items():
331            url = self.url(val)
332            yield(dict(url=url, name=key, val=val))
333
334    def getUsersWithLocalRoles(self):
335        return get_users_with_local_roles(self.context)
336
[5850]337    @grok.action('Save')
[5837]338    def apply(self, **data):
339        self.applyData(self.context, **data)
340        self.flash('Data saved.')
341        return
[6078]342
[6105]343    # ToDo: Show warning message before deletion
344    @grok.action('Remove selected')
345    def delApplicant(self, **data):
[6189]346        form = self.request.form
347        if form.has_key('val_id'):
348            child_id = form['val_id']
349        else:
350            self.flash('No applicant selected!')
351            self.redirect(self.url(self.context, '@@manage')+'#tab-2')
352            return
353        if not isinstance(child_id, list):
354            child_id = [child_id]
355        deleted = []
356        for id in child_id:
357            try:
358                del self.context[id]
359                deleted.append(id)
360            except:
361                self.flash('Could not delete %s: %s: %s' % (
362                        id, sys.exc_info()[0], sys.exc_info()[1]))
363        if len(deleted):
364            self.flash('Successfully removed: %s' % ', '.join(deleted))
365        self.redirect(self.url(self.context, u'@@manage')+'#tab-2')
366        return
[6105]367
368    @grok.action('Add applicant', validator=NullValidator)
369    def addApplicant(self, **data):
[6327]370        self.redirect(self.url(self.context, 'addapplicant'))
371        return
[6105]372
373    @grok.action('Cancel', validator=NullValidator)
[5837]374    def cancel(self, **data):
375        self.redirect(self.url(self.context))
376        return
[5886]377
[6184]378    @grok.action('Add local role', validator=NullValidator)
379    def addLocalRole(self, **data):
380        return add_local_role(self,3, **data)
[6105]381
[6184]382    @grok.action('Remove selected local roles')
383    def delLocalRoles(self, **data):
384        return del_local_roles(self,3,**data)
385
[5886]386class LoginApplicant(WAeUPPage):
387    grok.context(IApplicantsContainer)
388    grok.name('login')
[6153]389    grok.require('waeup.Public')
[5886]390
[6110]391    @property
392    def title(self):
393        return u"Applicant Login: %s" % self.context.title
[6078]394
[5886]395    @property
396    def label(self):
[6110]397        return u'Login for applicants only'
[5886]398
399    pnav = 3
[6319]400
[6110]401    @property
402    def ac_prefix(self):
403        return self.context.ac_prefix
[6078]404
[5896]405    def update(self, SUBMIT=None):
406        self.ac_series = self.request.form.get('form.ac_series', None)
407        self.ac_number = self.request.form.get('form.ac_number', None)
[5886]408        if SUBMIT is None:
409            return
[5894]410        if self.request.principal.id == 'zope.anybody':
[6105]411            self.flash('Entered credentials are invalid.')
[5886]412            return
[5894]413        if not IApplicantPrincipal.providedBy(self.request.principal):
414            # Don't care if user is already authenticated as non-applicant
415            return
[5905]416        pin = self.request.principal.access_code
417        if pin not in self.context.keys():
418            # Create applicant record
419            applicant = Applicant()
420            applicant.access_code = pin
421            self.context[pin] = applicant
[5937]422        # Assign current principal the owner role on created applicant
423        # record
[6184]424        role_manager = IPrincipalRoleManager(self.context[pin])
[5937]425        role_manager.assignRoleToPrincipal(
[6043]426            'waeup.local.ApplicationOwner', self.request.principal.id)
[6325]427        # Assign current principal the PortalUser role
428        role_manager = IPrincipalRoleManager(grok.getSite()['faculties'])
429        role_manager.assignRoleToPrincipal(
430            'waeup.PortalUser', self.request.principal.id)
[6303]431        state = IWorkflowState(self.context[pin]).getState()
432        if state == INITIALIZED:
433            IWorkflowInfo(self.context[pin]).fireTransition('start')
[5937]434        self.redirect(self.url(self.context[pin], 'edit'))
[5886]435        return
[6319]436
[6327]437class ApplicantAddFormPage(WAeUPAddFormPage):
438    """Add-form to add certificate to a department.
439    """
440    grok.context(IApplicantsContainer)
441    grok.require('waeup.manageApplications')
442    grok.name('addapplicant')
443    grok.template('applicantaddpage')
444    title = 'Applicants'
445    label = 'Add applicant'
446    pnav = 3
447
448    @property
449    def title(self):
450        return "Applicants Container: %s" % self.context.title
451
452    @property
453    def ac_prefix(self):
454        return self.context.ac_prefix
455
456    @grok.action('Create application record')
457    def addApplicant(self, **data):
458        ac_series = self.request.form.get('form.ac_series', None)
459        ac_number = self.request.form.get('form.ac_number', None)
460        pin = '%s-%s-%s' % (self.ac_prefix,ac_series,ac_number)
461        if pin not in self.context.keys():
462            # Create applicant record
463            applicant = Applicant()
464            applicant.access_code = pin
465            self.context[pin] = applicant
466        self.redirect(self.url(self.context[pin], 'edit'))
467        return
468
[6153]469class AccessCodeLink(LeftSidebarLink):
470    grok.order(1)
471    grok.require('waeup.Public')
[5886]472
[6153]473    def render(self):
474        if not IApplicantPrincipal.providedBy(self.request.principal):
475            return ''
476        access_code = getattr(self.request.principal,'access_code',None)
477        if access_code:
478            applicant_object = get_applicant_data(access_code)
479            url = absoluteURL(applicant_object, self.request)
[6198]480            return u'<div class="portlet"><a href="%s/edit">%s</a></div>' % (
[6153]481                url,access_code)
482        return ''
483
[5273]484class DisplayApplicant(WAeUPDisplayFormPage):
485    grok.context(IApplicant)
486    grok.name('index')
[6198]487    grok.require('waeup.handleApplication')
[6320]488    form_fields = grok.AutoFields(IApplicant).omit(
489        'locked').omit('course_admitted')
[6196]490    #form_fields['fst_sit_results'].custom_widget = list_results_display_widget
[5919]491    form_fields['passport'].custom_widget = ThumbnailWidget
[6054]492    form_fields['date_of_birth'].custom_widget = FriendlyDateDisplayWidget('le')
[5273]493    label = 'Applicant'
[6254]494    grok.template('form_display')
[5843]495    pnav = 3
[5273]496
[6196]497    @property
498    def title(self):
499        return '%s' % self.context.access_code
500
501    @property
502    def label(self):
503        container_title = self.context.__parent__.title
504        return '%s Application Record' % container_title
505
[6254]506    @property
507    def getCourseAdmitted(self):
508        course_admitted = self.context.course_admitted
509        #import pdb; pdb.set_trace()
510        if ICertificate.providedBy(course_admitted):
511            url = self.url(course_admitted)
512            title = course_admitted.title
513            code = course_admitted.code
514            return '<a href="%s">%s (%s)</a>' %(url,title,code)
515        return 'not yet admitted'
516
[6198]517class ApplicantsManageActionButton(ManageActionButton):
518    grok.context(IApplicant)
519    grok.view(DisplayApplicant)
520    grok.require('waeup.manageApplications')
521    text = 'Edit application record'
522    target = 'edit_full'
523
[6196]524class EditApplicantFull(WAeUPEditFormPage):
525    """A full edit view for applicant data.
526    """
527    grok.context(IApplicant)
528    grok.name('edit_full')
[6198]529    grok.require('waeup.manageApplications')
[6196]530    form_fields = grok.AutoFields(IApplicant)   #.omit('locked')
531    form_fields['passport'].custom_widget = EncodingImageFileWidget
532    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
533    grok.template('form_edit')
[6322]534    manage_applications = True
[6196]535    pnav = 3
536
537    def update(self):
538        datepicker.need() # Enable jQuery datepicker in date fields.
539        super(EditApplicantFull, self).update()
540        return
541
542    @property
543    def title(self):
544        return self.context.access_code
545
546    @property
547    def label(self):
548        container_title = self.context.__parent__.title
549        return '%s Application Form' % container_title
550
[6303]551    @property
552    def getTransitions(self):
[6320]553        allowed_transitions_ids = IWorkflowInfo(
554            self.context).getManualTransitionIds()
[6303]555        null_transition = [{'name': '', 'title':'No transition'}]
556        transitions = null_transition + [dict(
557            name=transition_object.transition_id,
558            title=transition_object.title)
[6305]559            for transition_object in TRANSITION_OBJECTS
[6303]560            if transition_object.transition_id in allowed_transitions_ids]
561        return transitions
562
[6196]563    @grok.action('Save')
564    def save(self, **data):
565        self.applyData(self.context, **data)
566        self.context._p_changed = True
[6303]567        form = self.request.form
568        if form.has_key('transition') and form['transition']:
[6305]569            transition_id = form['transition']
570            IWorkflowInfo(self.context).fireTransition(transition_id)
[6196]571        self.flash('Form has been saved.')
572        return
573
574class EditApplicantStudent(EditApplicantFull):
[5982]575    """An applicant-centered edit view for applicant data.
576    """
[6196]577    grok.context(IApplicantEdit)
[5273]578    grok.name('edit')
[6198]579    grok.require('waeup.handleApplication')
[6196]580    form_fields = grok.AutoFields(IApplicantEdit).omit('locked')
[5686]581    form_fields['passport'].custom_widget = EncodingImageFileWidget
[6054]582    form_fields['date_of_birth'].custom_widget = FriendlyDateWidget('le-year')
[6196]583    grok.template('form_edit')
[6322]584    manage_applications = False
[5484]585
[6322]586
[5941]587    def emitLockMessage(self):
[6105]588        self.flash('The requested form is locked (read-only).')
[5941]589        self.redirect(self.url(self.context))
590        return
[6078]591
[5686]592    def update(self):
[5941]593        if self.context.locked:
[6198]594            self.redirect(self.url(self.context))
[5941]595            return
[6040]596        datepicker.need() # Enable jQuery datepicker in date fields.
[5982]597        super(EditApplicantStudent, self).update()
[5686]598        return
[5952]599
[6196]600    def dataNotComplete(self):
[6322]601        #import pdb; pdb.set_trace()
602        if not self.request.form.get('confirm_passport', False):
[6196]603            return 'Passport confirmation box not ticked.'
604        if len(self.errors) > 0:
605            return 'Form has errors.'
606        return False
[5952]607
[5273]608    @grok.action('Save')
609    def save(self, **data):
[5941]610        if self.context.locked:
611            self.emitLockMessage()
612            return
[5273]613        self.applyData(self.context, **data)
614        self.context._p_changed = True
[6196]615        self.flash('Form has been saved.')
[5273]616        return
617
[5484]618    @grok.action('Final Submit')
619    def finalsubmit(self, **data):
[5941]620        if self.context.locked:
621            self.emitLockMessage()
622            return
[5273]623        self.applyData(self.context, **data)
[5484]624        self.context._p_changed = True
[6196]625        if self.dataNotComplete():
626            self.flash(self.dataNotComplete())
[5941]627            return
[6303]628        state = IWorkflowState(self.context).getState()
[6322]629        # This shouldn't happen, but the application officer
630        # might have forgotten to lock the form after changing the state
[6303]631        if state != STARTED:
[6322]632            self.flash('This form cannot be submitted. Wrong state!')
[6303]633            return
634        IWorkflowInfo(self.context).fireTransition('submit')
[5941]635        self.context.locked = True
[6196]636        self.flash('Form has been submitted.')
637        self.redirect(self.url(self.context))
[5273]638        return
[5941]639
Note: See TracBrowser for help on using the repository browser.