- Timestamp:
- 16 Jan 2016, 15:01:09 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/kofacustom.nigeria/trunk/src/kofacustom/nigeria/students/browser.py
r13458 r13620 20 20 from zope.component import getUtility 21 21 from zope.i18n import translate 22 from datetime import datetime 22 23 from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget 23 from waeup.kofa.interfaces import IExtFileStore 24 from waeup.kofa.browser.layout import action 24 from waeup.kofa.interfaces import IExtFileStore, IObjectHistory 25 from waeup.kofa.browser.layout import action, UtilityView 26 from waeup.kofa.utils.helpers import get_current_principal 25 27 from waeup.kofa.students.browser import ( 26 28 StudentPersonalDisplayFormPage, StudentPersonalManageFormPage, … … 62 64 form_fields = grok.AutoFields(INigeriaStudentBase).omit( 63 65 'password', 'suspended', 'suspended_comment') 66 form_fields[ 67 'financial_clearance_date'].custom_widget = FriendlyDatetimeDisplayWidget('le') 64 68 65 69 class NigeriaStudentBaseManageFormPage(StudentBaseManageFormPage): … … 67 71 """ 68 72 form_fields = grok.AutoFields(INigeriaStudentBase).omit( 69 'student_id', 'adm_code', 'suspended') 73 'student_id', 'adm_code', 'suspended', 74 'financially_cleared_by', 'financial_clearance_date') 70 75 71 76 class NigeriaStudentBaseEditFormPage(StudentBaseEditFormPage): … … 252 257 super(StudentFilesUploadPage, self).update() 253 258 return 259 260 class ClearStudentFinancially(UtilityView, grok.View): 261 """ Clear student financially by bursary officer 262 """ 263 grok.context(INigeriaStudent) 264 grok.name('clear_financially') 265 grok.require('waeup.clearStudentFinancially') 266 267 def update(self): 268 if self.context.financially_cleared_by: 269 self.flash(_('This student has already been financially cleared.'), 270 type="danger") 271 self.redirect(self.url(self.context)) 272 return 273 user = get_current_principal() 274 if user is None: 275 usertitle = 'system' 276 else: 277 usertitle = getattr(user, 'public_name', None) 278 if not usertitle: 279 usertitle = user.title 280 self.context.financially_cleared_by = usertitle 281 self.context.financial_clearance_date = datetime.utcnow() 282 self.context.writeLogMessage(self,'financially cleared') 283 history = IObjectHistory(self.context) 284 history.addMessage('Financially cleared') 285 self.flash(_('Student has been financially cleared.')) 286 self.redirect(self.url(self.context)) 287 return 288 289 def render(self): 290 return 291 292 class WithdrawFinancialClearance(UtilityView, grok.View): 293 """ Withdraw financial clearance by bursary officer 294 """ 295 grok.context(INigeriaStudent) 296 grok.name('withdraw_financial_clearance') 297 grok.require('waeup.clearStudentFinancially') 298 299 def update(self): 300 if not self.context.financially_cleared_by: 301 self.flash(_('This student has not yet been financially cleared.'), 302 type="danger") 303 self.redirect(self.url(self.context)) 304 return 305 self.context.financially_cleared_by = None 306 self.context.financial_clearance_date = None 307 self.context.writeLogMessage(self,'financial clearance withdrawn') 308 history = IObjectHistory(self.context) 309 history.addMessage('Financial clearance withdrawn') 310 self.flash(_('Financial clearance withdrawn.')) 311 self.redirect(self.url(self.context)) 312 return 313 314 def render(self): 315 return
Note: See TracChangeset for help on using the changeset viewer.