source: main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py @ 14709

Last change on this file since 14709 was 14158, checked in by Henrik Bettermann, 8 years ago

Name viewlet.

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