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

Last change on this file since 12853 was 12853, checked in by Henrik Bettermann, 9 years ago

Students are only allowed to download course registration slips if they are
in state 'registered' and their current level corresponds with the course
registration level.

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