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