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