Changeset 5822 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 9 Mar 2011, 13:45:10 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r5806 r5822 24 24 import grok 25 25 26 from zope.component import getUtility, getAllUtilitiesRegisteredFor 26 27 from zope.formlib.widgets import FileWidget 27 28 from waeup.sirp.browser import ( … … 30 31 from waeup.sirp.browser.pages import LoginPage 31 32 from waeup.sirp.interfaces import IWAeUPObject 33 from waeup.sirp.browser.viewlets import AddActionButton 32 34 from waeup.sirp.applicants import get_applicant_data, ResultEntry 33 35 from waeup.sirp.applicants.interfaces import ( 34 IApplicant, IApplicantPrincipal, IApplicantPDEEditData) 36 IApplicant, IApplicantPrincipal, IApplicantPDEEditData, 37 IApplicantsRoot, IApplicantsContainer, IApplicantContainerProvider, 38 ) 35 39 from waeup.sirp.widgets.passportwidget import ( 36 40 PassportWidget, PassportDisplayWidget … … 62 66 MultiListDisplayWidget, subwidget=results_display_widget) 63 67 64 #class ApplicationsPage(WAeUPPage):65 # grok.context(IApplicantContainer)66 #grok.name('index')67 # title = 'Applications'68 #pnav = 169 #70 #def getApplications(self):71 # """Get a list of all stored applications.72 #"""73 #for key, val in self.context.items():74 #url = self.url(val)75 #yield(dict(url=url, name=key))68 class ApplicationsPage(WAeUPPage): 69 grok.context(IApplicantsRoot) 70 grok.name('index') 71 title = 'Applicants' 72 pnav = 1 73 74 def getApplications(self): 75 """Get a list of all stored applicant containers. 76 """ 77 for key, val in self.context.items(): 78 url = self.url(val) 79 yield(dict(url=url, name=key)) 76 80 81 class AddApplicantsContainerActionButton(AddActionButton): 82 grok.context(IApplicantsRoot) 83 grok.view(ApplicationsPage) 84 text = 'Add applicants container' 85 86 class AddApplicantsContainer(WAeUPPage): 87 grok.context(IApplicantsRoot) 88 grok.name('add') 89 grok.template('addcontainer') 90 title = 'Add applicants container' 91 pnav = 1 92 93 def update(self, providername=None, name=None, ADD=None, CANCEL=None): 94 if CANCEL is not None: 95 self.redirect(self.url(self.context)) 96 return 97 if ADD is None: 98 return 99 if not name: 100 self.flash('Error: you must give a name') 101 return 102 if name in self.context.keys(): 103 self.flash('A container of the given name already exists') 104 return 105 # Add new applicants container... 106 provider = getUtility(IApplicantContainerProvider, 107 name=providername) 108 container = provider.factory() 109 self.context[name] = container 110 self.flash('Added "%s".' % name) 111 self.redirect(self.url(self.context)) 112 return 113 114 def getContainerProviders(self): 115 116 providers = getAllUtilitiesRegisteredFor(IApplicantContainerProvider) 117 result = [ 118 {'name': getattr(x, 'grokcore.component.directive.name'), 119 'provider': x} 120 for x in providers 121 ] 122 return result 123 77 124 #class AddApplicant(WAeUPAddFormPage): 78 125 # grok.context(IApplicantContainer)
Note: See TracChangeset for help on using the changeset viewer.