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

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

Implement transcript validation workflow. More tests will follow.

  • Property svn:keywords set to Id
File size: 27.4 KB
Line 
1## $Id: viewlets.py 15140 2018-09-18 05:53:44Z 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, IStudentTranscript
39    )
40from waeup.kofa.students.workflow import (
41    ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED,
42    TRANSREQ, TRANSVAL)
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 StudyCourseTranscriptActionButton(ManageActionButton):
394    grok.order(2)
395    grok.name('transcript')
396    grok.context(IStudentStudyCourse)
397    grok.view(StudyCourseDisplayFormPage)
398    grok.require('waeup.viewTranscript')
399    text = _('Transcript')
400    target = 'transcript'
401    icon = 'actionicon_transcript.png'
402
403    @property
404    def target_url(self):
405        if self.context.student.transcript_enabled:
406            return self.view.url(self.view.context, self.target)
407        return False
408
409
410class TranscriptSlipActionButton(ManageActionButton):
411    grok.order(1)
412    grok.name('transcript_slip')
413    grok.context(IStudentStudyCourse)
414    grok.view(StudyCourseTranscriptPage)
415    grok.require('waeup.viewTranscript')
416    text = _('Academic Transcript')
417    target = 'transcript.pdf'
418    icon = 'actionicon_pdf.png'
419
420    @property
421    def target_url(self):
422        if self.context.student.transcript_enabled:
423            return self.view.url(self.view.context, self.target)
424        return False
425
426
427class RevertTransferActionButton(ManageActionButton):
428    grok.order(1)
429    grok.context(IStudentStudyCourse)
430    grok.view(StudyCourseDisplayFormPage)
431    grok.require('waeup.manageStudent')
432    icon = 'actionicon_undo.png'
433    text = _('Reactivate this study course (revert previous transfer)')
434    target = 'revert_transfer'
435
436    @property
437    def target_url(self):
438        if self.context.is_previous:
439            return self.view.url(self.view.context.__parent__, self.target)
440        return False
441
442
443class StudyLevelManageActionButton(ManageActionButton):
444    grok.order(1)
445    grok.context(IStudentStudyLevel)
446    grok.view(StudyLevelDisplayFormPage)
447    grok.require('waeup.manageStudent')
448    text = _('Manage')
449    target = 'manage'
450
451    @property
452    def target_url(self):
453        is_current = self.context.__parent__.is_current
454        if not is_current:
455            return ''
456        return self.view.url(self.view.context, self.target)
457
458
459class StudentValidateCoursesActionButton(ManageActionButton):
460    grok.order(3)
461    grok.context(IStudentStudyLevel)
462    grok.view(StudyLevelDisplayFormPage)
463    grok.require('waeup.validateStudent')
464    text = _('Validate courses')
465    target = 'validate_courses'
466    icon = 'actionicon_accept.png'
467
468    @property
469    def target_url(self):
470        if not self.context.__parent__.is_current:
471            return ''
472        if self.context.student.state != REGISTERED:
473            return ''
474        if str(self.context.__parent__.current_level) != self.context.__name__:
475            return ''
476        return self.view.url(self.view.context, self.target)
477
478
479class StudentRejectCoursesActionButton(ManageActionButton):
480    grok.order(4)
481    grok.context(IStudentStudyLevel)
482    grok.view(StudyLevelDisplayFormPage)
483    grok.require('waeup.validateStudent')
484    text = _('Reject courses')
485    target = 'reject_courses'
486    icon = 'actionicon_reject.png'
487
488    @property
489    def target_url(self):
490        if not self.context.__parent__.is_current:
491            return ''
492        if self.context.student.state not in (VALIDATED, REGISTERED):
493            return ''
494        if str(self.context.__parent__.current_level) != self.context.__name__:
495            return ''
496        return self.view.url(self.view.context, self.target)
497
498
499class StudentUnregisterCoursesActionButton(ManageActionButton):
500    grok.order(5)
501    grok.context(IStudentStudyLevel)
502    grok.view(StudyLevelDisplayFormPage)
503    grok.require('waeup.handleStudent')
504    text = _('Unregister courses')
505    target = 'unregister_courses'
506    icon = 'actionicon_reject.png'
507
508    @property
509    def target_url(self):
510        if not self.context.__parent__.is_current:
511            return ''
512        if self.context.student.state != REGISTERED:
513            return ''
514        if str(self.context.__parent__.current_level) != self.context.__name__:
515            return ''
516        return self.view.url(self.view.context, self.target)
517
518
519class CourseRegistrationSlipActionButton(ManageActionButton):
520    grok.order(6)
521    grok.context(IStudentStudyLevel)
522    grok.view(StudyLevelDisplayFormPage)
523    grok.require('waeup.viewStudent')
524    icon = 'actionicon_pdf.png'
525    text = _('Download course registration slip')
526    target = 'course_registration_slip.pdf'
527
528    @property
529    def target_url(self):
530        is_current = self.context.__parent__.is_current
531        if not is_current:
532            return ''
533        return self.view.url(self.view.context, self.target)
534
535
536class CourseTicketManageActionButton(ManageActionButton):
537    grok.order(1)
538    grok.context(ICourseTicket)
539    grok.view(CourseTicketDisplayFormPage)
540    grok.require('waeup.manageStudent')
541    text = _('Manage')
542    target = 'manage'
543
544
545class PaymentReceiptActionButton(ManageActionButton):
546    grok.order(9)  # This button should always be the last one.
547    grok.context(IStudentOnlinePayment)
548    grok.view(OnlinePaymentDisplayFormPage)
549    grok.require('waeup.viewStudent')
550    icon = 'actionicon_pdf.png'
551    text = _('Download payment slip')
552    target = 'payment_slip.pdf'
553
554    @property
555    def target_url(self):
556        #if self.context.p_state != 'paid':
557        #    return ''
558        return self.view.url(self.view.context, self.target)
559
560
561class ApprovePaymentActionButton(ManageActionButton):
562    grok.order(8)
563    grok.context(IStudentOnlinePayment)
564    grok.view(OnlinePaymentDisplayFormPage)
565    grok.require('waeup.managePortal')
566    icon = 'actionicon_accept.png'
567    text = _('Approve payment')
568    target = 'approve'
569
570    @property
571    def target_url(self):
572        if self.context.p_state == 'paid':
573            return ''
574        return self.view.url(self.view.context, self.target)
575
576
577class BedTicketSlipActionButton(ManageActionButton):
578    grok.order(1)
579    grok.context(IBedTicket)
580    grok.view(BedTicketDisplayFormPage)
581    grok.require('waeup.handleAccommodation')
582    icon = 'actionicon_pdf.png'
583    text = _('Download bed allocation slip')
584    target = 'bed_allocation_slip.pdf'
585
586
587class RelocateStudentActionButton(ManageActionButton):
588    grok.order(2)
589    grok.context(IBedTicket)
590    grok.view(BedTicketDisplayFormPage)
591    grok.require('waeup.manageHostels')
592    icon = 'actionicon_reload.png'
593    text = _('Relocate student')
594    target = 'relocate'
595
596
597class StudentBaseActionButton(ManageActionButton):
598    grok.order(1)
599    grok.context(IStudent)
600    grok.view(StudentBaseDisplayFormPage)
601    grok.require('waeup.handleStudent')
602    text = _('Edit')
603    target = 'edit_base'
604
605
606class StudentPasswordActionButton(ManageActionButton):
607    grok.order(2)
608    grok.context(IStudent)
609    grok.view(StudentBaseDisplayFormPage)
610    grok.require('waeup.handleStudent')
611    icon = 'actionicon_key.png'
612    text = _('Change password')
613    target = 'change_password'
614
615
616class StudentPassportActionButton(ManageActionButton):
617    grok.order(3)
618    grok.context(IStudent)
619    grok.view(StudentBaseDisplayFormPage)
620    grok.require('waeup.handleStudent')
621    icon = 'actionicon_portrait.png'
622    text = _('Change portrait')
623    target = 'change_portrait'
624
625    @property
626    def target_url(self):
627        PORTRAIT_CHANGE_STATES = getUtility(
628            IStudentsUtils).PORTRAIT_CHANGE_STATES
629        if self.context.state not in PORTRAIT_CHANGE_STATES:
630            return ''
631        return self.view.url(self.view.context, self.target)
632
633
634class StudentClearanceStartActionButton(ManageActionButton):
635    grok.order(1)
636    grok.context(IStudent)
637    grok.view(StudentClearanceDisplayFormPage)
638    grok.require('waeup.handleStudent')
639    icon = 'actionicon_start.gif'
640    text = _('Start clearance')
641    target = 'start_clearance'
642
643    @property
644    def target_url(self):
645        if self.context.state != ADMITTED:
646            return ''
647        return self.view.url(self.view.context, self.target)
648
649
650class StudentClearanceEditActionButton(ManageActionButton):
651    grok.order(1)
652    grok.context(IStudent)
653    grok.view(StudentClearanceDisplayFormPage)
654    grok.require('waeup.handleStudent')
655    text = _('Edit')
656    target = 'cedit'
657
658    @property
659    def target_url(self):
660        if self.context.clearance_locked:
661            return ''
662        return self.view.url(self.view.context, self.target)
663
664
665class StartSessionActionButton(ManageActionButton):
666    grok.order(1)
667    grok.context(IStudentStudyCourse)
668    grok.view(StudyCourseDisplayFormPage)
669    grok.require('waeup.handleStudent')
670    icon = 'actionicon_start.gif'
671    text = _('Start new session')
672    target = 'start_session'
673
674    @property
675    def target_url(self):
676        if self.context.next_session_allowed and self.context.is_current:
677            return self.view.url(self.view.context, self.target)
678        return False
679
680
681class AddStudyLevelActionButton(AddActionButton):
682    grok.order(1)
683    grok.context(IStudentStudyCourse)
684    grok.view(StudyCourseDisplayFormPage)
685    grok.require('waeup.handleStudent')
686    text = _('Add course list')
687    target = 'add'
688
689    @property
690    def target_url(self):
691        student = self.view.context.student
692        condition1 = student.state != PAID
693        condition2 = str(student['studycourse'].current_level) in \
694            self.view.context.keys()
695        condition3 = not self.context.is_current
696        if condition1 or condition2 or condition3:
697            return ''
698        return self.view.url(self.view.context, self.target)
699
700
701class StudyLevelEditActionButton(ManageActionButton):
702    grok.order(2)
703    grok.context(IStudentStudyLevel)
704    grok.view(StudyLevelDisplayFormPage)
705    grok.require('waeup.editStudyLevel')
706    text = _('Edit course list')
707    target = 'edit'
708
709    @property
710    def target_url(self):
711        student = self.view.context.student
712        condition1 = student.state == PAID
713        condition2 = self.view.context.is_current_level
714        is_current = self.context.__parent__.is_current
715        if condition1 and condition2 and is_current:
716            return self.view.url(self.view.context, self.target)
717        return ''
718
719
720class AddPaymentActionButton(AddActionButton):
721    grok.order(1)
722    grok.context(IStudentPaymentsContainer)
723    grok.view(PaymentsManageFormPage)
724    grok.require('waeup.payStudent')
725    text = _('Add current session payment ticket')
726    target = 'addop'
727
728
729class AddPreviousPaymentActionButton(AddActionButton):
730    grok.order(2)
731    grok.context(IStudentPaymentsContainer)
732    grok.view(PaymentsManageFormPage)
733    grok.require('waeup.payStudent')
734    grok.name('addpreviouspaymentactionbutton')
735    text = _('Add previous session payment ticket')
736    target = 'addpp'
737
738    @property
739    def target_url(self):
740        student = self.view.context.student
741        if student.before_payment or not self.target:
742            return ''
743        return self.view.url(self.view.context, self.target)
744
745
746class AddBalancePaymentActionButton(AddActionButton):
747    grok.order(3)
748    grok.context(IStudentPaymentsContainer)
749    grok.view(PaymentsManageFormPage)
750    grok.require('waeup.manageStudent')
751    grok.name('addbalancepaymentactionbutton')
752    text = _('Add balance payment ticket')
753    target = 'addbp'
754
755    @property
756    def target_url(self):
757        if not self.target:
758            return ''
759        return self.view.url(self.view.context, self.target)
760
761
762class RequestTranscriptActionButton(ManageActionButton):
763    grok.order(8)
764    grok.context(IStudentTranscript)
765    grok.view(StudentBaseDisplayFormPage)
766    grok.require('waeup.handleStudent')
767    text = _('Request transcript')
768    target = 'request_transcript'
769    icon = 'actionicon_transcript.png'
770
771    @property
772    def target_url(self):
773        if self.context.state != GRADUATED:
774            return ''
775        return self.view.url(self.view.context, self.target)
776
777
778class ValidateTranscriptActionButton(ManageActionButton):
779    grok.order(9)
780    grok.context(IStudentTranscript)
781    grok.view(StudentBaseDisplayFormPage)
782    grok.require('waeup.processTranscript')
783    text = _('Validate transcript')
784    target = 'validate_transcript'
785    icon = 'actionicon_transcript.png'
786
787    @property
788    def target_url(self):
789        if self.context.state != TRANSREQ:
790            return ''
791        return self.view.url(self.view.context, self.target)
792
793    @property
794    def onclick(self):
795        return "return window.confirm(%s);" % _(
796            "'Course results cannot be changed after transcript "
797            "validation. \\n\\n"
798            "You really want to validate the transcript?'")
799
800
801class ReleaseTranscriptActionButton(ManageActionButton):
802    grok.order(9)
803    grok.context(IStudentTranscript)
804    grok.view(StudentBaseDisplayFormPage)
805    grok.require('waeup.processTranscript')
806    text = _('Release transcript')
807    target = 'release_transcript'
808    icon = 'actionicon_transcript.png'
809
810    @property
811    def target_url(self):
812        if self.context.state != TRANSVAL:
813            return ''
814        return self.view.url(self.view.context, self.target)
815
816
817class StudentsTab(PrimaryNavTab):
818    """Students tab in primary navigation.
819    """
820    grok.context(IKofaObject)
821    grok.order(4)
822    grok.require('waeup.viewStudentsContainer')
823    grok.name('studentstab')
824
825    pnav = 4
826    tab_title = _(u'Students')
827
828    @property
829    def link_target(self):
830        return self.view.application_url('students')
831
832
833class PrimaryStudentNavManager(grok.ViewletManager):
834    """Viewlet manager for the primary navigation tab.
835    """
836    grok.name('primary_nav_student')
837
838
839class PrimaryStudentNavTab(grok.Viewlet):
840    """Base for primary student nav tabs.
841    """
842    grok.baseclass()
843    grok.context(IKofaObject)
844    grok.viewletmanager(PrimaryStudentNavManager)
845    template = default_primary_nav_template
846    grok.order(1)
847    grok.require('waeup.Authenticated')
848    pnav = 0
849    tab_title = u'Some Text'
850
851    @property
852    def link_target(self):
853        return self.view.application_url()
854
855    @property
856    def active(self):
857        view_pnav = getattr(self.view, 'pnav', 0)
858        if view_pnav == self.pnav:
859            return 'active'
860        return ''
861
862
863class MyStudentDataTab(PrimaryStudentNavTab):
864    """MyData dropdown tab in primary navigation.
865    """
866    grok.order(3)
867    grok.require('waeup.viewMyStudentDataTab')
868    grok.template('mydatadropdowntabs')
869    grok.name('mystudentdatatab')
870    pnav = 4
871    tab_title = _(u'My Data')
872
873    @property
874    def active(self):
875        view_pnav = getattr(self.view, 'pnav', 0)
876        if view_pnav == self.pnav:
877            return 'active dropdown'
878        return 'dropdown'
879
880    @property
881    def targets(self):
882        student = grok.getSite()['students'][self.request.principal.id]
883        student_url = self.view.url(student)
884        app_slip = getUtility(IExtFileStore).getFileByContext(
885            student, 'application_slip')
886        targets = []
887        if app_slip:
888            targets = [{'url': student_url + '/application_slip',
889                        'title': _('Application Slip')}, ]
890        targets += [
891            {'url': student_url, 'title': 'Base Data'},
892            {'url': student_url + '/view_clearance',
893             'title': _('Clearance Data')},
894            {'url': student_url + '/view_personal',
895             'title': _('Personal Data')},
896            {'url': student_url + '/studycourse', 'title': _('Study Course')},
897            {'url': student_url + '/payments', 'title': _('Payments')},
898            {'url': student_url + '/accommodation',
899             'title': _('Accommodation Data')},
900            {'url': student_url + '/history', 'title': _('History')},
901            ]
902        return targets
903
904
905class DownloadCSVFileActionButton(ManageActionButton):
906    """ 'Download csv file' button for courses.
907    """
908    grok.context(ICourse)
909    grok.view(EditScoresPage)
910    grok.name('downloadcsv')
911    grok.require('waeup.editScores')
912    icon = 'actionicon_down.png'
913    text = _('Download csv file (editable scores only)')
914    target = 'download_scores'
915    grok.order(1)
916
917
918class DownloadTicketOverviewActionButton(ManageActionButton):
919    """ 'Download ticket overview' button for courses.
920    """
921    grok.context(ICourse)
922    grok.view(EditScoresPage)
923    grok.name('coursetickets')
924    grok.require('waeup.editScores')
925    icon = 'actionicon_pdf.png'
926    text = _('Download pdf file')
927    target = 'coursetickets.pdf'
928    grok.order(2)
Note: See TracBrowser for help on using the repository browser.