source: main/waeup.kofa/branches/henrik-transcript-workflow/src/waeup/kofa/students/viewlets.py @ 17937

Last change on this file since 17937 was 15155, checked in by Henrik Bettermann, 6 years ago

Reorganise interfaces.

Transcript processing views and viewlets are now in the context of studycourses. Officers can now validate, sign and release transcripts directly on the transcript page.

  • Property svn:keywords set to Id
File size: 28.5 KB
Line 
1## $Id: viewlets.py 15155 2018-09-20 07:04:17Z 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##
18import grok
19from zope.component import getUtility
20from zope.i18n import translate
21from zope.interface import Interface
22from waeup.kofa.browser.layout import default_primary_nav_template
23from waeup.kofa.browser.viewlets import (
24    PrimaryNavTab, ManageActionButton, AddActionButton)
25from waeup.kofa.interfaces import MessageFactory as _
26from waeup.kofa.interfaces import IExtFileStore, IKofaObject
27from 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, EditScoresPage)
35from waeup.kofa.students.interfaces import (
36    IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel,
37    ICourseTicket, IStudentOnlinePayment, IBedTicket,
38    IStudentPaymentsContainer, IStudentsUtils,
39    )
40from waeup.kofa.students.workflow import (
41    ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED,
42    TRANSREQ, TRANSVAL, TRANSREL)
43from waeup.kofa.university.interfaces import ICourse
44
45
46grok.context(IKofaObject)  # Make IKofaObject the default context
47grok.templatedir('browser_templates')
48
49
50class StudentManageSidebar(grok.ViewletManager):
51    grok.name('left_studentmanage')
52
53
54class 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
81class 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
98class StudentManageBaseLink(StudentManageLink):
99    grok.order(2)
100    link = 'index'
101    text = _(u'Base Data')
102
103
104class StudentManageClearanceLink(StudentManageLink):
105    grok.order(3)
106    grok.name('studentmanageclearancelink')
107    link = 'view_clearance'
108    text = _(u'Clearance Data')
109
110
111class StudentManagePersonalLink(StudentManageLink):
112    grok.order(4)
113    grok.name('studentmanagepersonallink')
114    link = 'view_personal'
115    text = _(u'Personal Data')
116
117
118class StudentManageStudyCourseLink(StudentManageLink):
119    grok.order(5)
120    link = 'studycourse'
121    text = _(u'Study Course')
122
123
124class StudentManagePaymentsLink(StudentManageLink):
125    grok.order(6)
126    grok.require('waeup.viewStudent')
127    link = 'payments'
128    text = _(u'Payments')
129
130
131class StudentManageAccommodationLink(StudentManageLink):
132    grok.order(7)
133    grok.name('studentmanageaccommodationlink')
134    grok.require('waeup.handleAccommodation')
135    link = 'accommodation'
136    text = _(u'Accommodation')
137
138
139class StudentManageHistoryLink(StudentManageLink):
140    grok.order(8)
141    link = 'history'
142    text = _(u'History')
143
144
145class 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
163class 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
171class 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
180class ContactActionButton(ManageActionButton):
181    grok.order(5)
182    grok.context(IStudent)
183    grok.view(StudentBaseDisplayFormPage)
184    grok.require('waeup.manageStudent')
185    icon = 'actionicon_mail.png'
186    text = _('Send email')
187    target = 'contactstudent'
188
189
190class 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
199class 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
209class 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
219class 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
229class 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
239class 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
260class 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
281class 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
290class 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
310class StudentRejectClearanceActionButton(ManageActionButton):
311    grok.order(3)
312    grok.context(IStudent)
313    grok.view(StudentClearanceDisplayFormPage)
314    grok.require('waeup.clearStudent')
315    text = _('Reject clearance')
316    target = 'reject_clearance'
317    icon = 'actionicon_reject.png'
318
319    @property
320    def target_url(self):
321        cdm = getUtility(
322            IStudentsUtils).clearance_disabled_message(self.context)
323        if cdm:
324            return ''
325        if self.context.state not in (REQUESTED, CLEARED):
326            return ''
327        return self.view.url(self.view.context, self.target)
328
329
330class ClearanceSlipActionButton(ManageActionButton):
331    grok.order(4)
332    grok.context(IStudent)
333    grok.view(StudentClearanceDisplayFormPage)
334    grok.require('waeup.viewStudent')
335    icon = 'actionicon_pdf.png'
336    text = _('Download clearance slip')
337    target = 'clearance_slip.pdf'
338
339
340class ClearanceViewActionButton(ManageActionButton):
341    grok.order(1)
342    grok.context(IStudent)
343    grok.view(StudentClearanceEditFormPage)
344    grok.require('waeup.viewStudent')
345    icon = 'actionicon_view.png'
346    text = _('View')
347    target = 'view_clearance'
348
349
350class PersonalViewActionButton(ManageActionButton):
351    grok.order(1)
352    grok.context(IStudent)
353    grok.view(StudentPersonalEditFormPage)
354    grok.require('waeup.viewStudent')
355    icon = 'actionicon_view.png'
356    text = _('View')
357    target = 'view_personal'
358
359
360class StudentPersonalManageActionButton(ManageActionButton):
361    grok.order(1)
362    grok.context(IStudent)
363    grok.view(StudentPersonalDisplayFormPage)
364    grok.require('waeup.manageStudent')
365    text = _('Manage')
366    target = 'manage_personal'
367
368
369class StudentPersonalEditActionButton(ManageActionButton):
370    grok.order(2)
371    grok.context(IStudent)
372    grok.view(StudentPersonalDisplayFormPage)
373    grok.require('waeup.handleStudent')
374    text = _('Edit')
375    target = 'edit_personal'
376
377
378class StudyCourseManageActionButton(ManageActionButton):
379    grok.order(1)
380    grok.context(IStudentStudyCourse)
381    grok.view(StudyCourseDisplayFormPage)
382    grok.require('waeup.manageStudent')
383    text = _('Manage')
384    target = 'manage'
385
386    @property
387    def target_url(self):
388        if self.context.is_current:
389            return self.view.url(self.view.context, self.target)
390        return False
391
392
393class RevertTransferActionButton(ManageActionButton):
394    grok.order(1)
395    grok.context(IStudentStudyCourse)
396    grok.view(StudyCourseDisplayFormPage)
397    grok.require('waeup.manageStudent')
398    icon = 'actionicon_undo.png'
399    text = _('Reactivate this study course (revert previous transfer)')
400    target = 'revert_transfer'
401
402    @property
403    def target_url(self):
404        if self.context.is_previous:
405            return self.view.url(self.view.context.__parent__, self.target)
406        return False
407
408
409class StudyLevelManageActionButton(ManageActionButton):
410    grok.order(1)
411    grok.context(IStudentStudyLevel)
412    grok.view(StudyLevelDisplayFormPage)
413    grok.require('waeup.manageStudent')
414    text = _('Manage')
415    target = 'manage'
416
417    @property
418    def target_url(self):
419        is_current = self.context.__parent__.is_current
420        if not is_current:
421            return ''
422        return self.view.url(self.view.context, self.target)
423
424
425class StudentValidateCoursesActionButton(ManageActionButton):
426    grok.order(3)
427    grok.context(IStudentStudyLevel)
428    grok.view(StudyLevelDisplayFormPage)
429    grok.require('waeup.validateStudent')
430    text = _('Validate courses')
431    target = 'validate_courses'
432    icon = 'actionicon_accept.png'
433
434    @property
435    def target_url(self):
436        if not self.context.__parent__.is_current:
437            return ''
438        if self.context.student.state != REGISTERED:
439            return ''
440        if str(self.context.__parent__.current_level) != self.context.__name__:
441            return ''
442        return self.view.url(self.view.context, self.target)
443
444
445class StudentRejectCoursesActionButton(ManageActionButton):
446    grok.order(4)
447    grok.context(IStudentStudyLevel)
448    grok.view(StudyLevelDisplayFormPage)
449    grok.require('waeup.validateStudent')
450    text = _('Reject courses')
451    target = 'reject_courses'
452    icon = 'actionicon_reject.png'
453
454    @property
455    def target_url(self):
456        if not self.context.__parent__.is_current:
457            return ''
458        if self.context.student.state not in (VALIDATED, REGISTERED):
459            return ''
460        if str(self.context.__parent__.current_level) != self.context.__name__:
461            return ''
462        return self.view.url(self.view.context, self.target)
463
464
465class StudentUnregisterCoursesActionButton(ManageActionButton):
466    grok.order(5)
467    grok.context(IStudentStudyLevel)
468    grok.view(StudyLevelDisplayFormPage)
469    grok.require('waeup.handleStudent')
470    text = _('Unregister courses')
471    target = 'unregister_courses'
472    icon = 'actionicon_reject.png'
473
474    @property
475    def target_url(self):
476        if not self.context.__parent__.is_current:
477            return ''
478        if self.context.student.state != REGISTERED:
479            return ''
480        if str(self.context.__parent__.current_level) != self.context.__name__:
481            return ''
482        return self.view.url(self.view.context, self.target)
483
484
485class CourseRegistrationSlipActionButton(ManageActionButton):
486    grok.order(6)
487    grok.context(IStudentStudyLevel)
488    grok.view(StudyLevelDisplayFormPage)
489    grok.require('waeup.viewStudent')
490    icon = 'actionicon_pdf.png'
491    text = _('Download course registration slip')
492    target = 'course_registration_slip.pdf'
493
494    @property
495    def target_url(self):
496        is_current = self.context.__parent__.is_current
497        if not is_current:
498            return ''
499        return self.view.url(self.view.context, self.target)
500
501
502class CourseTicketManageActionButton(ManageActionButton):
503    grok.order(1)
504    grok.context(ICourseTicket)
505    grok.view(CourseTicketDisplayFormPage)
506    grok.require('waeup.manageStudent')
507    text = _('Manage')
508    target = 'manage'
509
510
511class PaymentReceiptActionButton(ManageActionButton):
512    grok.order(9)  # This button should always be the last one.
513    grok.context(IStudentOnlinePayment)
514    grok.view(OnlinePaymentDisplayFormPage)
515    grok.require('waeup.viewStudent')
516    icon = 'actionicon_pdf.png'
517    text = _('Download payment slip')
518    target = 'payment_slip.pdf'
519
520    @property
521    def target_url(self):
522        #if self.context.p_state != 'paid':
523        #    return ''
524        return self.view.url(self.view.context, self.target)
525
526
527class ApprovePaymentActionButton(ManageActionButton):
528    grok.order(8)
529    grok.context(IStudentOnlinePayment)
530    grok.view(OnlinePaymentDisplayFormPage)
531    grok.require('waeup.managePortal')
532    icon = 'actionicon_accept.png'
533    text = _('Approve payment')
534    target = 'approve'
535
536    @property
537    def target_url(self):
538        if self.context.p_state == 'paid':
539            return ''
540        return self.view.url(self.view.context, self.target)
541
542
543class BedTicketSlipActionButton(ManageActionButton):
544    grok.order(1)
545    grok.context(IBedTicket)
546    grok.view(BedTicketDisplayFormPage)
547    grok.require('waeup.handleAccommodation')
548    icon = 'actionicon_pdf.png'
549    text = _('Download bed allocation slip')
550    target = 'bed_allocation_slip.pdf'
551
552
553class RelocateStudentActionButton(ManageActionButton):
554    grok.order(2)
555    grok.context(IBedTicket)
556    grok.view(BedTicketDisplayFormPage)
557    grok.require('waeup.manageHostels')
558    icon = 'actionicon_reload.png'
559    text = _('Relocate student')
560    target = 'relocate'
561
562
563class StudentBaseActionButton(ManageActionButton):
564    grok.order(1)
565    grok.context(IStudent)
566    grok.view(StudentBaseDisplayFormPage)
567    grok.require('waeup.handleStudent')
568    text = _('Edit')
569    target = 'edit_base'
570
571
572class StudentPasswordActionButton(ManageActionButton):
573    grok.order(2)
574    grok.context(IStudent)
575    grok.view(StudentBaseDisplayFormPage)
576    grok.require('waeup.handleStudent')
577    icon = 'actionicon_key.png'
578    text = _('Change password')
579    target = 'change_password'
580
581
582class StudentPassportActionButton(ManageActionButton):
583    grok.order(3)
584    grok.context(IStudent)
585    grok.view(StudentBaseDisplayFormPage)
586    grok.require('waeup.handleStudent')
587    icon = 'actionicon_portrait.png'
588    text = _('Change portrait')
589    target = 'change_portrait'
590
591    @property
592    def target_url(self):
593        PORTRAIT_CHANGE_STATES = getUtility(
594            IStudentsUtils).PORTRAIT_CHANGE_STATES
595        if self.context.state not in PORTRAIT_CHANGE_STATES:
596            return ''
597        return self.view.url(self.view.context, self.target)
598
599
600class StudentClearanceStartActionButton(ManageActionButton):
601    grok.order(1)
602    grok.context(IStudent)
603    grok.view(StudentClearanceDisplayFormPage)
604    grok.require('waeup.handleStudent')
605    icon = 'actionicon_start.gif'
606    text = _('Start clearance')
607    target = 'start_clearance'
608
609    @property
610    def target_url(self):
611        if self.context.state != ADMITTED:
612            return ''
613        return self.view.url(self.view.context, self.target)
614
615
616class StudentClearanceEditActionButton(ManageActionButton):
617    grok.order(1)
618    grok.context(IStudent)
619    grok.view(StudentClearanceDisplayFormPage)
620    grok.require('waeup.handleStudent')
621    text = _('Edit')
622    target = 'cedit'
623
624    @property
625    def target_url(self):
626        if self.context.clearance_locked:
627            return ''
628        return self.view.url(self.view.context, self.target)
629
630
631class StartSessionActionButton(ManageActionButton):
632    grok.order(1)
633    grok.context(IStudentStudyCourse)
634    grok.view(StudyCourseDisplayFormPage)
635    grok.require('waeup.handleStudent')
636    icon = 'actionicon_start.gif'
637    text = _('Start new session')
638    target = 'start_session'
639
640    @property
641    def target_url(self):
642        if self.context.next_session_allowed and self.context.is_current:
643            return self.view.url(self.view.context, self.target)
644        return False
645
646
647class AddStudyLevelActionButton(AddActionButton):
648    grok.order(1)
649    grok.context(IStudentStudyCourse)
650    grok.view(StudyCourseDisplayFormPage)
651    grok.require('waeup.handleStudent')
652    text = _('Add course list')
653    target = 'add'
654
655    @property
656    def target_url(self):
657        student = self.view.context.student
658        condition1 = student.state != PAID
659        condition2 = str(student['studycourse'].current_level) in \
660            self.view.context.keys()
661        condition3 = not self.context.is_current
662        if condition1 or condition2 or condition3:
663            return ''
664        return self.view.url(self.view.context, self.target)
665
666
667class StudyLevelEditActionButton(ManageActionButton):
668    grok.order(2)
669    grok.context(IStudentStudyLevel)
670    grok.view(StudyLevelDisplayFormPage)
671    grok.require('waeup.editStudyLevel')
672    text = _('Edit course list')
673    target = 'edit'
674
675    @property
676    def target_url(self):
677        student = self.view.context.student
678        condition1 = student.state == PAID
679        condition2 = self.view.context.is_current_level
680        is_current = self.context.__parent__.is_current
681        if condition1 and condition2 and is_current:
682            return self.view.url(self.view.context, self.target)
683        return ''
684
685
686class AddPaymentActionButton(AddActionButton):
687    grok.order(1)
688    grok.context(IStudentPaymentsContainer)
689    grok.view(PaymentsManageFormPage)
690    grok.require('waeup.payStudent')
691    text = _('Add current session payment ticket')
692    target = 'addop'
693
694
695class AddPreviousPaymentActionButton(AddActionButton):
696    grok.order(2)
697    grok.context(IStudentPaymentsContainer)
698    grok.view(PaymentsManageFormPage)
699    grok.require('waeup.payStudent')
700    grok.name('addpreviouspaymentactionbutton')
701    text = _('Add previous session payment ticket')
702    target = 'addpp'
703
704    @property
705    def target_url(self):
706        student = self.view.context.student
707        if student.before_payment or not self.target:
708            return ''
709        return self.view.url(self.view.context, self.target)
710
711
712class AddBalancePaymentActionButton(AddActionButton):
713    grok.order(3)
714    grok.context(IStudentPaymentsContainer)
715    grok.view(PaymentsManageFormPage)
716    grok.require('waeup.manageStudent')
717    grok.name('addbalancepaymentactionbutton')
718    text = _('Add balance payment ticket')
719    target = 'addbp'
720
721    @property
722    def target_url(self):
723        if not self.target:
724            return ''
725        return self.view.url(self.view.context, self.target)
726
727
728class StudyCourseTranscriptActionButton(ManageActionButton):
729    grok.order(2)
730    grok.name('transcript')
731    grok.context(IStudentStudyCourse)
732    grok.view(StudyCourseDisplayFormPage)
733    grok.require('waeup.viewTranscript')
734    text = _('Transcript')
735    target = 'transcript'
736    icon = 'actionicon_transcript.png'
737
738    @property
739    def target_url(self):
740        final_slip = getUtility(IExtFileStore).getFileByContext(
741            self.context.student, attr='final_transcript')
742        if self.context.student.transcript_enabled and not final_slip:
743            return self.view.url(self.view.context, self.target)
744        return False
745
746
747class RequestTranscriptActionButton(ManageActionButton):
748    grok.order(8)
749    grok.context(IStudent)
750    grok.view(StudentBaseDisplayFormPage)
751    grok.require('waeup.handleStudent')
752    text = _('Request transcript')
753    target = 'request_transcript'
754    icon = 'actionicon_transcript.png'
755
756    @property
757    def target_url(self):
758        if self.context.state != GRADUATED:
759            return ''
760        return self.view.url(self.view.context, self.target)
761
762
763class ValidateTranscriptActionButton(ManageActionButton):
764    grok.order(8)
765    grok.context(IStudentStudyCourse)
766    grok.view(StudyCourseTranscriptPage)
767    grok.require('waeup.processTranscript')
768    text = _('Validate transcript')
769    target = 'validate_transcript'
770    icon = 'actionicon_transcript.png'
771
772    @property
773    def target_url(self):
774        if self.context.student.state != TRANSREQ:
775            return ''
776        return self.view.url(self.view.context, self.target)
777
778    @property
779    def onclick(self):
780        return "return window.confirm(%s);" % _(
781            "'Course results cannot be changed after transcript "
782            "validation. \\n\\n"
783            "You really want to validate the transcript?'")
784
785
786class ReleaseTranscriptActionButton(ManageActionButton):
787    grok.order(8)
788    grok.context(IStudentStudyCourse)
789    grok.view(StudyCourseTranscriptPage)
790    grok.require('waeup.processTranscript')
791    text = _('Release transcript')
792    target = 'release_transcript'
793    icon = 'actionicon_transcript.png'
794
795    @property
796    def target_url(self):
797        if self.context.student.state != TRANSVAL:
798            return ''
799        return self.view.url(self.view.context, self.target)
800
801
802class TranscriptSlipActionButton(ManageActionButton):
803    grok.order(1)
804    grok.name('transcript_slip')
805    grok.context(IStudentStudyCourse)
806    grok.view(StudyCourseTranscriptPage)
807    grok.require('waeup.viewTranscript')
808    text = _('Academic Transcript')
809    target = 'transcript.pdf'
810    icon = 'actionicon_pdf.png'
811
812    @property
813    def target_url(self):
814        final_slip = getUtility(IExtFileStore).getFileByContext(
815            self.context.student, attr='final_transcript')
816        if self.context.student.transcript_enabled \
817            and not final_slip:
818            return self.view.url(self.view.context, self.target)
819        return False
820
821
822class SignTranscriptActionButton(ManageActionButton):
823    grok.order(2)
824    grok.context(IStudentStudyCourse)
825    grok.view(StudyCourseTranscriptPage)
826    grok.require('waeup.signTranscript')
827    text = _('Sign transcript electronically')
828    target = 'sign_transcript'
829    icon = 'actionicon_transcript.png'
830
831    @property
832    def target_url(self):
833        if self.context.student.state != TRANSVAL:
834            return ''
835        return self.view.url(self.view.context, self.target)
836
837    @property
838    def onclick(self):
839        return "return window.confirm(%s);" % _(
840            "'Signing a transcript electronically cannot be revoked. "
841            "The electronic signature replaces your handwritten signature.\\n\\n"
842            "You really want to sign the transcript?'")
843
844
845class StudentsTab(PrimaryNavTab):
846    """Students tab in primary navigation.
847    """
848    grok.context(IKofaObject)
849    grok.order(4)
850    grok.require('waeup.viewStudentsContainer')
851    grok.name('studentstab')
852
853    pnav = 4
854    tab_title = _(u'Students')
855
856    @property
857    def link_target(self):
858        return self.view.application_url('students')
859
860
861class PrimaryStudentNavManager(grok.ViewletManager):
862    """Viewlet manager for the primary navigation tab.
863    """
864    grok.name('primary_nav_student')
865
866
867class PrimaryStudentNavTab(grok.Viewlet):
868    """Base for primary student nav tabs.
869    """
870    grok.baseclass()
871    grok.context(IKofaObject)
872    grok.viewletmanager(PrimaryStudentNavManager)
873    template = default_primary_nav_template
874    grok.order(1)
875    grok.require('waeup.Authenticated')
876    pnav = 0
877    tab_title = u'Some Text'
878
879    @property
880    def link_target(self):
881        return self.view.application_url()
882
883    @property
884    def active(self):
885        view_pnav = getattr(self.view, 'pnav', 0)
886        if view_pnav == self.pnav:
887            return 'active'
888        return ''
889
890
891class MyStudentDataTab(PrimaryStudentNavTab):
892    """MyData dropdown tab in primary navigation.
893    """
894    grok.order(3)
895    grok.require('waeup.viewMyStudentDataTab')
896    grok.template('mydatadropdowntabs')
897    grok.name('mystudentdatatab')
898    pnav = 4
899    tab_title = _(u'My Data')
900
901    @property
902    def active(self):
903        view_pnav = getattr(self.view, 'pnav', 0)
904        if view_pnav == self.pnav:
905            return 'active dropdown'
906        return 'dropdown'
907
908    @property
909    def targets(self):
910        student = grok.getSite()['students'][self.request.principal.id]
911        student_url = self.view.url(student)
912        app_slip = getUtility(IExtFileStore).getFileByContext(
913            student, 'application_slip')
914        targets = []
915        if app_slip:
916            targets = [{'url': student_url + '/application_slip',
917                        'title': _('Application Slip')}, ]
918        targets += [
919            {'url': student_url, 'title': 'Base Data'},
920            {'url': student_url + '/view_clearance',
921             'title': _('Clearance Data')},
922            {'url': student_url + '/view_personal',
923             'title': _('Personal Data')},
924            {'url': student_url + '/studycourse', 'title': _('Study Course')},
925            {'url': student_url + '/payments', 'title': _('Payments')},
926            {'url': student_url + '/accommodation',
927             'title': _('Accommodation Data')},
928            {'url': student_url + '/history', 'title': _('History')},
929            ]
930        return targets
931
932
933class DownloadCSVFileActionButton(ManageActionButton):
934    """ 'Download csv file' button for courses.
935    """
936    grok.context(ICourse)
937    grok.view(EditScoresPage)
938    grok.name('downloadcsv')
939    grok.require('waeup.editScores')
940    icon = 'actionicon_down.png'
941    text = _('Download csv file (editable scores only)')
942    target = 'download_scores'
943    grok.order(1)
944
945
946class DownloadTicketOverviewActionButton(ManageActionButton):
947    """ 'Download ticket overview' button for courses.
948    """
949    grok.context(ICourse)
950    grok.view(EditScoresPage)
951    grok.name('coursetickets')
952    grok.require('waeup.editScores')
953    icon = 'actionicon_pdf.png'
954    text = _('Download pdf file')
955    target = 'coursetickets.pdf'
956    grok.order(2)
Note: See TracBrowser for help on using the repository browser.