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

Last change on this file since 15865 was 15843, checked in by Henrik Bettermann, 5 years ago

Show correct buttons if payment state in ('paid', 'waived', 'scholarship').

  • Property svn:keywords set to Id
File size: 27.9 KB
RevLine 
[11976]1## $Id: viewlets.py 15843 2019-11-25 11:04:39Z 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')
[7181]133    grok.require('waeup.handleAccommodation')
[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)
183    grok.require('waeup.manageStudent')
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)
551    grok.require('waeup.handleAccommodation')
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
[13935]766
[15163]767class ValidateTranscriptActionButton(ManageActionButton):
768    grok.order(8)
769    grok.context(IStudentStudyCourse)
770    grok.view(StudyCourseTranscriptPage)
771    grok.require('waeup.processTranscript')
772    text = _('Validate transcript')
773    target = 'validate_transcript'
774    icon = 'actionicon_transcript.png'
775
776    @property
777    def target_url(self):
778        if self.context.student.state != TRANSREQ:
779            return ''
780        return self.view.url(self.view.context, self.target)
781
782
783class ReleaseTranscriptActionButton(ManageActionButton):
784    grok.order(8)
785    grok.context(IStudentStudyCourse)
786    grok.view(StudyCourseTranscriptPage)
787    grok.require('waeup.processTranscript')
788    text = _('Release transcript')
789    target = 'release_transcript'
790    icon = 'actionicon_transcript.png'
791
792    @property
793    def target_url(self):
794        if self.context.student.state != TRANSVAL:
795            return ''
796        return self.view.url(self.view.context, self.target)
797
798
799class TranscriptSlipActionButton(ManageActionButton):
800    grok.order(1)
801    grok.name('transcript_slip')
802    grok.context(IStudentStudyCourse)
803    grok.view(StudyCourseTranscriptPage)
[10459]804    grok.require('waeup.viewTranscript')
[15163]805    text = _('Academic Transcript')
806    target = 'transcript.pdf'
807    icon = 'actionicon_pdf.png'
808
809    @property
810    def target_url(self):
811        final_slip = getUtility(IExtFileStore).getFileByContext(
812            self.context.student, attr='final_transcript')
813        if self.context.student.transcript_enabled \
814            and not final_slip:
815            return self.view.url(self.view.context, self.target)
816        return False
817
818
819class SignTranscriptActionButton(ManageActionButton):
820    grok.order(2)
821    grok.context(IStudentStudyCourse)
822    grok.view(StudyCourseTranscriptPage)
823    grok.require('waeup.signTranscript')
824    text = _('Sign transcript electronically')
825    target = 'sign_transcript'
[10458]826    icon = 'actionicon_transcript.png'
827
828    @property
829    def target_url(self):
[15163]830        if self.context.student.state != TRANSVAL:
[10458]831            return ''
832        return self.view.url(self.view.context, self.target)
833
[15163]834    @property
835    def onclick(self):
836        return "return window.confirm(%s);" % _(
837            "'Signing a transcript electronically cannot be revoked. "
838            "The electronic signature replaces your handwritten signature.\\n\\n"
839            "You really want to sign the transcript?'")
[13935]840
[15163]841
[7184]842class StudentsTab(PrimaryNavTab):
843    """Students tab in primary navigation.
844    """
[7819]845    grok.context(IKofaObject)
[7184]846    grok.order(4)
[12843]847    grok.require('waeup.viewStudentsContainer')
[10771]848    grok.name('studentstab')
[7184]849
850    pnav = 4
[7674]851    tab_title = _(u'Students')
[7184]852
853    @property
854    def link_target(self):
855        return self.view.application_url('students')
856
[13935]857
[6687]858class PrimaryStudentNavManager(grok.ViewletManager):
859    """Viewlet manager for the primary navigation tab.
860    """
861    grok.name('primary_nav_student')
862
[13935]863
[6687]864class PrimaryStudentNavTab(grok.Viewlet):
865    """Base for primary student nav tabs.
866    """
867    grok.baseclass()
[10816]868    grok.context(IKofaObject)
[6687]869    grok.viewletmanager(PrimaryStudentNavManager)
[7243]870    template = default_primary_nav_template
[6687]871    grok.order(1)
[7184]872    grok.require('waeup.Authenticated')
[8467]873    pnav = 0
[6687]874    tab_title = u'Some Text'
875
876    @property
877    def link_target(self):
878        return self.view.application_url()
879
880    @property
881    def active(self):
882        view_pnav = getattr(self.view, 'pnav', 0)
883        if view_pnav == self.pnav:
884            return 'active'
885        return ''
886
[13935]887
[7240]888class MyStudentDataTab(PrimaryStudentNavTab):
[7459]889    """MyData dropdown tab in primary navigation.
[6687]890    """
891    grok.order(3)
[7240]892    grok.require('waeup.viewMyStudentDataTab')
[7459]893    grok.template('mydatadropdowntabs')
[10816]894    grok.name('mystudentdatatab')
[6687]895    pnav = 4
[7738]896    tab_title = _(u'My Data')
[6687]897
898    @property
[7459]899    def active(self):
900        view_pnav = getattr(self.view, 'pnav', 0)
901        if view_pnav == self.pnav:
902            return 'active dropdown'
903        return 'dropdown'
[7097]904
[7459]905    @property
906    def targets(self):
[9180]907        student = grok.getSite()['students'][self.request.principal.id]
908        student_url = self.view.url(student)
[9178]909        app_slip = getUtility(IExtFileStore).getFileByContext(
[9180]910            student, 'application_slip')
[7459]911        targets = []
[15606]912        if student.getParentsPassword():
913            targets += [
914                {'url': student_url, 'title': 'Base Data'},
915                {'url': student_url + '/studycourse', 'title': _('Study Course')},
916                {'url': student_url + '/payments', 'title': _('Payments')},
917                ]
918            return targets
[9178]919        if app_slip:
[13935]920            targets = [{'url': student_url + '/application_slip',
921                        'title': _('Application Slip')}, ]
[7459]922        targets += [
[13935]923            {'url': student_url, 'title': 'Base Data'},
924            {'url': student_url + '/view_clearance',
925             'title': _('Clearance Data')},
926            {'url': student_url + '/view_personal',
927             'title': _('Personal Data')},
928            {'url': student_url + '/studycourse', 'title': _('Study Course')},
929            {'url': student_url + '/payments', 'title': _('Payments')},
930            {'url': student_url + '/accommodation',
931             'title': _('Accommodation Data')},
932            {'url': student_url + '/history', 'title': _('History')},
[7459]933            ]
934        return targets
Note: See TracBrowser for help on using the repository browser.