- Timestamp:
- 11 Mar 2011, 10:45:19 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser.py
r5832 r5837 24 24 import grok 25 25 26 from datetime import datetime 27 from hurry.jquery import jquery 28 from hurry.jqueryui import jqueryui 26 29 from zope.component import getUtility, getAllUtilitiesRegisteredFor 27 30 from zope.formlib.widgets import FileWidget … … 31 34 from waeup.sirp.browser.pages import LoginPage 32 35 from waeup.sirp.interfaces import IWAeUPObject 36 from waeup.sirp.browser.resources import datepicker 33 37 from waeup.sirp.browser.viewlets import ( 34 38 AddActionButton, ManageActionButton, PrimaryNavTab, … … 204 208 grok.name('index') 205 209 206 title = 'Applicants Container' 207 label = 'Applicants Container' 210 @property 211 def title(self): 212 return "Applicants Container: %s" % getattr( 213 self.context, '__name__', 'unnamed') 214 215 @property 216 def label(self): 217 return self.title 208 218 pnav = 2 209 219 … … 214 224 215 225 class ApplicantsContainerEditPage(WAeUPPage): 226 """Manage/edit a container for regular applicants. 227 """ 216 228 grok.context(IApplicantsContainer) 217 229 grok.name('manage') 218 230 219 title = 'Manage Applicants Container' 220 label = 'Manage Applicants Container' 221 pnav = 2 222 223 231 @property 232 def title(self): 233 return "Manage applicants container: %s" % getattr( 234 self.context, '__name__', 'unnamed') 235 236 @property 237 def label(self): 238 return self.title 239 240 pnav = 2 241 242 def update(self, CANCEL=None, SAVE=None, 243 title=None, description=None, startdate=None, enddate=None): 244 datepicker.need() 245 246 if CANCEL is not None: 247 self.redirect(self.url(self.context)) 248 return 249 if SAVE is None: 250 return 251 self.context.title = title 252 self.context.description = description 253 try: 254 self.context.startdate = datetime.strptime(startdate, '%Y-%m-%d') 255 except ValueError: 256 pass 257 try: 258 self.context.enddate = datetime.strptime(enddate, '%Y-%m-%d') 259 except ValueError: 260 pass 261 self.flash('Data saved.') 262 return 263 264 def getFormattedDates(self): 265 """Returns a dict with formatted start- and enddate. 266 267 Returns dates of form ``YYYY-MM-DD`` based on the start and 268 enddates of the context container. The result dict has 269 format:: 270 271 { 'start': '<YYYY-MM-DD>', 272 'end': '<YYYY-MM-DD>'} 273 274 Each value can also be ``''`` (empty string) if unset. 275 """ 276 start = '' 277 if self.context.startdate is not None: 278 start = datetime.strftime(self.context.startdate, '%Y-%m-%d') 279 end = '' 280 if self.context.enddate is not None: 281 end = datetime.strftime(self.context.enddate, '%Y-%m-%d') 282 return {'start' : start, 'end' : end } 283 284 285 class ManageApplicantsContainer(WAeUPEditFormPage): 286 grok.context(IApplicantsContainer) 287 grok.name('edit') 288 form_fields = grok.AutoFields(IApplicantsContainer) 289 label = 'Edit container' 290 title = label 291 pnav = 2 292 293 def update(self): 294 datepicker.need() 295 return super(ManageApplicantsContainer, self).update() 296 297 @grok.action('Apply') 298 def apply(self, **data): 299 self.applyData(self.context, **data) 300 self.flash('Data saved.') 301 return 302 303 @grok.action('Back') 304 def cancel(self, **data): 305 self.redirect(self.url(self.context)) 306 return 307 224 308 #class AddApplicant(WAeUPAddFormPage): 225 309 # grok.context(IApplicantContainer)
Note: See TracChangeset for help on using the changeset viewer.