Ignore:
Timestamp:
15 May 2011, 02:51:49 (14 years ago)
Author:
uli
Message:
  • Make 'cancel' work in addform.
  • Shorten attribute value computation.
File:
1 edited

Legend:

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

    r6087 r6103  
    3434    WAeUPDisplayFormPage, NullValidator)
    3535from waeup.sirp.browser.breadcrumbs import Breadcrumb
     36from waeup.sirp.browser.layout import NullValidator
    3637from waeup.sirp.browser.resources import datepicker, tabs, datatable
    3738from waeup.sirp.browser.viewlets import ManageActionButton, PrimaryNavTab
     
    140141    pnav = 3
    141142
    142     form_fields = grok.AutoFields(IApplicantsContainerAdd)
     143    form_fields = grok.AutoFields(
     144        IApplicantsContainerAdd).omit('code').omit('title')
    143145    form_fields['startdate'].custom_widget = FriendlyDateWidget('le')
    144146    form_fields['enddate'].custom_widget = FriendlyDateWidget('le')
     
    146148    def update(self):
    147149        datepicker.need() # Enable jQuery datepicker in date fields.
     150        from waeup.sirp.browser.resources import jqueryui
     151        jqueryui.need()
    148152        return super(ApplicantsContainerAddFormPage, self).update()
    149153
    150154    @grok.action('Add applicants container')
    151155    def addApplicantsContainer(self, **data):
    152         year1 = unicode(data['year'])
    153         year2 = unicode(data['year']+1)
    154         code = unicode(data['prefix']) + year1
    155         title = unicode(application_types_vocab.getTerm(data['prefix']).title) + u' ' + year1 + u'/' + year2       
     156        year = data['year']
     157        code = u'%s%s' % (data['prefix'], year)
     158        prefix = application_types_vocab.getTerm(data['prefix'])
     159        title = u'%s %s/%s' % (prefix.title, year, year + 1)
    156160        if code in self.context.keys():
    157             self.status = Invalid('The code chosen already exists '
    158                                   'in the database')
     161            self.status = Invalid(
     162                'Error: An applicants container for the same application '
     163                'type and entrance year exists already in the database')
    159164            return
    160165        # Add new applicants container...
     
    164169        container.code = code
    165170        container.title = title
    166         #import pdb; pdb.set_trace()
    167171        self.context[code] = container
    168172        self.flash('Added "%s".' % code)
     
    170174        return
    171175
    172     @grok.action('Cancel')
     176    @grok.action('Cancel', validator=NullValidator)
    173177    def cancel(self, **data):
    174         self.redirect(self.url(self.context))
     178        self.redirect(self.url(self.context, '@@manage') + '#tab-1')
    175179
    176180class ApplicantsRootBreadcrumb(Breadcrumb):
Note: See TracChangeset for help on using the changeset viewer.