[11976] | 1 | ## $Id: viewlets.py 17867 2024-08-02 19:10:34Z henrik $ |
---|
[7191] | 2 | ## |
---|
| 3 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann |
---|
| 4 | ## This program is free software; you can redistribute it and/or modify |
---|
| 5 | ## it under the terms of the GNU General Public License as published by |
---|
| 6 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | ## (at your option) any later version. |
---|
| 8 | ## |
---|
| 9 | ## This program is distributed in the hope that it will be useful, |
---|
| 10 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | ## GNU General Public License for more details. |
---|
| 13 | ## |
---|
| 14 | ## You should have received a copy of the GNU General Public License |
---|
| 15 | ## along with this program; if not, write to the Free Software |
---|
| 16 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | ## |
---|
[6642] | 18 | import grok |
---|
[7097] | 19 | from zope.component import getUtility |
---|
[13935] | 20 | from zope.i18n import translate |
---|
[6642] | 21 | from zope.interface import Interface |
---|
[13935] | 22 | from waeup.kofa.browser.layout import default_primary_nav_template |
---|
[7811] | 23 | from waeup.kofa.browser.viewlets import ( |
---|
[7591] | 24 | PrimaryNavTab, ManageActionButton, AddActionButton) |
---|
[13935] | 25 | from waeup.kofa.interfaces import MessageFactory as _ |
---|
| 26 | from waeup.kofa.interfaces import IExtFileStore, IKofaObject |
---|
[7811] | 27 | from waeup.kofa.students.browser import ( |
---|
[13935] | 28 | StudentsContainerPage, StudentsContainerManagePage, |
---|
| 29 | StudentBaseDisplayFormPage, StudentClearanceDisplayFormPage, |
---|
| 30 | StudentPersonalDisplayFormPage, StudyCourseDisplayFormPage, |
---|
| 31 | StudyLevelDisplayFormPage, CourseTicketDisplayFormPage, |
---|
| 32 | OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage, |
---|
[9517] | 33 | StudentClearanceEditFormPage, StudentPersonalEditFormPage, |
---|
[15422] | 34 | PaymentsManageFormPage, StudyCourseTranscriptPage) |
---|
[7811] | 35 | from waeup.kofa.students.interfaces import ( |
---|
[13935] | 36 | IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel, |
---|
| 37 | ICourseTicket, IStudentOnlinePayment, IBedTicket, |
---|
[15163] | 38 | IStudentPaymentsContainer, IStudentsUtils, |
---|
[7591] | 39 | ) |
---|
[13935] | 40 | from waeup.kofa.students.workflow import ( |
---|
| 41 | ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED, |
---|
[15163] | 42 | TRANSREQ, TRANSVAL, TRANSREL) |
---|
[6642] | 43 | |
---|
[13935] | 44 | |
---|
| 45 | grok.context(IKofaObject) # Make IKofaObject the default context |
---|
[6687] | 46 | grok.templatedir('browser_templates') |
---|
[6642] | 47 | |
---|
[7123] | 48 | |
---|
[6687] | 49 | class StudentManageSidebar(grok.ViewletManager): |
---|
| 50 | grok.name('left_studentmanage') |
---|
[6642] | 51 | |
---|
[13935] | 52 | |
---|
[6687] | 53 | class StudentManageLink(grok.Viewlet): |
---|
[6660] | 54 | """A link displayed in the student box which shows up for StudentNavigation |
---|
[6642] | 55 | objects. |
---|
| 56 | |
---|
| 57 | """ |
---|
| 58 | grok.baseclass() |
---|
[6687] | 59 | grok.viewletmanager(StudentManageSidebar) |
---|
[7819] | 60 | grok.context(IKofaObject) |
---|
[6642] | 61 | grok.view(Interface) |
---|
| 62 | grok.order(5) |
---|
[6660] | 63 | grok.require('waeup.viewStudent') |
---|
[6642] | 64 | |
---|
| 65 | link = 'index' |
---|
[7738] | 66 | text = _(u'Base Data') |
---|
[6642] | 67 | |
---|
| 68 | def render(self): |
---|
[8736] | 69 | url = self.view.url(self.context.student, self.link) |
---|
[7833] | 70 | # Here we know that the cookie has been set |
---|
| 71 | lang = self.request.cookies.get('kofa.language') |
---|
[13935] | 72 | text = translate( |
---|
| 73 | self.text, 'waeup.kofa', target_language=lang) |
---|
[10802] | 74 | if not self.link: |
---|
| 75 | return '' |
---|
[7459] | 76 | return u'<li><a href="%s">%s</a></li>' % ( |
---|
[13935] | 77 | url, text) |
---|
[6642] | 78 | |
---|
[13935] | 79 | |
---|
[7459] | 80 | class StudentManageApplicationLink(StudentManageLink): |
---|
[6687] | 81 | grok.order(1) |
---|
[7351] | 82 | link = 'application_slip' |
---|
[7738] | 83 | text = _(u'Application Slip') |
---|
[7340] | 84 | |
---|
| 85 | def render(self): |
---|
[7351] | 86 | slip = getUtility(IExtFileStore).getFileByContext( |
---|
[8736] | 87 | self.context.student, attr=self.link) |
---|
[7351] | 88 | if slip: |
---|
[10805] | 89 | lang = self.request.cookies.get('kofa.language') |
---|
[13935] | 90 | text = translate( |
---|
| 91 | self.text, 'waeup.kofa', target_language=lang) |
---|
| 92 | url = self.view.url(self.context.student, self.link) |
---|
[7459] | 93 | return u'<li><a href="%s">%s</a></li>' % ( |
---|
[13935] | 94 | url, text) |
---|
[7340] | 95 | return '' |
---|
| 96 | |
---|
[7459] | 97 | class StudentManageBaseLink(StudentManageLink): |
---|
| 98 | grok.order(2) |
---|
| 99 | link = 'index' |
---|
[7738] | 100 | text = _(u'Base Data') |
---|
[7459] | 101 | |
---|
[13935] | 102 | |
---|
[6687] | 103 | class StudentManageClearanceLink(StudentManageLink): |
---|
[7340] | 104 | grok.order(3) |
---|
[10802] | 105 | grok.name('studentmanageclearancelink') |
---|
[6687] | 106 | link = 'view_clearance' |
---|
[7738] | 107 | text = _(u'Clearance Data') |
---|
[6687] | 108 | |
---|
[13935] | 109 | |
---|
[6687] | 110 | class StudentManagePersonalLink(StudentManageLink): |
---|
[7340] | 111 | grok.order(4) |
---|
[10802] | 112 | grok.name('studentmanagepersonallink') |
---|
[6687] | 113 | link = 'view_personal' |
---|
[7738] | 114 | text = _(u'Personal Data') |
---|
[6687] | 115 | |
---|
[13935] | 116 | |
---|
[6687] | 117 | class StudentManageStudyCourseLink(StudentManageLink): |
---|
[7340] | 118 | grok.order(5) |
---|
[6687] | 119 | link = 'studycourse' |
---|
[7738] | 120 | text = _(u'Study Course') |
---|
[6687] | 121 | |
---|
[13935] | 122 | |
---|
[6687] | 123 | class StudentManagePaymentsLink(StudentManageLink): |
---|
[7340] | 124 | grok.order(6) |
---|
[10080] | 125 | grok.require('waeup.viewStudent') |
---|
[6687] | 126 | link = 'payments' |
---|
[7738] | 127 | text = _(u'Payments') |
---|
[6687] | 128 | |
---|
[13935] | 129 | |
---|
[6687] | 130 | class StudentManageAccommodationLink(StudentManageLink): |
---|
[7340] | 131 | grok.order(7) |
---|
[10803] | 132 | grok.name('studentmanageaccommodationlink') |
---|
[15972] | 133 | grok.require('waeup.viewStudent') |
---|
[6687] | 134 | link = 'accommodation' |
---|
[7738] | 135 | text = _(u'Accommodation') |
---|
[6687] | 136 | |
---|
[13935] | 137 | |
---|
[6687] | 138 | class StudentManageHistoryLink(StudentManageLink): |
---|
[7340] | 139 | grok.order(8) |
---|
[6687] | 140 | link = 'history' |
---|
[7738] | 141 | text = _(u'History') |
---|
[6687] | 142 | |
---|
[7591] | 143 | |
---|
[15163] | 144 | class StudentManageTranscriptLink(StudentManageLink): |
---|
| 145 | grok.order(9) |
---|
| 146 | link = 'final_transcript' |
---|
| 147 | text = _(u'Final Transcript') |
---|
| 148 | |
---|
| 149 | def render(self): |
---|
| 150 | slip = getUtility(IExtFileStore).getFileByContext( |
---|
| 151 | self.context.student, attr=self.link) |
---|
| 152 | if slip: |
---|
| 153 | lang = self.request.cookies.get('kofa.language') |
---|
| 154 | text = translate( |
---|
| 155 | self.text, 'waeup.kofa', target_language=lang) |
---|
| 156 | url = self.view.url(self.context.student, self.link) |
---|
| 157 | return u'<li><a href="%s">%s</a></li>' % ( |
---|
| 158 | url, text) |
---|
| 159 | return '' |
---|
| 160 | |
---|
| 161 | |
---|
[7591] | 162 | class StudentsContainerManageActionButton(ManageActionButton): |
---|
| 163 | grok.order(1) |
---|
| 164 | grok.context(IStudentsContainer) |
---|
| 165 | grok.view(StudentsContainerPage) |
---|
| 166 | grok.require('waeup.manageStudent') |
---|
[13076] | 167 | text = _('Manage students section') |
---|
[7591] | 168 | |
---|
[13935] | 169 | |
---|
[7591] | 170 | class StudentsContainerAddActionButton(AddActionButton): |
---|
| 171 | grok.order(1) |
---|
| 172 | grok.context(IStudentsContainer) |
---|
| 173 | grok.view(StudentsContainerManagePage) |
---|
| 174 | grok.require('waeup.manageStudent') |
---|
[7738] | 175 | text = _('Add student') |
---|
[7591] | 176 | target = 'addstudent' |
---|
| 177 | |
---|
[13935] | 178 | |
---|
[7591] | 179 | class ContactActionButton(ManageActionButton): |
---|
[9191] | 180 | grok.order(5) |
---|
[7591] | 181 | grok.context(IStudent) |
---|
| 182 | grok.view(StudentBaseDisplayFormPage) |
---|
[16523] | 183 | grok.require('waeup.viewStudent') |
---|
[7591] | 184 | icon = 'actionicon_mail.png' |
---|
[7738] | 185 | text = _('Send email') |
---|
[7591] | 186 | target = 'contactstudent' |
---|
| 187 | |
---|
[13935] | 188 | |
---|
[7591] | 189 | class StudentBaseManageActionButton(ManageActionButton): |
---|
| 190 | grok.order(1) |
---|
| 191 | grok.context(IStudent) |
---|
| 192 | grok.view(StudentBaseDisplayFormPage) |
---|
| 193 | grok.require('waeup.manageStudent') |
---|
[7738] | 194 | text = _('Manage') |
---|
[7591] | 195 | target = 'manage_base' |
---|
| 196 | |
---|
[13935] | 197 | |
---|
[9273] | 198 | class StudentTrigTransActionButton(ManageActionButton): |
---|
| 199 | grok.order(2) |
---|
| 200 | grok.context(IStudent) |
---|
| 201 | grok.view(StudentBaseDisplayFormPage) |
---|
| 202 | grok.require('waeup.triggerTransition') |
---|
| 203 | icon = 'actionicon_trigtrans.png' |
---|
| 204 | text = _(u'Trigger transition') |
---|
| 205 | target = 'trigtrans' |
---|
| 206 | |
---|
[13935] | 207 | |
---|
[9338] | 208 | class StudentLoginAsActionButton(ManageActionButton): |
---|
| 209 | grok.order(3) |
---|
| 210 | grok.context(IStudent) |
---|
| 211 | grok.view(StudentBaseDisplayFormPage) |
---|
| 212 | grok.require('waeup.loginAsStudent') |
---|
| 213 | icon = 'actionicon_mask.png' |
---|
| 214 | text = _(u'Login as student') |
---|
| 215 | target = 'loginasstep1' |
---|
| 216 | |
---|
[13935] | 217 | |
---|
[9191] | 218 | class AdmissionSlipActionButton(ManageActionButton): |
---|
| 219 | grok.order(4) |
---|
| 220 | grok.context(IStudent) |
---|
| 221 | grok.view(StudentBaseDisplayFormPage) |
---|
| 222 | grok.require('waeup.viewStudent') |
---|
| 223 | icon = 'actionicon_pdf.png' |
---|
| 224 | text = _('Download admission letter') |
---|
| 225 | target = 'admission_slip.pdf' |
---|
| 226 | |
---|
[13935] | 227 | |
---|
[10694] | 228 | class StudentTransferButton(ManageActionButton): |
---|
[9191] | 229 | grok.order(6) |
---|
[9124] | 230 | grok.context(IStudent) |
---|
| 231 | grok.view(StudentBaseDisplayFormPage) |
---|
| 232 | grok.require('waeup.manageStudent') |
---|
[9138] | 233 | text = _('Transfer student') |
---|
| 234 | target = 'transfer' |
---|
| 235 | icon = 'actionicon_redo.png' |
---|
| 236 | |
---|
[13935] | 237 | |
---|
[9138] | 238 | class StudentDeactivateActionButton(ManageActionButton): |
---|
[9191] | 239 | grok.order(7) |
---|
[9138] | 240 | grok.context(IStudent) |
---|
| 241 | grok.view(StudentBaseDisplayFormPage) |
---|
| 242 | grok.require('waeup.manageStudent') |
---|
[9124] | 243 | text = _('Deactivate account') |
---|
| 244 | target = 'deactivate' |
---|
| 245 | icon = 'actionicon_traffic_lights_red.png' |
---|
| 246 | |
---|
| 247 | @property |
---|
| 248 | def target_url(self): |
---|
| 249 | if self.context.suspended: |
---|
| 250 | return '' |
---|
| 251 | return self.view.url(self.view.context, self.target) |
---|
| 252 | |
---|
[9145] | 253 | @property |
---|
| 254 | def onclick(self): |
---|
| 255 | return "return window.confirm(%s);" % _( |
---|
| 256 | "'A history message will be added. Are you sure?'") |
---|
| 257 | |
---|
[13935] | 258 | |
---|
[9124] | 259 | class StudentActivateActionButton(ManageActionButton): |
---|
[9191] | 260 | grok.order(7) |
---|
[9124] | 261 | grok.context(IStudent) |
---|
| 262 | grok.view(StudentBaseDisplayFormPage) |
---|
| 263 | grok.require('waeup.manageStudent') |
---|
| 264 | text = _('Activate account') |
---|
| 265 | target = 'activate' |
---|
| 266 | icon = 'actionicon_traffic_lights_green.png' |
---|
| 267 | |
---|
| 268 | @property |
---|
| 269 | def target_url(self): |
---|
| 270 | if not self.context.suspended: |
---|
| 271 | return '' |
---|
| 272 | return self.view.url(self.view.context, self.target) |
---|
| 273 | |
---|
[9145] | 274 | @property |
---|
| 275 | def onclick(self): |
---|
| 276 | return "return window.confirm(%s);" % _( |
---|
| 277 | "'A history message will be added. Are you sure?'") |
---|
| 278 | |
---|
[13935] | 279 | |
---|
[7591] | 280 | class StudentClearanceManageActionButton(ManageActionButton): |
---|
| 281 | grok.order(1) |
---|
| 282 | grok.context(IStudent) |
---|
| 283 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 284 | grok.require('waeup.manageStudent') |
---|
[7738] | 285 | text = _('Manage') |
---|
[8119] | 286 | target = 'manage_clearance' |
---|
[7591] | 287 | |
---|
[13935] | 288 | |
---|
[7591] | 289 | class StudentClearActionButton(ManageActionButton): |
---|
| 290 | grok.order(2) |
---|
| 291 | grok.context(IStudent) |
---|
| 292 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 293 | grok.require('waeup.clearStudent') |
---|
[7738] | 294 | text = _('Clear student') |
---|
[7591] | 295 | target = 'clear' |
---|
| 296 | icon = 'actionicon_accept.png' |
---|
| 297 | |
---|
| 298 | @property |
---|
| 299 | def target_url(self): |
---|
[13935] | 300 | cdm = getUtility( |
---|
| 301 | IStudentsUtils).clearance_disabled_message(self.context) |
---|
[11772] | 302 | if cdm: |
---|
[9814] | 303 | return '' |
---|
[7591] | 304 | if self.context.state != REQUESTED: |
---|
| 305 | return '' |
---|
| 306 | return self.view.url(self.view.context, self.target) |
---|
| 307 | |
---|
[16187] | 308 | class StudentTemporarilyClearActionButton(ManageActionButton): |
---|
| 309 | grok.order(3) |
---|
| 310 | grok.context(IStudent) |
---|
| 311 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 312 | grok.require('waeup.clearStudent') |
---|
| 313 | text = _('Clear student temporarily') |
---|
| 314 | target = 'temp_clearance' |
---|
| 315 | icon = 'actionicon_accept.png' |
---|
[13935] | 316 | |
---|
[16187] | 317 | @property |
---|
| 318 | def target_url(self): |
---|
| 319 | cdm = getUtility( |
---|
| 320 | IStudentsUtils).clearance_disabled_message(self.context) |
---|
| 321 | if cdm: |
---|
| 322 | return '' |
---|
| 323 | if self.context.officer_comment \ |
---|
| 324 | and self.context.officer_comment.startswith('Temporarily cleared'): |
---|
| 325 | return '' |
---|
| 326 | if self.context.state != REQUESTED: |
---|
| 327 | return '' |
---|
| 328 | return self.view.url(self.view.context, self.target) |
---|
| 329 | |
---|
| 330 | |
---|
[7591] | 331 | class StudentRejectClearanceActionButton(ManageActionButton): |
---|
[16187] | 332 | grok.order(4) |
---|
[7591] | 333 | grok.context(IStudent) |
---|
| 334 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 335 | grok.require('waeup.clearStudent') |
---|
[7738] | 336 | text = _('Reject clearance') |
---|
[7591] | 337 | target = 'reject_clearance' |
---|
| 338 | icon = 'actionicon_reject.png' |
---|
| 339 | |
---|
| 340 | @property |
---|
| 341 | def target_url(self): |
---|
[13935] | 342 | cdm = getUtility( |
---|
| 343 | IStudentsUtils).clearance_disabled_message(self.context) |
---|
[11772] | 344 | if cdm: |
---|
[9814] | 345 | return '' |
---|
[7591] | 346 | if self.context.state not in (REQUESTED, CLEARED): |
---|
| 347 | return '' |
---|
| 348 | return self.view.url(self.view.context, self.target) |
---|
| 349 | |
---|
[13935] | 350 | |
---|
[7591] | 351 | class ClearanceSlipActionButton(ManageActionButton): |
---|
[16187] | 352 | grok.order(5) |
---|
[7591] | 353 | grok.context(IStudent) |
---|
| 354 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 355 | grok.require('waeup.viewStudent') |
---|
| 356 | icon = 'actionicon_pdf.png' |
---|
[7738] | 357 | text = _('Download clearance slip') |
---|
[9452] | 358 | target = 'clearance_slip.pdf' |
---|
[7591] | 359 | |
---|
[13935] | 360 | |
---|
[8119] | 361 | class ClearanceViewActionButton(ManageActionButton): |
---|
| 362 | grok.order(1) |
---|
| 363 | grok.context(IStudent) |
---|
| 364 | grok.view(StudentClearanceEditFormPage) |
---|
| 365 | grok.require('waeup.viewStudent') |
---|
| 366 | icon = 'actionicon_view.png' |
---|
| 367 | text = _('View') |
---|
| 368 | target = 'view_clearance' |
---|
| 369 | |
---|
[13935] | 370 | |
---|
[8119] | 371 | class PersonalViewActionButton(ManageActionButton): |
---|
| 372 | grok.order(1) |
---|
| 373 | grok.context(IStudent) |
---|
| 374 | grok.view(StudentPersonalEditFormPage) |
---|
| 375 | grok.require('waeup.viewStudent') |
---|
| 376 | icon = 'actionicon_view.png' |
---|
| 377 | text = _('View') |
---|
| 378 | target = 'view_personal' |
---|
| 379 | |
---|
[13935] | 380 | |
---|
[8903] | 381 | class StudentPersonalManageActionButton(ManageActionButton): |
---|
[7591] | 382 | grok.order(1) |
---|
| 383 | grok.context(IStudent) |
---|
| 384 | grok.view(StudentPersonalDisplayFormPage) |
---|
[8903] | 385 | grok.require('waeup.manageStudent') |
---|
| 386 | text = _('Manage') |
---|
| 387 | target = 'manage_personal' |
---|
| 388 | |
---|
[13935] | 389 | |
---|
[8903] | 390 | class StudentPersonalEditActionButton(ManageActionButton): |
---|
| 391 | grok.order(2) |
---|
| 392 | grok.context(IStudent) |
---|
| 393 | grok.view(StudentPersonalDisplayFormPage) |
---|
| 394 | grok.require('waeup.handleStudent') |
---|
[7738] | 395 | text = _('Edit') |
---|
[7591] | 396 | target = 'edit_personal' |
---|
| 397 | |
---|
[13935] | 398 | |
---|
[7591] | 399 | class StudyCourseManageActionButton(ManageActionButton): |
---|
| 400 | grok.order(1) |
---|
| 401 | grok.context(IStudentStudyCourse) |
---|
| 402 | grok.view(StudyCourseDisplayFormPage) |
---|
| 403 | grok.require('waeup.manageStudent') |
---|
[7738] | 404 | text = _('Manage') |
---|
[7591] | 405 | target = 'manage' |
---|
| 406 | |
---|
[9138] | 407 | @property |
---|
| 408 | def target_url(self): |
---|
| 409 | if self.context.is_current: |
---|
| 410 | return self.view.url(self.view.context, self.target) |
---|
| 411 | return False |
---|
| 412 | |
---|
[13935] | 413 | |
---|
[10060] | 414 | class RevertTransferActionButton(ManageActionButton): |
---|
| 415 | grok.order(1) |
---|
| 416 | grok.context(IStudentStudyCourse) |
---|
| 417 | grok.view(StudyCourseDisplayFormPage) |
---|
| 418 | grok.require('waeup.manageStudent') |
---|
| 419 | icon = 'actionicon_undo.png' |
---|
| 420 | text = _('Reactivate this study course (revert previous transfer)') |
---|
| 421 | target = 'revert_transfer' |
---|
| 422 | |
---|
| 423 | @property |
---|
| 424 | def target_url(self): |
---|
| 425 | if self.context.is_previous: |
---|
| 426 | return self.view.url(self.view.context.__parent__, self.target) |
---|
| 427 | return False |
---|
| 428 | |
---|
[13935] | 429 | |
---|
[8078] | 430 | class StudyLevelManageActionButton(ManageActionButton): |
---|
[7591] | 431 | grok.order(1) |
---|
| 432 | grok.context(IStudentStudyLevel) |
---|
| 433 | grok.view(StudyLevelDisplayFormPage) |
---|
| 434 | grok.require('waeup.manageStudent') |
---|
[7738] | 435 | text = _('Manage') |
---|
[7591] | 436 | target = 'manage' |
---|
| 437 | |
---|
[9138] | 438 | @property |
---|
| 439 | def target_url(self): |
---|
| 440 | is_current = self.context.__parent__.is_current |
---|
| 441 | if not is_current: |
---|
| 442 | return '' |
---|
| 443 | return self.view.url(self.view.context, self.target) |
---|
| 444 | |
---|
[13935] | 445 | |
---|
[7591] | 446 | class StudentValidateCoursesActionButton(ManageActionButton): |
---|
| 447 | grok.order(3) |
---|
| 448 | grok.context(IStudentStudyLevel) |
---|
| 449 | grok.view(StudyLevelDisplayFormPage) |
---|
| 450 | grok.require('waeup.validateStudent') |
---|
[7738] | 451 | text = _('Validate courses') |
---|
[7591] | 452 | target = 'validate_courses' |
---|
| 453 | icon = 'actionicon_accept.png' |
---|
| 454 | |
---|
| 455 | @property |
---|
| 456 | def target_url(self): |
---|
[13935] | 457 | if not self.context.__parent__.is_current: |
---|
[7591] | 458 | return '' |
---|
[13935] | 459 | if self.context.student.state != REGISTERED: |
---|
| 460 | return '' |
---|
| 461 | if str(self.context.__parent__.current_level) != self.context.__name__: |
---|
| 462 | return '' |
---|
[7591] | 463 | return self.view.url(self.view.context, self.target) |
---|
| 464 | |
---|
[13935] | 465 | |
---|
[7591] | 466 | class StudentRejectCoursesActionButton(ManageActionButton): |
---|
| 467 | grok.order(4) |
---|
| 468 | grok.context(IStudentStudyLevel) |
---|
| 469 | grok.view(StudyLevelDisplayFormPage) |
---|
| 470 | grok.require('waeup.validateStudent') |
---|
[7738] | 471 | text = _('Reject courses') |
---|
[7591] | 472 | target = 'reject_courses' |
---|
| 473 | icon = 'actionicon_reject.png' |
---|
| 474 | |
---|
| 475 | @property |
---|
| 476 | def target_url(self): |
---|
[13935] | 477 | if not self.context.__parent__.is_current: |
---|
[7591] | 478 | return '' |
---|
[13935] | 479 | if self.context.student.state not in (VALIDATED, REGISTERED): |
---|
| 480 | return '' |
---|
| 481 | if str(self.context.__parent__.current_level) != self.context.__name__: |
---|
| 482 | return '' |
---|
[7591] | 483 | return self.view.url(self.view.context, self.target) |
---|
| 484 | |
---|
[13935] | 485 | |
---|
[13610] | 486 | class StudentUnregisterCoursesActionButton(ManageActionButton): |
---|
[8078] | 487 | grok.order(5) |
---|
| 488 | grok.context(IStudentStudyLevel) |
---|
| 489 | grok.view(StudyLevelDisplayFormPage) |
---|
[13610] | 490 | grok.require('waeup.handleStudent') |
---|
| 491 | text = _('Unregister courses') |
---|
| 492 | target = 'unregister_courses' |
---|
| 493 | icon = 'actionicon_reject.png' |
---|
| 494 | |
---|
| 495 | @property |
---|
[15820] | 496 | def onclick(self): |
---|
| 497 | return "return window.confirm(%s);" % _( |
---|
| 498 | "'You really want to unregister your course list?'") |
---|
| 499 | |
---|
| 500 | @property |
---|
[13610] | 501 | def target_url(self): |
---|
[13935] | 502 | if not self.context.__parent__.is_current: |
---|
[13610] | 503 | return '' |
---|
[13935] | 504 | if self.context.student.state != REGISTERED: |
---|
| 505 | return '' |
---|
| 506 | if str(self.context.__parent__.current_level) != self.context.__name__: |
---|
| 507 | return '' |
---|
[13610] | 508 | return self.view.url(self.view.context, self.target) |
---|
| 509 | |
---|
[13935] | 510 | |
---|
[13610] | 511 | class CourseRegistrationSlipActionButton(ManageActionButton): |
---|
| 512 | grok.order(6) |
---|
| 513 | grok.context(IStudentStudyLevel) |
---|
| 514 | grok.view(StudyLevelDisplayFormPage) |
---|
[8078] | 515 | grok.require('waeup.viewStudent') |
---|
| 516 | icon = 'actionicon_pdf.png' |
---|
| 517 | text = _('Download course registration slip') |
---|
[9452] | 518 | target = 'course_registration_slip.pdf' |
---|
[8078] | 519 | |
---|
[9138] | 520 | @property |
---|
| 521 | def target_url(self): |
---|
| 522 | is_current = self.context.__parent__.is_current |
---|
| 523 | if not is_current: |
---|
| 524 | return '' |
---|
| 525 | return self.view.url(self.view.context, self.target) |
---|
| 526 | |
---|
[13935] | 527 | |
---|
[7591] | 528 | class CourseTicketManageActionButton(ManageActionButton): |
---|
| 529 | grok.order(1) |
---|
| 530 | grok.context(ICourseTicket) |
---|
| 531 | grok.view(CourseTicketDisplayFormPage) |
---|
| 532 | grok.require('waeup.manageStudent') |
---|
[7738] | 533 | text = _('Manage') |
---|
[7591] | 534 | target = 'manage' |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | class PaymentReceiptActionButton(ManageActionButton): |
---|
[13935] | 538 | grok.order(9) # This button should always be the last one. |
---|
[7591] | 539 | grok.context(IStudentOnlinePayment) |
---|
| 540 | grok.view(OnlinePaymentDisplayFormPage) |
---|
| 541 | grok.require('waeup.viewStudent') |
---|
| 542 | icon = 'actionicon_pdf.png' |
---|
[8262] | 543 | text = _('Download payment slip') |
---|
| 544 | target = 'payment_slip.pdf' |
---|
[7591] | 545 | |
---|
| 546 | @property |
---|
| 547 | def target_url(self): |
---|
[8262] | 548 | #if self.context.p_state != 'paid': |
---|
| 549 | # return '' |
---|
[7591] | 550 | return self.view.url(self.view.context, self.target) |
---|
| 551 | |
---|
[13935] | 552 | |
---|
[8420] | 553 | class ApprovePaymentActionButton(ManageActionButton): |
---|
[17217] | 554 | grok.order(20) |
---|
[7591] | 555 | grok.context(IStudentOnlinePayment) |
---|
| 556 | grok.view(OnlinePaymentDisplayFormPage) |
---|
[8420] | 557 | grok.require('waeup.managePortal') |
---|
[8435] | 558 | icon = 'actionicon_accept.png' |
---|
[8420] | 559 | text = _('Approve payment') |
---|
| 560 | target = 'approve' |
---|
[7591] | 561 | |
---|
| 562 | @property |
---|
| 563 | def target_url(self): |
---|
[15843] | 564 | if self.context.p_state in ('paid', 'waived', 'scholarship'): |
---|
[7591] | 565 | return '' |
---|
| 566 | return self.view.url(self.view.context, self.target) |
---|
| 567 | |
---|
[13935] | 568 | |
---|
[7591] | 569 | class BedTicketSlipActionButton(ManageActionButton): |
---|
| 570 | grok.order(1) |
---|
| 571 | grok.context(IBedTicket) |
---|
| 572 | grok.view(BedTicketDisplayFormPage) |
---|
[15972] | 573 | grok.require('waeup.viewStudent') |
---|
[7591] | 574 | icon = 'actionicon_pdf.png' |
---|
[7738] | 575 | text = _('Download bed allocation slip') |
---|
[9452] | 576 | target = 'bed_allocation_slip.pdf' |
---|
[7591] | 577 | |
---|
[13935] | 578 | |
---|
[7591] | 579 | class RelocateStudentActionButton(ManageActionButton): |
---|
| 580 | grok.order(2) |
---|
| 581 | grok.context(IBedTicket) |
---|
| 582 | grok.view(BedTicketDisplayFormPage) |
---|
| 583 | grok.require('waeup.manageHostels') |
---|
| 584 | icon = 'actionicon_reload.png' |
---|
[7738] | 585 | text = _('Relocate student') |
---|
[7591] | 586 | target = 'relocate' |
---|
| 587 | |
---|
[13935] | 588 | |
---|
[7591] | 589 | class StudentBaseActionButton(ManageActionButton): |
---|
| 590 | grok.order(1) |
---|
| 591 | grok.context(IStudent) |
---|
| 592 | grok.view(StudentBaseDisplayFormPage) |
---|
| 593 | grok.require('waeup.handleStudent') |
---|
[7876] | 594 | text = _('Edit') |
---|
[7591] | 595 | target = 'edit_base' |
---|
| 596 | |
---|
[13935] | 597 | |
---|
[7591] | 598 | class StudentPasswordActionButton(ManageActionButton): |
---|
| 599 | grok.order(2) |
---|
| 600 | grok.context(IStudent) |
---|
| 601 | grok.view(StudentBaseDisplayFormPage) |
---|
| 602 | grok.require('waeup.handleStudent') |
---|
| 603 | icon = 'actionicon_key.png' |
---|
[7738] | 604 | text = _('Change password') |
---|
[7591] | 605 | target = 'change_password' |
---|
| 606 | |
---|
[13935] | 607 | |
---|
[7591] | 608 | class StudentPassportActionButton(ManageActionButton): |
---|
| 609 | grok.order(3) |
---|
| 610 | grok.context(IStudent) |
---|
| 611 | grok.view(StudentBaseDisplayFormPage) |
---|
| 612 | grok.require('waeup.handleStudent') |
---|
| 613 | icon = 'actionicon_portrait.png' |
---|
[7738] | 614 | text = _('Change portrait') |
---|
[7591] | 615 | target = 'change_portrait' |
---|
| 616 | |
---|
| 617 | @property |
---|
| 618 | def target_url(self): |
---|
[16671] | 619 | if not getUtility(IStudentsUtils).allowPortraitChange(self.context): |
---|
[7591] | 620 | return '' |
---|
| 621 | return self.view.url(self.view.context, self.target) |
---|
| 622 | |
---|
[16609] | 623 | class StudentSignatureActionButton(ManageActionButton): |
---|
| 624 | grok.order(4) |
---|
| 625 | grok.context(IStudent) |
---|
| 626 | grok.view(StudentBaseDisplayFormPage) |
---|
| 627 | grok.require('waeup.handleStudent') |
---|
| 628 | icon = 'actionicon_signature.png' |
---|
[16610] | 629 | text = _('Upload signature') |
---|
[16609] | 630 | target = 'change_signature' |
---|
[13935] | 631 | |
---|
[16609] | 632 | @property |
---|
| 633 | def target_url(self): |
---|
| 634 | SIGNATURE_CHANGE_STATES = getUtility( |
---|
| 635 | IStudentsUtils).SIGNATURE_CHANGE_STATES |
---|
| 636 | if self.context.state not in SIGNATURE_CHANGE_STATES: |
---|
| 637 | return '' |
---|
| 638 | return self.view.url(self.view.context, self.target) |
---|
| 639 | |
---|
[17867] | 640 | class StudentFinalClearanceFormActionButton(ManageActionButton): |
---|
| 641 | grok.order(5) |
---|
| 642 | grok.context(IStudent) |
---|
| 643 | grok.view(StudentBaseDisplayFormPage) |
---|
| 644 | grok.require('waeup.handleStudent') |
---|
| 645 | icon = 'actionicon_signature.png' |
---|
| 646 | text = _('Upload final clearance routing slip') |
---|
| 647 | target = 'routing_slip_upload' |
---|
[16609] | 648 | |
---|
[17867] | 649 | @property |
---|
| 650 | def target_url(self): |
---|
| 651 | final_clearance_enabled = getUtility( |
---|
| 652 | IStudentsUtils).final_clearance_enabled(self.context) |
---|
| 653 | if not final_clearance_enabled: |
---|
| 654 | return '' |
---|
| 655 | return self.view.url(self.view.context, self.target) |
---|
| 656 | |
---|
| 657 | |
---|
[7591] | 658 | class StudentClearanceStartActionButton(ManageActionButton): |
---|
| 659 | grok.order(1) |
---|
| 660 | grok.context(IStudent) |
---|
| 661 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 662 | grok.require('waeup.handleStudent') |
---|
| 663 | icon = 'actionicon_start.gif' |
---|
[7738] | 664 | text = _('Start clearance') |
---|
[7591] | 665 | target = 'start_clearance' |
---|
| 666 | |
---|
| 667 | @property |
---|
| 668 | def target_url(self): |
---|
[7671] | 669 | if self.context.state != ADMITTED: |
---|
[7591] | 670 | return '' |
---|
| 671 | return self.view.url(self.view.context, self.target) |
---|
| 672 | |
---|
[13935] | 673 | |
---|
[7591] | 674 | class StudentClearanceEditActionButton(ManageActionButton): |
---|
| 675 | grok.order(1) |
---|
| 676 | grok.context(IStudent) |
---|
| 677 | grok.view(StudentClearanceDisplayFormPage) |
---|
| 678 | grok.require('waeup.handleStudent') |
---|
[7738] | 679 | text = _('Edit') |
---|
[7591] | 680 | target = 'cedit' |
---|
| 681 | |
---|
| 682 | @property |
---|
| 683 | def target_url(self): |
---|
| 684 | if self.context.clearance_locked: |
---|
| 685 | return '' |
---|
| 686 | return self.view.url(self.view.context, self.target) |
---|
| 687 | |
---|
[13935] | 688 | |
---|
[8476] | 689 | class StartSessionActionButton(ManageActionButton): |
---|
[7591] | 690 | grok.order(1) |
---|
| 691 | grok.context(IStudentStudyCourse) |
---|
| 692 | grok.view(StudyCourseDisplayFormPage) |
---|
| 693 | grok.require('waeup.handleStudent') |
---|
| 694 | icon = 'actionicon_start.gif' |
---|
[8920] | 695 | text = _('Start new session') |
---|
[8471] | 696 | target = 'start_session' |
---|
[7591] | 697 | |
---|
| 698 | @property |
---|
| 699 | def target_url(self): |
---|
[9138] | 700 | if self.context.next_session_allowed and self.context.is_current: |
---|
[8471] | 701 | return self.view.url(self.view.context, self.target) |
---|
| 702 | return False |
---|
[7591] | 703 | |
---|
[13935] | 704 | |
---|
[7591] | 705 | class AddStudyLevelActionButton(AddActionButton): |
---|
| 706 | grok.order(1) |
---|
| 707 | grok.context(IStudentStudyCourse) |
---|
| 708 | grok.view(StudyCourseDisplayFormPage) |
---|
| 709 | grok.require('waeup.handleStudent') |
---|
[7738] | 710 | text = _('Add course list') |
---|
[7591] | 711 | target = 'add' |
---|
| 712 | |
---|
| 713 | @property |
---|
| 714 | def target_url(self): |
---|
[8736] | 715 | student = self.view.context.student |
---|
[7671] | 716 | condition1 = student.state != PAID |
---|
[7591] | 717 | condition2 = str(student['studycourse'].current_level) in \ |
---|
| 718 | self.view.context.keys() |
---|
[9138] | 719 | condition3 = not self.context.is_current |
---|
| 720 | if condition1 or condition2 or condition3: |
---|
[7591] | 721 | return '' |
---|
| 722 | return self.view.url(self.view.context, self.target) |
---|
| 723 | |
---|
[13935] | 724 | |
---|
[7591] | 725 | class StudyLevelEditActionButton(ManageActionButton): |
---|
[8078] | 726 | grok.order(2) |
---|
[7591] | 727 | grok.context(IStudentStudyLevel) |
---|
| 728 | grok.view(StudyLevelDisplayFormPage) |
---|
[9924] | 729 | grok.require('waeup.editStudyLevel') |
---|
[8920] | 730 | text = _('Edit course list') |
---|
[7591] | 731 | target = 'edit' |
---|
| 732 | |
---|
| 733 | @property |
---|
| 734 | def target_url(self): |
---|
[8736] | 735 | student = self.view.context.student |
---|
[9257] | 736 | condition1 = student.state == PAID |
---|
| 737 | condition2 = self.view.context.is_current_level |
---|
[9138] | 738 | is_current = self.context.__parent__.is_current |
---|
[9257] | 739 | if condition1 and condition2 and is_current: |
---|
| 740 | return self.view.url(self.view.context, self.target) |
---|
| 741 | return '' |
---|
[7591] | 742 | |
---|
[13935] | 743 | |
---|
[9517] | 744 | class AddPaymentActionButton(AddActionButton): |
---|
| 745 | grok.order(1) |
---|
| 746 | grok.context(IStudentPaymentsContainer) |
---|
| 747 | grok.view(PaymentsManageFormPage) |
---|
| 748 | grok.require('waeup.payStudent') |
---|
| 749 | text = _('Add current session payment ticket') |
---|
| 750 | target = 'addop' |
---|
| 751 | |
---|
[13935] | 752 | |
---|
[9517] | 753 | class AddPreviousPaymentActionButton(AddActionButton): |
---|
| 754 | grok.order(2) |
---|
| 755 | grok.context(IStudentPaymentsContainer) |
---|
| 756 | grok.view(PaymentsManageFormPage) |
---|
| 757 | grok.require('waeup.payStudent') |
---|
[10811] | 758 | grok.name('addpreviouspaymentactionbutton') |
---|
[9517] | 759 | text = _('Add previous session payment ticket') |
---|
| 760 | target = 'addpp' |
---|
| 761 | |
---|
| 762 | @property |
---|
| 763 | def target_url(self): |
---|
| 764 | student = self.view.context.student |
---|
[10811] | 765 | if student.before_payment or not self.target: |
---|
[9517] | 766 | return '' |
---|
| 767 | return self.view.url(self.view.context, self.target) |
---|
| 768 | |
---|
[13935] | 769 | |
---|
[9865] | 770 | class AddBalancePaymentActionButton(AddActionButton): |
---|
| 771 | grok.order(3) |
---|
| 772 | grok.context(IStudentPaymentsContainer) |
---|
| 773 | grok.view(PaymentsManageFormPage) |
---|
[9938] | 774 | grok.require('waeup.manageStudent') |
---|
[10810] | 775 | grok.name('addbalancepaymentactionbutton') |
---|
[9865] | 776 | text = _('Add balance payment ticket') |
---|
| 777 | target = 'addbp' |
---|
| 778 | |
---|
| 779 | @property |
---|
| 780 | def target_url(self): |
---|
[10810] | 781 | if not self.target: |
---|
| 782 | return '' |
---|
[9865] | 783 | return self.view.url(self.view.context, self.target) |
---|
| 784 | |
---|
[13935] | 785 | |
---|
[15163] | 786 | class StudyCourseTranscriptActionButton(ManageActionButton): |
---|
| 787 | grok.order(2) |
---|
| 788 | grok.name('transcript') |
---|
| 789 | grok.context(IStudentStudyCourse) |
---|
| 790 | grok.view(StudyCourseDisplayFormPage) |
---|
| 791 | grok.require('waeup.viewTranscript') |
---|
| 792 | text = _('Transcript') |
---|
| 793 | target = 'transcript' |
---|
| 794 | icon = 'actionicon_transcript.png' |
---|
| 795 | |
---|
| 796 | @property |
---|
| 797 | def target_url(self): |
---|
| 798 | final_slip = getUtility(IExtFileStore).getFileByContext( |
---|
| 799 | self.context.student, attr='final_transcript') |
---|
| 800 | if self.context.student.transcript_enabled and not final_slip: |
---|
| 801 | return self.view.url(self.view.context, self.target) |
---|
| 802 | return False |
---|
| 803 | |
---|
| 804 | |
---|
[10458] | 805 | class RequestTranscriptActionButton(ManageActionButton): |
---|
| 806 | grok.order(8) |
---|
| 807 | grok.context(IStudent) |
---|
| 808 | grok.view(StudentBaseDisplayFormPage) |
---|
| 809 | grok.require('waeup.handleStudent') |
---|
| 810 | text = _('Request transcript') |
---|
| 811 | target = 'request_transcript' |
---|
| 812 | icon = 'actionicon_transcript.png' |
---|
| 813 | |
---|
| 814 | @property |
---|
| 815 | def target_url(self): |
---|
| 816 | if self.context.state != GRADUATED: |
---|
| 817 | return '' |
---|
| 818 | return self.view.url(self.view.context, self.target) |
---|
| 819 | |
---|
[16120] | 820 | class TORequestTranscriptActionButton(RequestTranscriptActionButton): |
---|
| 821 | grok.require('waeup.processTranscript') |
---|
| 822 | text = _('Request transcript for student') |
---|
| 823 | target = 'request_transcript_for_student' |
---|
[13935] | 824 | |
---|
[16120] | 825 | |
---|
[15163] | 826 | class ValidateTranscriptActionButton(ManageActionButton): |
---|
| 827 | grok.order(8) |
---|
| 828 | grok.context(IStudentStudyCourse) |
---|
| 829 | grok.view(StudyCourseTranscriptPage) |
---|
| 830 | grok.require('waeup.processTranscript') |
---|
| 831 | text = _('Validate transcript') |
---|
| 832 | target = 'validate_transcript' |
---|
| 833 | icon = 'actionicon_transcript.png' |
---|
| 834 | |
---|
| 835 | @property |
---|
| 836 | def target_url(self): |
---|
| 837 | if self.context.student.state != TRANSREQ: |
---|
| 838 | return '' |
---|
| 839 | return self.view.url(self.view.context, self.target) |
---|
| 840 | |
---|
| 841 | |
---|
| 842 | class ReleaseTranscriptActionButton(ManageActionButton): |
---|
| 843 | grok.order(8) |
---|
| 844 | grok.context(IStudentStudyCourse) |
---|
| 845 | grok.view(StudyCourseTranscriptPage) |
---|
| 846 | grok.require('waeup.processTranscript') |
---|
| 847 | text = _('Release transcript') |
---|
| 848 | target = 'release_transcript' |
---|
| 849 | icon = 'actionicon_transcript.png' |
---|
| 850 | |
---|
| 851 | @property |
---|
| 852 | def target_url(self): |
---|
| 853 | if self.context.student.state != TRANSVAL: |
---|
| 854 | return '' |
---|
| 855 | return self.view.url(self.view.context, self.target) |
---|
| 856 | |
---|
| 857 | |
---|
| 858 | class TranscriptSlipActionButton(ManageActionButton): |
---|
| 859 | grok.order(1) |
---|
| 860 | grok.name('transcript_slip') |
---|
| 861 | grok.context(IStudentStudyCourse) |
---|
| 862 | grok.view(StudyCourseTranscriptPage) |
---|
[16170] | 863 | grok.require('waeup.downloadTranscript') |
---|
[15163] | 864 | text = _('Academic Transcript') |
---|
| 865 | target = 'transcript.pdf' |
---|
| 866 | icon = 'actionicon_pdf.png' |
---|
| 867 | |
---|
| 868 | @property |
---|
| 869 | def target_url(self): |
---|
| 870 | final_slip = getUtility(IExtFileStore).getFileByContext( |
---|
| 871 | self.context.student, attr='final_transcript') |
---|
| 872 | if self.context.student.transcript_enabled \ |
---|
| 873 | and not final_slip: |
---|
| 874 | return self.view.url(self.view.context, self.target) |
---|
| 875 | return False |
---|
| 876 | |
---|
| 877 | |
---|
| 878 | class SignTranscriptActionButton(ManageActionButton): |
---|
| 879 | grok.order(2) |
---|
| 880 | grok.context(IStudentStudyCourse) |
---|
| 881 | grok.view(StudyCourseTranscriptPage) |
---|
| 882 | grok.require('waeup.signTranscript') |
---|
| 883 | text = _('Sign transcript electronically') |
---|
| 884 | target = 'sign_transcript' |
---|
[10458] | 885 | icon = 'actionicon_transcript.png' |
---|
| 886 | |
---|
| 887 | @property |
---|
| 888 | def target_url(self): |
---|
[15163] | 889 | if self.context.student.state != TRANSVAL: |
---|
[10458] | 890 | return '' |
---|
| 891 | return self.view.url(self.view.context, self.target) |
---|
| 892 | |
---|
[15163] | 893 | @property |
---|
| 894 | def onclick(self): |
---|
| 895 | return "return window.confirm(%s);" % _( |
---|
| 896 | "'Signing a transcript electronically cannot be revoked. " |
---|
| 897 | "The electronic signature replaces your handwritten signature.\\n\\n" |
---|
| 898 | "You really want to sign the transcript?'") |
---|
[13935] | 899 | |
---|
[15163] | 900 | |
---|
[7184] | 901 | class StudentsTab(PrimaryNavTab): |
---|
| 902 | """Students tab in primary navigation. |
---|
| 903 | """ |
---|
[7819] | 904 | grok.context(IKofaObject) |
---|
[7184] | 905 | grok.order(4) |
---|
[12843] | 906 | grok.require('waeup.viewStudentsContainer') |
---|
[10771] | 907 | grok.name('studentstab') |
---|
[7184] | 908 | |
---|
| 909 | pnav = 4 |
---|
[7674] | 910 | tab_title = _(u'Students') |
---|
[7184] | 911 | |
---|
| 912 | @property |
---|
| 913 | def link_target(self): |
---|
| 914 | return self.view.application_url('students') |
---|
| 915 | |
---|
[13935] | 916 | |
---|
[6687] | 917 | class PrimaryStudentNavManager(grok.ViewletManager): |
---|
| 918 | """Viewlet manager for the primary navigation tab. |
---|
| 919 | """ |
---|
| 920 | grok.name('primary_nav_student') |
---|
| 921 | |
---|
[13935] | 922 | |
---|
[6687] | 923 | class PrimaryStudentNavTab(grok.Viewlet): |
---|
| 924 | """Base for primary student nav tabs. |
---|
| 925 | """ |
---|
| 926 | grok.baseclass() |
---|
[10816] | 927 | grok.context(IKofaObject) |
---|
[6687] | 928 | grok.viewletmanager(PrimaryStudentNavManager) |
---|
[7243] | 929 | template = default_primary_nav_template |
---|
[6687] | 930 | grok.order(1) |
---|
[7184] | 931 | grok.require('waeup.Authenticated') |
---|
[8467] | 932 | pnav = 0 |
---|
[6687] | 933 | tab_title = u'Some Text' |
---|
| 934 | |
---|
| 935 | @property |
---|
| 936 | def link_target(self): |
---|
| 937 | return self.view.application_url() |
---|
| 938 | |
---|
| 939 | @property |
---|
| 940 | def active(self): |
---|
| 941 | view_pnav = getattr(self.view, 'pnav', 0) |
---|
| 942 | if view_pnav == self.pnav: |
---|
| 943 | return 'active' |
---|
| 944 | return '' |
---|
| 945 | |
---|
[13935] | 946 | |
---|
[7240] | 947 | class MyStudentDataTab(PrimaryStudentNavTab): |
---|
[7459] | 948 | """MyData dropdown tab in primary navigation. |
---|
[6687] | 949 | """ |
---|
| 950 | grok.order(3) |
---|
[7240] | 951 | grok.require('waeup.viewMyStudentDataTab') |
---|
[7459] | 952 | grok.template('mydatadropdowntabs') |
---|
[10816] | 953 | grok.name('mystudentdatatab') |
---|
[6687] | 954 | pnav = 4 |
---|
[7738] | 955 | tab_title = _(u'My Data') |
---|
[6687] | 956 | |
---|
| 957 | @property |
---|
[7459] | 958 | def active(self): |
---|
| 959 | view_pnav = getattr(self.view, 'pnav', 0) |
---|
| 960 | if view_pnav == self.pnav: |
---|
| 961 | return 'active dropdown' |
---|
| 962 | return 'dropdown' |
---|
[7097] | 963 | |
---|
[7459] | 964 | @property |
---|
| 965 | def targets(self): |
---|
[9180] | 966 | student = grok.getSite()['students'][self.request.principal.id] |
---|
| 967 | student_url = self.view.url(student) |
---|
[9178] | 968 | app_slip = getUtility(IExtFileStore).getFileByContext( |
---|
[9180] | 969 | student, 'application_slip') |
---|
[7459] | 970 | targets = [] |
---|
[15606] | 971 | if student.getParentsPassword(): |
---|
| 972 | targets += [ |
---|
| 973 | {'url': student_url, 'title': 'Base Data'}, |
---|
| 974 | {'url': student_url + '/studycourse', 'title': _('Study Course')}, |
---|
| 975 | {'url': student_url + '/payments', 'title': _('Payments')}, |
---|
| 976 | ] |
---|
| 977 | return targets |
---|
[9178] | 978 | if app_slip: |
---|
[13935] | 979 | targets = [{'url': student_url + '/application_slip', |
---|
| 980 | 'title': _('Application Slip')}, ] |
---|
[7459] | 981 | targets += [ |
---|
[13935] | 982 | {'url': student_url, 'title': 'Base Data'}, |
---|
| 983 | {'url': student_url + '/view_clearance', |
---|
| 984 | 'title': _('Clearance Data')}, |
---|
| 985 | {'url': student_url + '/view_personal', |
---|
| 986 | 'title': _('Personal Data')}, |
---|
| 987 | {'url': student_url + '/studycourse', 'title': _('Study Course')}, |
---|
| 988 | {'url': student_url + '/payments', 'title': _('Payments')}, |
---|
| 989 | {'url': student_url + '/accommodation', |
---|
| 990 | 'title': _('Accommodation Data')}, |
---|
| 991 | {'url': student_url + '/history', 'title': _('History')}, |
---|
[7459] | 992 | ] |
---|
| 993 | return targets |
---|