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

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

Divide editscorespage.pt into two parts, one for file upload and one for table form.

Add Help modal.

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