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

Last change on this file since 17959 was 17918, checked in by Henrik Bettermann, 2 months ago

Rename slip title.

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