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

Last change on this file since 16153 was 16120, checked in by Henrik Bettermann, 4 years ago

Finetune transcript processing. Allow transcript officers to request a transcript.

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