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

Last change on this file since 14195 was 14158, checked in by Henrik Bettermann, 8 years ago

Name viewlet.

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