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

Last change on this file since 15185 was 15175, checked in by Henrik Bettermann, 6 years ago

Remove warning message.

  • Property svn:keywords set to Id
File size: 28.2 KB
RevLine 
[11976]1## $Id: viewlets.py 15175 2018-09-25 11:51:01Z 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,
[13935]34    PaymentsManageFormPage, StudyCourseTranscriptPage, EditScoresPage)
[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)
[13935]43from waeup.kofa.university.interfaces import ICourse
[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')
[7181]134    grok.require('waeup.handleAccommodation')
[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)
184    grok.require('waeup.manageStudent')
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
[13935]309
[7591]310class StudentRejectClearanceActionButton(ManageActionButton):
311    grok.order(3)
312    grok.context(IStudent)
313    grok.view(StudentClearanceDisplayFormPage)
314    grok.require('waeup.clearStudent')
[7738]315    text = _('Reject clearance')
[7591]316    target = 'reject_clearance'
317    icon = 'actionicon_reject.png'
318
319    @property
320    def target_url(self):
[13935]321        cdm = getUtility(
322            IStudentsUtils).clearance_disabled_message(self.context)
[11772]323        if cdm:
[9814]324            return ''
[7591]325        if self.context.state not in (REQUESTED, CLEARED):
326            return ''
327        return self.view.url(self.view.context, self.target)
328
[13935]329
[7591]330class ClearanceSlipActionButton(ManageActionButton):
331    grok.order(4)
332    grok.context(IStudent)
333    grok.view(StudentClearanceDisplayFormPage)
334    grok.require('waeup.viewStudent')
335    icon = 'actionicon_pdf.png'
[7738]336    text = _('Download clearance slip')
[9452]337    target = 'clearance_slip.pdf'
[7591]338
[13935]339
[8119]340class ClearanceViewActionButton(ManageActionButton):
341    grok.order(1)
342    grok.context(IStudent)
343    grok.view(StudentClearanceEditFormPage)
344    grok.require('waeup.viewStudent')
345    icon = 'actionicon_view.png'
346    text = _('View')
347    target = 'view_clearance'
348
[13935]349
[8119]350class PersonalViewActionButton(ManageActionButton):
351    grok.order(1)
352    grok.context(IStudent)
353    grok.view(StudentPersonalEditFormPage)
354    grok.require('waeup.viewStudent')
355    icon = 'actionicon_view.png'
356    text = _('View')
357    target = 'view_personal'
358
[13935]359
[8903]360class StudentPersonalManageActionButton(ManageActionButton):
[7591]361    grok.order(1)
362    grok.context(IStudent)
363    grok.view(StudentPersonalDisplayFormPage)
[8903]364    grok.require('waeup.manageStudent')
365    text = _('Manage')
366    target = 'manage_personal'
367
[13935]368
[8903]369class StudentPersonalEditActionButton(ManageActionButton):
370    grok.order(2)
371    grok.context(IStudent)
372    grok.view(StudentPersonalDisplayFormPage)
373    grok.require('waeup.handleStudent')
[7738]374    text = _('Edit')
[7591]375    target = 'edit_personal'
376
[13935]377
[7591]378class StudyCourseManageActionButton(ManageActionButton):
379    grok.order(1)
380    grok.context(IStudentStudyCourse)
381    grok.view(StudyCourseDisplayFormPage)
382    grok.require('waeup.manageStudent')
[7738]383    text = _('Manage')
[7591]384    target = 'manage'
385
[9138]386    @property
387    def target_url(self):
388        if self.context.is_current:
389            return self.view.url(self.view.context, self.target)
390        return False
391
[13935]392
[10060]393class RevertTransferActionButton(ManageActionButton):
394    grok.order(1)
395    grok.context(IStudentStudyCourse)
396    grok.view(StudyCourseDisplayFormPage)
397    grok.require('waeup.manageStudent')
398    icon = 'actionicon_undo.png'
399    text = _('Reactivate this study course (revert previous transfer)')
400    target = 'revert_transfer'
401
402    @property
403    def target_url(self):
404        if self.context.is_previous:
405            return self.view.url(self.view.context.__parent__, self.target)
406        return False
407
[13935]408
[8078]409class StudyLevelManageActionButton(ManageActionButton):
[7591]410    grok.order(1)
411    grok.context(IStudentStudyLevel)
412    grok.view(StudyLevelDisplayFormPage)
413    grok.require('waeup.manageStudent')
[7738]414    text = _('Manage')
[7591]415    target = 'manage'
416
[9138]417    @property
418    def target_url(self):
419        is_current = self.context.__parent__.is_current
420        if not is_current:
421            return ''
422        return self.view.url(self.view.context, self.target)
423
[13935]424
[7591]425class StudentValidateCoursesActionButton(ManageActionButton):
426    grok.order(3)
427    grok.context(IStudentStudyLevel)
428    grok.view(StudyLevelDisplayFormPage)
429    grok.require('waeup.validateStudent')
[7738]430    text = _('Validate courses')
[7591]431    target = 'validate_courses'
432    icon = 'actionicon_accept.png'
433
434    @property
435    def target_url(self):
[13935]436        if not self.context.__parent__.is_current:
[7591]437            return ''
[13935]438        if self.context.student.state != REGISTERED:
439            return ''
440        if str(self.context.__parent__.current_level) != self.context.__name__:
441            return ''
[7591]442        return self.view.url(self.view.context, self.target)
443
[13935]444
[7591]445class StudentRejectCoursesActionButton(ManageActionButton):
446    grok.order(4)
447    grok.context(IStudentStudyLevel)
448    grok.view(StudyLevelDisplayFormPage)
449    grok.require('waeup.validateStudent')
[7738]450    text = _('Reject courses')
[7591]451    target = 'reject_courses'
452    icon = 'actionicon_reject.png'
453
454    @property
455    def target_url(self):
[13935]456        if not self.context.__parent__.is_current:
[7591]457            return ''
[13935]458        if self.context.student.state not in (VALIDATED, REGISTERED):
459            return ''
460        if str(self.context.__parent__.current_level) != self.context.__name__:
461            return ''
[7591]462        return self.view.url(self.view.context, self.target)
463
[13935]464
[13610]465class StudentUnregisterCoursesActionButton(ManageActionButton):
[8078]466    grok.order(5)
467    grok.context(IStudentStudyLevel)
468    grok.view(StudyLevelDisplayFormPage)
[13610]469    grok.require('waeup.handleStudent')
470    text = _('Unregister courses')
471    target = 'unregister_courses'
472    icon = 'actionicon_reject.png'
473
474    @property
475    def target_url(self):
[13935]476        if not self.context.__parent__.is_current:
[13610]477            return ''
[13935]478        if self.context.student.state != REGISTERED:
479            return ''
480        if str(self.context.__parent__.current_level) != self.context.__name__:
481            return ''
[13610]482        return self.view.url(self.view.context, self.target)
483
[13935]484
[13610]485class CourseRegistrationSlipActionButton(ManageActionButton):
486    grok.order(6)
487    grok.context(IStudentStudyLevel)
488    grok.view(StudyLevelDisplayFormPage)
[8078]489    grok.require('waeup.viewStudent')
490    icon = 'actionicon_pdf.png'
491    text = _('Download course registration slip')
[9452]492    target = 'course_registration_slip.pdf'
[8078]493
[9138]494    @property
495    def target_url(self):
496        is_current = self.context.__parent__.is_current
497        if not is_current:
498            return ''
499        return self.view.url(self.view.context, self.target)
500
[13935]501
[7591]502class CourseTicketManageActionButton(ManageActionButton):
503    grok.order(1)
504    grok.context(ICourseTicket)
505    grok.view(CourseTicketDisplayFormPage)
506    grok.require('waeup.manageStudent')
[7738]507    text = _('Manage')
[7591]508    target = 'manage'
509
510
511class PaymentReceiptActionButton(ManageActionButton):
[13935]512    grok.order(9)  # This button should always be the last one.
[7591]513    grok.context(IStudentOnlinePayment)
514    grok.view(OnlinePaymentDisplayFormPage)
515    grok.require('waeup.viewStudent')
516    icon = 'actionicon_pdf.png'
[8262]517    text = _('Download payment slip')
518    target = 'payment_slip.pdf'
[7591]519
520    @property
521    def target_url(self):
[8262]522        #if self.context.p_state != 'paid':
523        #    return ''
[7591]524        return self.view.url(self.view.context, self.target)
525
[13935]526
[8420]527class ApprovePaymentActionButton(ManageActionButton):
[9070]528    grok.order(8)
[7591]529    grok.context(IStudentOnlinePayment)
530    grok.view(OnlinePaymentDisplayFormPage)
[8420]531    grok.require('waeup.managePortal')
[8435]532    icon = 'actionicon_accept.png'
[8420]533    text = _('Approve payment')
534    target = 'approve'
[7591]535
536    @property
537    def target_url(self):
[7888]538        if self.context.p_state == 'paid':
[7591]539            return ''
540        return self.view.url(self.view.context, self.target)
541
[13935]542
[7591]543class BedTicketSlipActionButton(ManageActionButton):
544    grok.order(1)
545    grok.context(IBedTicket)
546    grok.view(BedTicketDisplayFormPage)
547    grok.require('waeup.handleAccommodation')
548    icon = 'actionicon_pdf.png'
[7738]549    text = _('Download bed allocation slip')
[9452]550    target = 'bed_allocation_slip.pdf'
[7591]551
[13935]552
[7591]553class RelocateStudentActionButton(ManageActionButton):
554    grok.order(2)
555    grok.context(IBedTicket)
556    grok.view(BedTicketDisplayFormPage)
557    grok.require('waeup.manageHostels')
558    icon = 'actionicon_reload.png'
[7738]559    text = _('Relocate student')
[7591]560    target = 'relocate'
561
[13935]562
[7591]563class StudentBaseActionButton(ManageActionButton):
564    grok.order(1)
565    grok.context(IStudent)
566    grok.view(StudentBaseDisplayFormPage)
567    grok.require('waeup.handleStudent')
[7876]568    text = _('Edit')
[7591]569    target = 'edit_base'
570
[13935]571
[7591]572class StudentPasswordActionButton(ManageActionButton):
573    grok.order(2)
574    grok.context(IStudent)
575    grok.view(StudentBaseDisplayFormPage)
576    grok.require('waeup.handleStudent')
577    icon = 'actionicon_key.png'
[7738]578    text = _('Change password')
[7591]579    target = 'change_password'
580
[13935]581
[7591]582class StudentPassportActionButton(ManageActionButton):
583    grok.order(3)
584    grok.context(IStudent)
585    grok.view(StudentBaseDisplayFormPage)
586    grok.require('waeup.handleStudent')
587    icon = 'actionicon_portrait.png'
[7738]588    text = _('Change portrait')
[7591]589    target = 'change_portrait'
590
591    @property
592    def target_url(self):
[13935]593        PORTRAIT_CHANGE_STATES = getUtility(
594            IStudentsUtils).PORTRAIT_CHANGE_STATES
[13129]595        if self.context.state not in PORTRAIT_CHANGE_STATES:
[7591]596            return ''
597        return self.view.url(self.view.context, self.target)
598
[13935]599
[7591]600class StudentClearanceStartActionButton(ManageActionButton):
601    grok.order(1)
602    grok.context(IStudent)
603    grok.view(StudentClearanceDisplayFormPage)
604    grok.require('waeup.handleStudent')
605    icon = 'actionicon_start.gif'
[7738]606    text = _('Start clearance')
[7591]607    target = 'start_clearance'
608
609    @property
610    def target_url(self):
[7671]611        if self.context.state != ADMITTED:
[7591]612            return ''
613        return self.view.url(self.view.context, self.target)
614
[13935]615
[7591]616class StudentClearanceEditActionButton(ManageActionButton):
617    grok.order(1)
618    grok.context(IStudent)
619    grok.view(StudentClearanceDisplayFormPage)
620    grok.require('waeup.handleStudent')
[7738]621    text = _('Edit')
[7591]622    target = 'cedit'
623
624    @property
625    def target_url(self):
626        if self.context.clearance_locked:
627            return ''
628        return self.view.url(self.view.context, self.target)
629
[13935]630
[8476]631class StartSessionActionButton(ManageActionButton):
[7591]632    grok.order(1)
633    grok.context(IStudentStudyCourse)
634    grok.view(StudyCourseDisplayFormPage)
635    grok.require('waeup.handleStudent')
636    icon = 'actionicon_start.gif'
[8920]637    text = _('Start new session')
[8471]638    target = 'start_session'
[7591]639
640    @property
641    def target_url(self):
[9138]642        if self.context.next_session_allowed and self.context.is_current:
[8471]643            return self.view.url(self.view.context, self.target)
644        return False
[7591]645
[13935]646
[7591]647class AddStudyLevelActionButton(AddActionButton):
648    grok.order(1)
649    grok.context(IStudentStudyCourse)
650    grok.view(StudyCourseDisplayFormPage)
651    grok.require('waeup.handleStudent')
[7738]652    text = _('Add course list')
[7591]653    target = 'add'
654
655    @property
656    def target_url(self):
[8736]657        student = self.view.context.student
[7671]658        condition1 = student.state != PAID
[7591]659        condition2 = str(student['studycourse'].current_level) in \
660            self.view.context.keys()
[9138]661        condition3 = not self.context.is_current
662        if condition1 or condition2 or condition3:
[7591]663            return ''
664        return self.view.url(self.view.context, self.target)
665
[13935]666
[7591]667class StudyLevelEditActionButton(ManageActionButton):
[8078]668    grok.order(2)
[7591]669    grok.context(IStudentStudyLevel)
670    grok.view(StudyLevelDisplayFormPage)
[9924]671    grok.require('waeup.editStudyLevel')
[8920]672    text = _('Edit course list')
[7591]673    target = 'edit'
674
675    @property
676    def target_url(self):
[8736]677        student = self.view.context.student
[9257]678        condition1 = student.state == PAID
679        condition2 = self.view.context.is_current_level
[9138]680        is_current = self.context.__parent__.is_current
[9257]681        if condition1 and condition2 and is_current:
682            return self.view.url(self.view.context, self.target)
683        return ''
[7591]684
[13935]685
[9517]686class AddPaymentActionButton(AddActionButton):
687    grok.order(1)
688    grok.context(IStudentPaymentsContainer)
689    grok.view(PaymentsManageFormPage)
690    grok.require('waeup.payStudent')
691    text = _('Add current session payment ticket')
692    target = 'addop'
693
[13935]694
[9517]695class AddPreviousPaymentActionButton(AddActionButton):
696    grok.order(2)
697    grok.context(IStudentPaymentsContainer)
698    grok.view(PaymentsManageFormPage)
699    grok.require('waeup.payStudent')
[10811]700    grok.name('addpreviouspaymentactionbutton')
[9517]701    text = _('Add previous session payment ticket')
702    target = 'addpp'
703
704    @property
705    def target_url(self):
706        student = self.view.context.student
[10811]707        if student.before_payment or not self.target:
[9517]708            return ''
709        return self.view.url(self.view.context, self.target)
710
[13935]711
[9865]712class AddBalancePaymentActionButton(AddActionButton):
713    grok.order(3)
714    grok.context(IStudentPaymentsContainer)
715    grok.view(PaymentsManageFormPage)
[9938]716    grok.require('waeup.manageStudent')
[10810]717    grok.name('addbalancepaymentactionbutton')
[9865]718    text = _('Add balance payment ticket')
719    target = 'addbp'
720
721    @property
722    def target_url(self):
[10810]723        if not self.target:
724            return ''
[9865]725        return self.view.url(self.view.context, self.target)
726
[13935]727
[15163]728class StudyCourseTranscriptActionButton(ManageActionButton):
729    grok.order(2)
730    grok.name('transcript')
731    grok.context(IStudentStudyCourse)
732    grok.view(StudyCourseDisplayFormPage)
733    grok.require('waeup.viewTranscript')
734    text = _('Transcript')
735    target = 'transcript'
736    icon = 'actionicon_transcript.png'
737
738    @property
739    def target_url(self):
740        final_slip = getUtility(IExtFileStore).getFileByContext(
741            self.context.student, attr='final_transcript')
742        if self.context.student.transcript_enabled and not final_slip:
743            return self.view.url(self.view.context, self.target)
744        return False
745
746
[10458]747class RequestTranscriptActionButton(ManageActionButton):
748    grok.order(8)
749    grok.context(IStudent)
750    grok.view(StudentBaseDisplayFormPage)
751    grok.require('waeup.handleStudent')
752    text = _('Request transcript')
753    target = 'request_transcript'
754    icon = 'actionicon_transcript.png'
755
756    @property
757    def target_url(self):
758        if self.context.state != GRADUATED:
759            return ''
760        return self.view.url(self.view.context, self.target)
761
[13935]762
[15163]763class ValidateTranscriptActionButton(ManageActionButton):
764    grok.order(8)
765    grok.context(IStudentStudyCourse)
766    grok.view(StudyCourseTranscriptPage)
767    grok.require('waeup.processTranscript')
768    text = _('Validate transcript')
769    target = 'validate_transcript'
770    icon = 'actionicon_transcript.png'
771
772    @property
773    def target_url(self):
774        if self.context.student.state != TRANSREQ:
775            return ''
776        return self.view.url(self.view.context, self.target)
777
778
779class ReleaseTranscriptActionButton(ManageActionButton):
780    grok.order(8)
781    grok.context(IStudentStudyCourse)
782    grok.view(StudyCourseTranscriptPage)
783    grok.require('waeup.processTranscript')
784    text = _('Release transcript')
785    target = 'release_transcript'
786    icon = 'actionicon_transcript.png'
787
788    @property
789    def target_url(self):
790        if self.context.student.state != TRANSVAL:
791            return ''
792        return self.view.url(self.view.context, self.target)
793
794
795class TranscriptSlipActionButton(ManageActionButton):
796    grok.order(1)
797    grok.name('transcript_slip')
798    grok.context(IStudentStudyCourse)
799    grok.view(StudyCourseTranscriptPage)
[10459]800    grok.require('waeup.viewTranscript')
[15163]801    text = _('Academic Transcript')
802    target = 'transcript.pdf'
803    icon = 'actionicon_pdf.png'
804
805    @property
806    def target_url(self):
807        final_slip = getUtility(IExtFileStore).getFileByContext(
808            self.context.student, attr='final_transcript')
809        if self.context.student.transcript_enabled \
810            and not final_slip:
811            return self.view.url(self.view.context, self.target)
812        return False
813
814
815class SignTranscriptActionButton(ManageActionButton):
816    grok.order(2)
817    grok.context(IStudentStudyCourse)
818    grok.view(StudyCourseTranscriptPage)
819    grok.require('waeup.signTranscript')
820    text = _('Sign transcript electronically')
821    target = 'sign_transcript'
[10458]822    icon = 'actionicon_transcript.png'
823
824    @property
825    def target_url(self):
[15163]826        if self.context.student.state != TRANSVAL:
[10458]827            return ''
828        return self.view.url(self.view.context, self.target)
829
[15163]830    @property
831    def onclick(self):
832        return "return window.confirm(%s);" % _(
833            "'Signing a transcript electronically cannot be revoked. "
834            "The electronic signature replaces your handwritten signature.\\n\\n"
835            "You really want to sign the transcript?'")
[13935]836
[15163]837
[7184]838class StudentsTab(PrimaryNavTab):
839    """Students tab in primary navigation.
840    """
[7819]841    grok.context(IKofaObject)
[7184]842    grok.order(4)
[12843]843    grok.require('waeup.viewStudentsContainer')
[10771]844    grok.name('studentstab')
[7184]845
846    pnav = 4
[7674]847    tab_title = _(u'Students')
[7184]848
849    @property
850    def link_target(self):
851        return self.view.application_url('students')
852
[13935]853
[6687]854class PrimaryStudentNavManager(grok.ViewletManager):
855    """Viewlet manager for the primary navigation tab.
856    """
857    grok.name('primary_nav_student')
858
[13935]859
[6687]860class PrimaryStudentNavTab(grok.Viewlet):
861    """Base for primary student nav tabs.
862    """
863    grok.baseclass()
[10816]864    grok.context(IKofaObject)
[6687]865    grok.viewletmanager(PrimaryStudentNavManager)
[7243]866    template = default_primary_nav_template
[6687]867    grok.order(1)
[7184]868    grok.require('waeup.Authenticated')
[8467]869    pnav = 0
[6687]870    tab_title = u'Some Text'
871
872    @property
873    def link_target(self):
874        return self.view.application_url()
875
876    @property
877    def active(self):
878        view_pnav = getattr(self.view, 'pnav', 0)
879        if view_pnav == self.pnav:
880            return 'active'
881        return ''
882
[13935]883
[7240]884class MyStudentDataTab(PrimaryStudentNavTab):
[7459]885    """MyData dropdown tab in primary navigation.
[6687]886    """
887    grok.order(3)
[7240]888    grok.require('waeup.viewMyStudentDataTab')
[7459]889    grok.template('mydatadropdowntabs')
[10816]890    grok.name('mystudentdatatab')
[6687]891    pnav = 4
[7738]892    tab_title = _(u'My Data')
[6687]893
894    @property
[7459]895    def active(self):
896        view_pnav = getattr(self.view, 'pnav', 0)
897        if view_pnav == self.pnav:
898            return 'active dropdown'
899        return 'dropdown'
[7097]900
[7459]901    @property
902    def targets(self):
[9180]903        student = grok.getSite()['students'][self.request.principal.id]
904        student_url = self.view.url(student)
[9178]905        app_slip = getUtility(IExtFileStore).getFileByContext(
[9180]906            student, 'application_slip')
[7459]907        targets = []
[9178]908        if app_slip:
[13935]909            targets = [{'url': student_url + '/application_slip',
910                        'title': _('Application Slip')}, ]
[7459]911        targets += [
[13935]912            {'url': student_url, 'title': 'Base Data'},
913            {'url': student_url + '/view_clearance',
914             'title': _('Clearance Data')},
915            {'url': student_url + '/view_personal',
916             'title': _('Personal Data')},
917            {'url': student_url + '/studycourse', 'title': _('Study Course')},
918            {'url': student_url + '/payments', 'title': _('Payments')},
919            {'url': student_url + '/accommodation',
920             'title': _('Accommodation Data')},
921            {'url': student_url + '/history', 'title': _('History')},
[7459]922            ]
923        return targets
[13935]924
925
926class DownloadCSVFileActionButton(ManageActionButton):
927    """ 'Download csv file' button for courses.
928    """
929    grok.context(ICourse)
930    grok.view(EditScoresPage)
931    grok.name('downloadcsv')
932    grok.require('waeup.editScores')
933    icon = 'actionicon_down.png'
[13936]934    text = _('Download csv file (editable scores only)')
[13935]935    target = 'download_scores'
936    grok.order(1)
937
938
939class DownloadTicketOverviewActionButton(ManageActionButton):
940    """ 'Download ticket overview' button for courses.
941    """
942    grok.context(ICourse)
943    grok.view(EditScoresPage)
944    grok.name('coursetickets')
945    grok.require('waeup.editScores')
946    icon = 'actionicon_pdf.png'
947    text = _('Download pdf file')
948    target = 'coursetickets.pdf'
949    grok.order(2)
Note: See TracBrowser for help on using the repository browser.