Changeset 4755
- Timestamp:
- 9 Jan 2010, 11:14:06 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/pages.py
r4735 r4755 9 9 from hurry.query import Eq 10 10 from hurry.query.query import Query, Text 11 from hurry.workflow.interfaces import NoTransitionAvailableError 11 12 from waeup.browser import (WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage, 12 13 WAeUPDisplayFormPage) … … 19 20 from waeup.widgets.interfaces import ITableProvider 20 21 from waeup.utils.helpers import getName 22 from zope import schema 21 23 from zope.app.security.interfaces import (IAuthentication, 22 24 IUnauthenticatedPrincipal, … … 585 587 title = u'Add certificate' 586 588 pnav = 1 587 588 # We need a deepcopy here, because otherwise also all other 589 # ICertificate forms would be affected. 590 form_fields = copy.deepcopy(grok.AutoFields(ICertificate)) 591 form_fields.get('code').field.readonly = False 592 589 form_fields = grok.AutoFields(ICertificate) 590 593 591 @grok.action('Add certificate') 594 592 def addCertificate(self, **data): 595 593 certificate = createObject(u'waeup.Certificate') 596 self.applyData(certificate, **data) 594 try: 595 self.applyData(certificate, **data) 596 except NoTransitionAvailableError: 597 self.status = Invalid('Review state cannot be changed to ' 598 'requested state: no such transition ' 599 'available in workflow.') 600 return 597 601 try: 598 602 self.context.certificates.addCertificate(certificate) … … 604 608 605 609 @grok.action('Cancel') 606 def cancel(self , **data):610 def cancel(self): #, **data): 607 611 self.redirect(self.url(self.context)) 608 612 return … … 717 721 grok.name('manage') 718 722 grok.require('waeup.manageUniversity') 719 form_fields = grok.AutoFields(ICertificate) 723 # We omit 'code' field from original schema and set prepend a new 724 # one with 'readonly' set to True. 725 form_fields = grok.Fields( 726 code = schema.TextLine( 727 title = u'Code', readonly=True 728 ) 729 ) + grok.AutoFields(ICertificate).omit('code') 720 730 pnav = 1 721 731 … … 727 737 @grok.action('Save') 728 738 def save(self, **data): 729 self.applyData(self.context, **data) 739 try: 740 self.applyData(self.context, **data) 741 except NoTransitionAvailableError: 742 self.status = Invalid('Review state cannot be changed to ' 743 'requested state: no such transition ' 744 'available in workflow.') 730 745 return 731 746 732 747 @grok.action('Save and return') 733 748 def saveAndReturn(self, **data): 734 self.applyData(self.context, **data) 749 try: 750 self.applyData(self.context, **data) 751 except NoTransitionAvailableError: 752 self.status = Invalid('Review state cannot be changed to ' 753 'requested state: no such transition ' 754 'available in workflow.') 755 return 735 756 self.redirect(self.url(self.context)) 736 757 return
Note: See TracChangeset for help on using the changeset viewer.