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

Last change on this file since 13621 was 13610, checked in by Henrik Bettermann, 9 years ago

Add button and view which allow students to unregister their
current course list unless the courses have not been validated.

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