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

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

Implement course result validation workflow for lecturers.

  • Property svn:keywords set to Id
File size: 27.4 KB
RevLine 
[11976]1## $Id: viewlets.py 15422 2019-05-24 09:11:40Z 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
474    def target_url(self):
[13935]475        if not self.context.__parent__.is_current:
[13610]476            return ''
[13935]477        if self.context.student.state != REGISTERED:
478            return ''
479        if str(self.context.__parent__.current_level) != self.context.__name__:
480            return ''
[13610]481        return self.view.url(self.view.context, self.target)
482
[13935]483
[13610]484class CourseRegistrationSlipActionButton(ManageActionButton):
485    grok.order(6)
486    grok.context(IStudentStudyLevel)
487    grok.view(StudyLevelDisplayFormPage)
[8078]488    grok.require('waeup.viewStudent')
489    icon = 'actionicon_pdf.png'
490    text = _('Download course registration slip')
[9452]491    target = 'course_registration_slip.pdf'
[8078]492
[9138]493    @property
494    def target_url(self):
495        is_current = self.context.__parent__.is_current
496        if not is_current:
497            return ''
498        return self.view.url(self.view.context, self.target)
499
[13935]500
[7591]501class CourseTicketManageActionButton(ManageActionButton):
502    grok.order(1)
503    grok.context(ICourseTicket)
504    grok.view(CourseTicketDisplayFormPage)
505    grok.require('waeup.manageStudent')
[7738]506    text = _('Manage')
[7591]507    target = 'manage'
508
509
510class PaymentReceiptActionButton(ManageActionButton):
[13935]511    grok.order(9)  # This button should always be the last one.
[7591]512    grok.context(IStudentOnlinePayment)
513    grok.view(OnlinePaymentDisplayFormPage)
514    grok.require('waeup.viewStudent')
515    icon = 'actionicon_pdf.png'
[8262]516    text = _('Download payment slip')
517    target = 'payment_slip.pdf'
[7591]518
519    @property
520    def target_url(self):
[8262]521        #if self.context.p_state != 'paid':
522        #    return ''
[7591]523        return self.view.url(self.view.context, self.target)
524
[13935]525
[8420]526class ApprovePaymentActionButton(ManageActionButton):
[9070]527    grok.order(8)
[7591]528    grok.context(IStudentOnlinePayment)
529    grok.view(OnlinePaymentDisplayFormPage)
[8420]530    grok.require('waeup.managePortal')
[8435]531    icon = 'actionicon_accept.png'
[8420]532    text = _('Approve payment')
533    target = 'approve'
[7591]534
535    @property
536    def target_url(self):
[7888]537        if self.context.p_state == 'paid':
[7591]538            return ''
539        return self.view.url(self.view.context, self.target)
540
[13935]541
[7591]542class BedTicketSlipActionButton(ManageActionButton):
543    grok.order(1)
544    grok.context(IBedTicket)
545    grok.view(BedTicketDisplayFormPage)
546    grok.require('waeup.handleAccommodation')
547    icon = 'actionicon_pdf.png'
[7738]548    text = _('Download bed allocation slip')
[9452]549    target = 'bed_allocation_slip.pdf'
[7591]550
[13935]551
[7591]552class RelocateStudentActionButton(ManageActionButton):
553    grok.order(2)
554    grok.context(IBedTicket)
555    grok.view(BedTicketDisplayFormPage)
556    grok.require('waeup.manageHostels')
557    icon = 'actionicon_reload.png'
[7738]558    text = _('Relocate student')
[7591]559    target = 'relocate'
560
[13935]561
[7591]562class StudentBaseActionButton(ManageActionButton):
563    grok.order(1)
564    grok.context(IStudent)
565    grok.view(StudentBaseDisplayFormPage)
566    grok.require('waeup.handleStudent')
[7876]567    text = _('Edit')
[7591]568    target = 'edit_base'
569
[13935]570
[7591]571class StudentPasswordActionButton(ManageActionButton):
572    grok.order(2)
573    grok.context(IStudent)
574    grok.view(StudentBaseDisplayFormPage)
575    grok.require('waeup.handleStudent')
576    icon = 'actionicon_key.png'
[7738]577    text = _('Change password')
[7591]578    target = 'change_password'
579
[13935]580
[7591]581class StudentPassportActionButton(ManageActionButton):
582    grok.order(3)
583    grok.context(IStudent)
584    grok.view(StudentBaseDisplayFormPage)
585    grok.require('waeup.handleStudent')
586    icon = 'actionicon_portrait.png'
[7738]587    text = _('Change portrait')
[7591]588    target = 'change_portrait'
589
590    @property
591    def target_url(self):
[13935]592        PORTRAIT_CHANGE_STATES = getUtility(
593            IStudentsUtils).PORTRAIT_CHANGE_STATES
[13129]594        if self.context.state not in PORTRAIT_CHANGE_STATES:
[7591]595            return ''
596        return self.view.url(self.view.context, self.target)
597
[13935]598
[7591]599class StudentClearanceStartActionButton(ManageActionButton):
600    grok.order(1)
601    grok.context(IStudent)
602    grok.view(StudentClearanceDisplayFormPage)
603    grok.require('waeup.handleStudent')
604    icon = 'actionicon_start.gif'
[7738]605    text = _('Start clearance')
[7591]606    target = 'start_clearance'
607
608    @property
609    def target_url(self):
[7671]610        if self.context.state != ADMITTED:
[7591]611            return ''
612        return self.view.url(self.view.context, self.target)
613
[13935]614
[7591]615class StudentClearanceEditActionButton(ManageActionButton):
616    grok.order(1)
617    grok.context(IStudent)
618    grok.view(StudentClearanceDisplayFormPage)
619    grok.require('waeup.handleStudent')
[7738]620    text = _('Edit')
[7591]621    target = 'cedit'
622
623    @property
624    def target_url(self):
625        if self.context.clearance_locked:
626            return ''
627        return self.view.url(self.view.context, self.target)
628
[13935]629
[8476]630class StartSessionActionButton(ManageActionButton):
[7591]631    grok.order(1)
632    grok.context(IStudentStudyCourse)
633    grok.view(StudyCourseDisplayFormPage)
634    grok.require('waeup.handleStudent')
635    icon = 'actionicon_start.gif'
[8920]636    text = _('Start new session')
[8471]637    target = 'start_session'
[7591]638
639    @property
640    def target_url(self):
[9138]641        if self.context.next_session_allowed and self.context.is_current:
[8471]642            return self.view.url(self.view.context, self.target)
643        return False
[7591]644
[13935]645
[7591]646class AddStudyLevelActionButton(AddActionButton):
647    grok.order(1)
648    grok.context(IStudentStudyCourse)
649    grok.view(StudyCourseDisplayFormPage)
650    grok.require('waeup.handleStudent')
[7738]651    text = _('Add course list')
[7591]652    target = 'add'
653
654    @property
655    def target_url(self):
[8736]656        student = self.view.context.student
[7671]657        condition1 = student.state != PAID
[7591]658        condition2 = str(student['studycourse'].current_level) in \
659            self.view.context.keys()
[9138]660        condition3 = not self.context.is_current
661        if condition1 or condition2 or condition3:
[7591]662            return ''
663        return self.view.url(self.view.context, self.target)
664
[13935]665
[7591]666class StudyLevelEditActionButton(ManageActionButton):
[8078]667    grok.order(2)
[7591]668    grok.context(IStudentStudyLevel)
669    grok.view(StudyLevelDisplayFormPage)
[9924]670    grok.require('waeup.editStudyLevel')
[8920]671    text = _('Edit course list')
[7591]672    target = 'edit'
673
674    @property
675    def target_url(self):
[8736]676        student = self.view.context.student
[9257]677        condition1 = student.state == PAID
678        condition2 = self.view.context.is_current_level
[9138]679        is_current = self.context.__parent__.is_current
[9257]680        if condition1 and condition2 and is_current:
681            return self.view.url(self.view.context, self.target)
682        return ''
[7591]683
[13935]684
[9517]685class AddPaymentActionButton(AddActionButton):
686    grok.order(1)
687    grok.context(IStudentPaymentsContainer)
688    grok.view(PaymentsManageFormPage)
689    grok.require('waeup.payStudent')
690    text = _('Add current session payment ticket')
691    target = 'addop'
692
[13935]693
[9517]694class AddPreviousPaymentActionButton(AddActionButton):
695    grok.order(2)
696    grok.context(IStudentPaymentsContainer)
697    grok.view(PaymentsManageFormPage)
698    grok.require('waeup.payStudent')
[10811]699    grok.name('addpreviouspaymentactionbutton')
[9517]700    text = _('Add previous session payment ticket')
701    target = 'addpp'
702
703    @property
704    def target_url(self):
705        student = self.view.context.student
[10811]706        if student.before_payment or not self.target:
[9517]707            return ''
708        return self.view.url(self.view.context, self.target)
709
[13935]710
[9865]711class AddBalancePaymentActionButton(AddActionButton):
712    grok.order(3)
713    grok.context(IStudentPaymentsContainer)
714    grok.view(PaymentsManageFormPage)
[9938]715    grok.require('waeup.manageStudent')
[10810]716    grok.name('addbalancepaymentactionbutton')
[9865]717    text = _('Add balance payment ticket')
718    target = 'addbp'
719
720    @property
721    def target_url(self):
[10810]722        if not self.target:
723            return ''
[9865]724        return self.view.url(self.view.context, self.target)
725
[13935]726
[15163]727class StudyCourseTranscriptActionButton(ManageActionButton):
728    grok.order(2)
729    grok.name('transcript')
730    grok.context(IStudentStudyCourse)
731    grok.view(StudyCourseDisplayFormPage)
732    grok.require('waeup.viewTranscript')
733    text = _('Transcript')
734    target = 'transcript'
735    icon = 'actionicon_transcript.png'
736
737    @property
738    def target_url(self):
739        final_slip = getUtility(IExtFileStore).getFileByContext(
740            self.context.student, attr='final_transcript')
741        if self.context.student.transcript_enabled and not final_slip:
742            return self.view.url(self.view.context, self.target)
743        return False
744
745
[10458]746class RequestTranscriptActionButton(ManageActionButton):
747    grok.order(8)
748    grok.context(IStudent)
749    grok.view(StudentBaseDisplayFormPage)
750    grok.require('waeup.handleStudent')
751    text = _('Request transcript')
752    target = 'request_transcript'
753    icon = 'actionicon_transcript.png'
754
755    @property
756    def target_url(self):
757        if self.context.state != GRADUATED:
758            return ''
759        return self.view.url(self.view.context, self.target)
760
[13935]761
[15163]762class ValidateTranscriptActionButton(ManageActionButton):
763    grok.order(8)
764    grok.context(IStudentStudyCourse)
765    grok.view(StudyCourseTranscriptPage)
766    grok.require('waeup.processTranscript')
767    text = _('Validate transcript')
768    target = 'validate_transcript'
769    icon = 'actionicon_transcript.png'
770
771    @property
772    def target_url(self):
773        if self.context.student.state != TRANSREQ:
774            return ''
775        return self.view.url(self.view.context, self.target)
776
777
778class ReleaseTranscriptActionButton(ManageActionButton):
779    grok.order(8)
780    grok.context(IStudentStudyCourse)
781    grok.view(StudyCourseTranscriptPage)
782    grok.require('waeup.processTranscript')
783    text = _('Release transcript')
784    target = 'release_transcript'
785    icon = 'actionicon_transcript.png'
786
787    @property
788    def target_url(self):
789        if self.context.student.state != TRANSVAL:
790            return ''
791        return self.view.url(self.view.context, self.target)
792
793
794class TranscriptSlipActionButton(ManageActionButton):
795    grok.order(1)
796    grok.name('transcript_slip')
797    grok.context(IStudentStudyCourse)
798    grok.view(StudyCourseTranscriptPage)
[10459]799    grok.require('waeup.viewTranscript')
[15163]800    text = _('Academic Transcript')
801    target = 'transcript.pdf'
802    icon = 'actionicon_pdf.png'
803
804    @property
805    def target_url(self):
806        final_slip = getUtility(IExtFileStore).getFileByContext(
807            self.context.student, attr='final_transcript')
808        if self.context.student.transcript_enabled \
809            and not final_slip:
810            return self.view.url(self.view.context, self.target)
811        return False
812
813
814class SignTranscriptActionButton(ManageActionButton):
815    grok.order(2)
816    grok.context(IStudentStudyCourse)
817    grok.view(StudyCourseTranscriptPage)
818    grok.require('waeup.signTranscript')
819    text = _('Sign transcript electronically')
820    target = 'sign_transcript'
[10458]821    icon = 'actionicon_transcript.png'
822
823    @property
824    def target_url(self):
[15163]825        if self.context.student.state != TRANSVAL:
[10458]826            return ''
827        return self.view.url(self.view.context, self.target)
828
[15163]829    @property
830    def onclick(self):
831        return "return window.confirm(%s);" % _(
832            "'Signing a transcript electronically cannot be revoked. "
833            "The electronic signature replaces your handwritten signature.\\n\\n"
834            "You really want to sign the transcript?'")
[13935]835
[15163]836
[7184]837class StudentsTab(PrimaryNavTab):
838    """Students tab in primary navigation.
839    """
[7819]840    grok.context(IKofaObject)
[7184]841    grok.order(4)
[12843]842    grok.require('waeup.viewStudentsContainer')
[10771]843    grok.name('studentstab')
[7184]844
845    pnav = 4
[7674]846    tab_title = _(u'Students')
[7184]847
848    @property
849    def link_target(self):
850        return self.view.application_url('students')
851
[13935]852
[6687]853class PrimaryStudentNavManager(grok.ViewletManager):
854    """Viewlet manager for the primary navigation tab.
855    """
856    grok.name('primary_nav_student')
857
[13935]858
[6687]859class PrimaryStudentNavTab(grok.Viewlet):
860    """Base for primary student nav tabs.
861    """
862    grok.baseclass()
[10816]863    grok.context(IKofaObject)
[6687]864    grok.viewletmanager(PrimaryStudentNavManager)
[7243]865    template = default_primary_nav_template
[6687]866    grok.order(1)
[7184]867    grok.require('waeup.Authenticated')
[8467]868    pnav = 0
[6687]869    tab_title = u'Some Text'
870
871    @property
872    def link_target(self):
873        return self.view.application_url()
874
875    @property
876    def active(self):
877        view_pnav = getattr(self.view, 'pnav', 0)
878        if view_pnav == self.pnav:
879            return 'active'
880        return ''
881
[13935]882
[7240]883class MyStudentDataTab(PrimaryStudentNavTab):
[7459]884    """MyData dropdown tab in primary navigation.
[6687]885    """
886    grok.order(3)
[7240]887    grok.require('waeup.viewMyStudentDataTab')
[7459]888    grok.template('mydatadropdowntabs')
[10816]889    grok.name('mystudentdatatab')
[6687]890    pnav = 4
[7738]891    tab_title = _(u'My Data')
[6687]892
893    @property
[7459]894    def active(self):
895        view_pnav = getattr(self.view, 'pnav', 0)
896        if view_pnav == self.pnav:
897            return 'active dropdown'
898        return 'dropdown'
[7097]899
[7459]900    @property
901    def targets(self):
[9180]902        student = grok.getSite()['students'][self.request.principal.id]
903        student_url = self.view.url(student)
[9178]904        app_slip = getUtility(IExtFileStore).getFileByContext(
[9180]905            student, 'application_slip')
[7459]906        targets = []
[9178]907        if app_slip:
[13935]908            targets = [{'url': student_url + '/application_slip',
909                        'title': _('Application Slip')}, ]
[7459]910        targets += [
[13935]911            {'url': student_url, 'title': 'Base Data'},
912            {'url': student_url + '/view_clearance',
913             'title': _('Clearance Data')},
914            {'url': student_url + '/view_personal',
915             'title': _('Personal Data')},
916            {'url': student_url + '/studycourse', 'title': _('Study Course')},
917            {'url': student_url + '/payments', 'title': _('Payments')},
918            {'url': student_url + '/accommodation',
919             'title': _('Accommodation Data')},
920            {'url': student_url + '/history', 'title': _('History')},
[7459]921            ]
922        return targets
Note: See TracBrowser for help on using the repository browser.