Ignore:
Timestamp:
6 Feb 2012, 16:57:37 (13 years ago)
Author:
Henrik Bettermann
Message:

Move all action button viewlets from browser module to viewlets module.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/students
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r7549 r7591  
    3636    SIRPPage, SIRPEditFormPage, SIRPAddFormPage, SIRPDisplayFormPage,
    3737    ContactAdminForm, SIRPForm)
    38 from waeup.sirp.browser.interfaces import ICaptchaManager, IBreadcrumbIgnorable
     38from waeup.sirp.browser.interfaces import ICaptchaManager
    3939from waeup.sirp.browser.breadcrumbs import Breadcrumb
    4040from waeup.sirp.browser.resources import datepicker, datatable, tabs, warning
    41 from waeup.sirp.browser.viewlets import (
    42     ManageActionButton, AddActionButton)
    4341from waeup.sirp.browser.layout import jsaction, action, UtilityView
    4442from waeup.sirp.interfaces import (
     
    6260from waeup.sirp.students.vocabularies import StudyLevelSource
    6361from waeup.sirp.browser.resources import toggleall
    64 from waeup.sirp.applicants.interfaces import IApplicantBaseData
    6562from waeup.sirp.hostels.hostel import NOT_OCCUPIED
    6663from waeup.sirp.utils.helpers import get_current_principal
     
    248245        return
    249246
    250 class StudentsContainerManageActionButton(ManageActionButton):
    251     grok.order(1)
    252     grok.context(IStudentsContainer)
    253     grok.view(StudentsContainerPage)
    254     grok.require('waeup.manageStudent')
    255     text = 'Manage student section'
    256 
    257 
    258247class StudentsContainerManagePage(SIRPPage):
    259248    """The manage page for student containers.
     
    304293        return
    305294
    306 class StudentsContainerAddActionButton(AddActionButton):
    307     grok.order(1)
    308     grok.context(IStudentsContainer)
    309     grok.view(StudentsContainerManagePage)
    310     grok.require('waeup.manageStudent')
    311     text = 'Add student'
    312     target = 'addstudent'
    313 
    314295class StudentAddFormPage(SIRPAddFormPage):
    315296    """Add-form to add a student.
     
    351332            return 'set'
    352333        return 'unset'
    353 
    354 class ContactActionButton(ManageActionButton):
    355     grok.order(4)
    356     grok.context(IStudent)
    357     grok.view(StudentBaseDisplayFormPage)
    358     grok.require('waeup.manageStudent')
    359     icon = 'actionicon_mail.png'
    360     text = 'Send email'
    361     target = 'contactstudent'
    362334
    363335class ContactStudentForm(ContactAdminForm):
     
    397369        return
    398370
    399 class StudentBaseManageActionButton(ManageActionButton):
    400     grok.order(1)
    401     grok.context(IStudent)
    402     grok.view(StudentBaseDisplayFormPage)
    403     grok.require('waeup.manageStudent')
    404     text = 'Manage'
    405     target = 'manage_base'
    406 
    407371class StudentBaseManageFormPage(SIRPEditFormPage):
    408372    """ View to manage student base data
     
    484448        return '%s: Clearance Data' % self.context.display_fullname
    485449
    486 class StudentClearanceManageActionButton(ManageActionButton):
    487     grok.order(1)
    488     grok.context(IStudent)
    489     grok.view(StudentClearanceDisplayFormPage)
    490     grok.require('waeup.manageStudent')
    491     text = 'Manage'
    492     target = 'edit_clearance'
    493 
    494 class StudentClearActionButton(ManageActionButton):
    495     grok.order(2)
    496     grok.context(IStudent)
    497     grok.view(StudentClearanceDisplayFormPage)
    498     grok.require('waeup.clearStudent')
    499     text = 'Clear student'
    500     target = 'clear'
    501     icon = 'actionicon_accept.png'
    502 
    503     @property
    504     def target_url(self):
    505         if self.context.state != REQUESTED:
    506             return ''
    507         return self.view.url(self.view.context, self.target)
    508 
    509 class StudentRejectClearanceActionButton(ManageActionButton):
    510     grok.order(3)
    511     grok.context(IStudent)
    512     grok.view(StudentClearanceDisplayFormPage)
    513     grok.require('waeup.clearStudent')
    514     text = 'Reject clearance'
    515     target = 'reject_clearance'
    516     icon = 'actionicon_reject.png'
    517 
    518     @property
    519     def target_url(self):
    520         if self.context.state not in (REQUESTED, CLEARED):
    521             return ''
    522         return self.view.url(self.view.context, self.target)
    523 
    524 class ClearanceSlipActionButton(ManageActionButton):
    525     grok.order(4)
    526     grok.context(IStudent)
    527     grok.view(StudentClearanceDisplayFormPage)
    528     grok.require('waeup.viewStudent')
    529     icon = 'actionicon_pdf.png'
    530     text = 'Download clearance slip'
    531     target = 'clearance.pdf'
    532 
    533450class ExportPDFClearanceSlipPage(grok.View):
    534451    """Deliver a PDF slip of the context.
     
    642559        return '%s: Personal Data' % self.context.display_fullname
    643560
    644 class StudentPersonalEditActionButton(ManageActionButton):
    645     grok.order(1)
    646     grok.context(IStudent)
    647     grok.view(StudentPersonalDisplayFormPage)
    648     grok.require('waeup.viewStudent')
    649     text = 'Edit'
    650     target = 'edit_personal'
    651 
    652561class StudentPersonalManageFormPage(SIRPEditFormPage):
    653562    """ Page to edit student clearance data
     
    698607            return self.context.certificate.__parent__.__parent__.__parent__
    699608        return
    700 
    701 class StudyCourseManageActionButton(ManageActionButton):
    702     grok.order(1)
    703     grok.context(IStudentStudyCourse)
    704     grok.view(StudyCourseDisplayFormPage)
    705     grok.require('waeup.manageStudent')
    706     text = 'Manage'
    707     target = 'manage'
    708609
    709610class StudyCourseManageFormPage(SIRPEditFormPage):
     
    809710            total_credits += val.credits
    810711        return total_credits
    811 
    812 class CourseRegistrationSlipActionButton(ManageActionButton):
    813     grok.order(1)
    814     grok.context(IStudentStudyLevel)
    815     grok.view(StudyLevelDisplayFormPage)
    816     grok.require('waeup.viewStudent')
    817     icon = 'actionicon_pdf.png'
    818     text = 'Download course registration slip'
    819     target = 'course_registration.pdf'
    820712
    821713class ExportPDFCourseRegistrationSlipPage(UtilityView, grok.View):
     
    852744            tabledata=tabledata)
    853745
    854 class StudyLevelManageActionButton(ManageActionButton):
    855     grok.order(2)
    856     grok.context(IStudentStudyLevel)
    857     grok.view(StudyLevelDisplayFormPage)
    858     grok.require('waeup.manageStudent')
    859     text = 'Manage'
    860     target = 'manage'
    861 
    862 class StudentValidateCoursesActionButton(ManageActionButton):
    863     grok.order(3)
    864     grok.context(IStudentStudyLevel)
    865     grok.view(StudyLevelDisplayFormPage)
    866     grok.require('waeup.validateStudent')
    867     text = 'Validate courses'
    868     target = 'validate_courses'
    869     icon = 'actionicon_accept.png'
    870 
    871     @property
    872     def target_url(self):
    873         if self.context.getStudent().state != REGISTERED or \
    874             str(self.context.__parent__.current_level) != self.context.__name__:
    875             return ''
    876         return self.view.url(self.view.context, self.target)
    877 
    878 class StudentRejectCoursesActionButton(ManageActionButton):
    879     grok.order(4)
    880     grok.context(IStudentStudyLevel)
    881     grok.view(StudyLevelDisplayFormPage)
    882     grok.require('waeup.validateStudent')
    883     text = 'Reject courses'
    884     target = 'reject_courses'
    885     icon = 'actionicon_reject.png'
    886 
    887     @property
    888     def target_url(self):
    889         if self.context.getStudent().state not in (VALIDATED, REGISTERED) or \
    890             str(self.context.__parent__.current_level) != self.context.__name__:
    891             return ''
    892         return self.view.url(self.view.context, self.target)
    893 
    894746class StudyLevelManageFormPage(SIRPEditFormPage):
    895747    """ Page to edit the student study level data
     
    1058910            self.context.getStudent().display_fullname,self.context.code)
    1059911
    1060 class CourseTicketManageActionButton(ManageActionButton):
    1061     grok.order(1)
    1062     grok.context(ICourseTicket)
    1063     grok.view(CourseTicketDisplayFormPage)
    1064     grok.require('waeup.manageStudent')
    1065     text = 'Manage'
    1066     target = 'manage'
    1067 
    1068912class CourseTicketManageFormPage(SIRPEditFormPage):
    1069913    """ Page to manage course tickets
     
    11621006    def addPaymentTicket(self, **data):
    11631007        self.redirect(self.url(self.context, '@@addop'))
    1164 
    1165 #class OnlinePaymentManageActionButton(ManageActionButton):
    1166 #    grok.order(1)
    1167 #    grok.context(IStudentPaymentsContainer)
    1168 #    grok.view(PaymentsDisplayFormPage)
    1169 #    grok.require('waeup.manageStudent')
    1170 #    text = 'Manage payments'
    1171 #    target = 'manage'
    11721008
    11731009class OnlinePaymentAddFormPage(SIRPAddFormPage):
     
    12431079        return '%s: Online Payment Ticket %s' % (
    12441080            self.context.getStudent().display_fullname,self.context.p_id)
    1245 
    1246 class PaymentReceiptActionButton(ManageActionButton):
    1247     grok.order(1)
    1248     grok.context(IStudentOnlinePayment)
    1249     grok.view(OnlinePaymentDisplayFormPage)
    1250     grok.require('waeup.viewStudent')
    1251     icon = 'actionicon_pdf.png'
    1252     text = 'Download payment receipt'
    1253     target = 'payment_receipt.pdf'
    1254 
    1255     @property
    1256     def target_url(self):
    1257         if self.context.p_state != 'paid':
    1258             return ''
    1259         return self.view.url(self.view.context, self.target)
    1260 
    1261 class RequestCallbackActionButton(ManageActionButton):
    1262     grok.order(2)
    1263     grok.context(IStudentOnlinePayment)
    1264     grok.view(OnlinePaymentDisplayFormPage)
    1265     grok.require('waeup.payStudent')
    1266     icon = 'actionicon_call.png'
    1267     text = 'Request callback'
    1268     target = 'callback'
    1269 
    1270     @property
    1271     def target_url(self):
    1272         if self.context.p_state != 'unpaid':
    1273             return ''
    1274         return self.view.url(self.view.context, self.target)
    12751081
    12761082class OnlinePaymentCallbackPage(UtilityView, grok.View):
     
    14201226        return sa
    14211227
    1422 class AddBedTicketActionButton(ManageActionButton):
    1423     grok.order(1)
    1424     grok.context(IStudentAccommodation)
    1425     grok.view(AccommodationManageFormPage)
    1426     grok.require('waeup.handleAccommodation')
    1427     icon = 'actionicon_home.png'
    1428     text = 'Book accommodation'
    1429     target = 'add'
    1430 
    14311228class BedTicketAddPage(SIRPPage):
    14321229    """ Page to add an online payment ticket
     
    15381335        return 'Bed Ticket for Session %s' % self.context.getSessionString()
    15391336
    1540 class BedTicketSlipActionButton(ManageActionButton):
    1541     grok.order(1)
    1542     grok.context(IBedTicket)
    1543     grok.view(BedTicketDisplayFormPage)
    1544     grok.require('waeup.handleAccommodation')
    1545     icon = 'actionicon_pdf.png'
    1546     text = 'Download bed allocation slip'
    1547     target = 'bed_allocation.pdf'
    1548 
    15491337class ExportPDFBedTicketSlipPage(UtilityView, grok.View):
    15501338    """Deliver a PDF slip of the context.
     
    15691357            self, 'bed_allocation.pdf',
    15701358            self.context.getStudent(), studentview)
    1571 
    1572 class RelocateStudentActionButton(ManageActionButton):
    1573     grok.order(2)
    1574     grok.context(IBedTicket)
    1575     grok.view(BedTicketDisplayFormPage)
    1576     grok.require('waeup.manageHostels')
    1577     icon = 'actionicon_reload.png'
    1578     text = 'Relocate student'
    1579     target = 'relocate'
    15801359
    15811360class BedTicketRelocationPage(UtilityView, grok.View):
     
    16611440# Pages for students only
    16621441
    1663 class StudentBaseActionButton(ManageActionButton):
    1664     grok.order(1)
    1665     grok.context(IStudent)
    1666     grok.view(StudentBaseDisplayFormPage)
    1667     grok.require('waeup.handleStudent')
    1668     text = 'Edit base data'
    1669     target = 'edit_base'
    1670 
    1671 class StudentPasswordActionButton(ManageActionButton):
    1672     grok.order(2)
    1673     grok.context(IStudent)
    1674     grok.view(StudentBaseDisplayFormPage)
    1675     grok.require('waeup.handleStudent')
    1676     icon = 'actionicon_key.png'
    1677     text = 'Change password'
    1678     target = 'change_password'
    1679 
    1680 class StudentPassportActionButton(ManageActionButton):
    1681     grok.order(3)
    1682     grok.context(IStudent)
    1683     grok.view(StudentBaseDisplayFormPage)
    1684     grok.require('waeup.handleStudent')
    1685     icon = 'actionicon_portrait.png'
    1686     text = 'Change portrait'
    1687     target = 'change_portrait'
    1688 
    1689     @property
    1690     def target_url(self):
    1691         if self.context.state != 'admitted':
    1692             return ''
    1693         return self.view.url(self.view.context, self.target)
    1694 
    16951442class StudentBaseEditFormPage(SIRPEditFormPage):
    16961443    """ View to edit student base data
     
    17521499        return
    17531500
    1754 class StudentClearanceStartActionButton(ManageActionButton):
    1755     grok.order(1)
    1756     grok.context(IStudent)
    1757     grok.view(StudentClearanceDisplayFormPage)
    1758     grok.require('waeup.handleStudent')
    1759     icon = 'actionicon_start.gif'
    1760     text = 'Start clearance'
    1761     target = 'start_clearance'
    1762 
    1763     @property
    1764     def target_url(self):
    1765         if self.context.state != 'admitted':
    1766             return ''
    1767         return self.view.url(self.view.context, self.target)
    1768 
    17691501class StartClearancePage(SIRPPage):
    17701502    grok.context(IStudent)
     
    18321564        return
    18331565
    1834 class StudentClearanceEditActionButton(ManageActionButton):
    1835     grok.order(1)
    1836     grok.context(IStudent)
    1837     grok.view(StudentClearanceDisplayFormPage)
    1838     grok.require('waeup.handleStudent')
    1839     text = 'Edit'
    1840     target = 'cedit'
    1841 
    1842     @property
    1843     def target_url(self):
    1844         if self.context.clearance_locked:
    1845             return ''
    1846         return self.view.url(self.view.context, self.target)
    1847 
    18481566class StudentClearanceEditFormPage(StudentClearanceManageFormPage):
    18491567    """ View to edit student clearance data by student
     
    19171635        self.redirect(self.url(self.context))
    19181636        return
    1919 
    1920 class CourseRegistrationStartActionButton(ManageActionButton):
    1921     grok.order(1)
    1922     grok.context(IStudentStudyCourse)
    1923     grok.view(StudyCourseDisplayFormPage)
    1924     grok.require('waeup.handleStudent')
    1925     icon = 'actionicon_start.gif'
    1926     text = 'Start course registration'
    1927     target = 'start_course_registration'
    1928 
    1929     @property
    1930     def target_url(self):
    1931         if not self.context.getStudent().state in (CLEARED,RETURNING):
    1932             return ''
    1933         return self.view.url(self.view.context, self.target)
    19341637
    19351638class StartCourseRegistrationPage(SIRPPage):
     
    19821685        return
    19831686
    1984 
    1985 class AddStudyLevelActionButton(AddActionButton):
    1986     grok.order(1)
    1987     grok.context(IStudentStudyCourse)
    1988     grok.view(StudyCourseDisplayFormPage)
    1989     grok.require('waeup.handleStudent')
    1990     text = 'Add course list'
    1991     target = 'add'
    1992 
    1993     @property
    1994     def target_url(self):
    1995         student = self.view.context.getStudent()
    1996         condition1 = student.state != 'school fee paid'
    1997         condition2 = str(student['studycourse'].current_level) in \
    1998             self.view.context.keys()
    1999         if condition1 or condition2:
    2000             return ''
    2001         return self.view.url(self.view.context, self.target)
    2002 
    20031687class AddStudyLevelFormPage(SIRPEditFormPage):
    20041688    """ Page for students to add current study levels
     
    20371721        self.redirect(self.url(self.context))
    20381722        return
    2039 
    2040 class StudyLevelEditActionButton(ManageActionButton):
    2041     grok.order(1)
    2042     grok.context(IStudentStudyLevel)
    2043     grok.view(StudyLevelDisplayFormPage)
    2044     grok.require('waeup.handleStudent')
    2045     text = 'Add and remove courses'
    2046     target = 'edit'
    2047 
    2048     @property
    2049     def target_url(self):
    2050         student = self.view.context.getStudent()
    2051         condition1 = student.state != 'school fee paid'
    2052         condition2 = student[
    2053             'studycourse'].current_level != self.view.context.level
    2054         if condition1 or condition2:
    2055             return ''
    2056         return self.view.url(self.view.context, self.target)
    20571723
    20581724class StudyLevelEditFormPage(SIRPEditFormPage):
  • main/waeup.sirp/trunk/src/waeup/sirp/students/viewlets.py

    r7491 r7591  
    2424from waeup.sirp.utils.helpers import string_from_bytes, file_size
    2525from waeup.sirp.browser import DEFAULT_IMAGE_PATH
    26 from waeup.sirp.browser.viewlets import PrimaryNavTab, PlainActionButton
     26from waeup.sirp.browser.viewlets import (
     27    PrimaryNavTab, ManageActionButton, AddActionButton)
    2728from waeup.sirp.browser.layout import default_primary_nav_template
     29from waeup.sirp.students.workflow import (ADMITTED, PAID,
     30    CLEARANCE, REQUESTED, RETURNING, CLEARED, REGISTERED, VALIDATED)
    2831from waeup.sirp.students.browser import (
    29     StudentClearanceDisplayFormPage, StudentClearanceManageFormPage,
    30     write_log_message, StudentBaseManageFormPage, StudentBaseDisplayFormPage,
    31     StudentFilesUploadPage, ExportPDFClearanceSlipPage)
    32 from waeup.sirp.students.interfaces import IStudent, IStudentClearance
     32    StudentClearanceManageFormPage,
     33    write_log_message, StudentBaseManageFormPage,
     34    StudentFilesUploadPage, ExportPDFClearanceSlipPage, StudentsContainerPage,
     35    StudentsContainerManagePage, StudentBaseDisplayFormPage,
     36    StudentClearanceDisplayFormPage, StudentPersonalDisplayFormPage,
     37    StudyCourseDisplayFormPage, StudyLevelDisplayFormPage,
     38    CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage,
     39    AccommodationManageFormPage, BedTicketDisplayFormPage,)
     40from waeup.sirp.students.interfaces import (
     41    IStudentsContainer, IStudent, IStudentClearance,
     42    IStudentStudyCourse, IStudentAccommodation, IStudentStudyLevel,
     43    ICourseTicket, IStudentOnlinePayment, IBedTicket,
     44    )
    3345
    3446grok.context(ISIRPObject) # Make ISIRPObject the default context
     
    110122    link = 'history'
    111123    text = u'History'
     124
     125
     126class StudentsContainerManageActionButton(ManageActionButton):
     127    grok.order(1)
     128    grok.context(IStudentsContainer)
     129    grok.view(StudentsContainerPage)
     130    grok.require('waeup.manageStudent')
     131    text = 'Manage student section'
     132
     133class StudentsContainerAddActionButton(AddActionButton):
     134    grok.order(1)
     135    grok.context(IStudentsContainer)
     136    grok.view(StudentsContainerManagePage)
     137    grok.require('waeup.manageStudent')
     138    text = 'Add student'
     139    target = 'addstudent'
     140
     141class ContactActionButton(ManageActionButton):
     142    grok.order(4)
     143    grok.context(IStudent)
     144    grok.view(StudentBaseDisplayFormPage)
     145    grok.require('waeup.manageStudent')
     146    icon = 'actionicon_mail.png'
     147    text = 'Send email'
     148    target = 'contactstudent'
     149
     150class StudentBaseManageActionButton(ManageActionButton):
     151    grok.order(1)
     152    grok.context(IStudent)
     153    grok.view(StudentBaseDisplayFormPage)
     154    grok.require('waeup.manageStudent')
     155    text = 'Manage'
     156    target = 'manage_base'
     157
     158class StudentClearanceManageActionButton(ManageActionButton):
     159    grok.order(1)
     160    grok.context(IStudent)
     161    grok.view(StudentClearanceDisplayFormPage)
     162    grok.require('waeup.manageStudent')
     163    text = 'Manage'
     164    target = 'edit_clearance'
     165
     166class StudentClearActionButton(ManageActionButton):
     167    grok.order(2)
     168    grok.context(IStudent)
     169    grok.view(StudentClearanceDisplayFormPage)
     170    grok.require('waeup.clearStudent')
     171    text = 'Clear student'
     172    target = 'clear'
     173    icon = 'actionicon_accept.png'
     174
     175    @property
     176    def target_url(self):
     177        if self.context.state != REQUESTED:
     178            return ''
     179        return self.view.url(self.view.context, self.target)
     180
     181class StudentRejectClearanceActionButton(ManageActionButton):
     182    grok.order(3)
     183    grok.context(IStudent)
     184    grok.view(StudentClearanceDisplayFormPage)
     185    grok.require('waeup.clearStudent')
     186    text = 'Reject clearance'
     187    target = 'reject_clearance'
     188    icon = 'actionicon_reject.png'
     189
     190    @property
     191    def target_url(self):
     192        if self.context.state not in (REQUESTED, CLEARED):
     193            return ''
     194        return self.view.url(self.view.context, self.target)
     195
     196class ClearanceSlipActionButton(ManageActionButton):
     197    grok.order(4)
     198    grok.context(IStudent)
     199    grok.view(StudentClearanceDisplayFormPage)
     200    grok.require('waeup.viewStudent')
     201    icon = 'actionicon_pdf.png'
     202    text = 'Download clearance slip'
     203    target = 'clearance.pdf'
     204
     205class StudentPersonalEditActionButton(ManageActionButton):
     206    grok.order(1)
     207    grok.context(IStudent)
     208    grok.view(StudentPersonalDisplayFormPage)
     209    grok.require('waeup.viewStudent')
     210    text = 'Edit'
     211    target = 'edit_personal'
     212
     213class StudyCourseManageActionButton(ManageActionButton):
     214    grok.order(1)
     215    grok.context(IStudentStudyCourse)
     216    grok.view(StudyCourseDisplayFormPage)
     217    grok.require('waeup.manageStudent')
     218    text = 'Manage'
     219    target = 'manage'
     220
     221class CourseRegistrationSlipActionButton(ManageActionButton):
     222    grok.order(1)
     223    grok.context(IStudentStudyLevel)
     224    grok.view(StudyLevelDisplayFormPage)
     225    grok.require('waeup.viewStudent')
     226    icon = 'actionicon_pdf.png'
     227    text = 'Download course registration slip'
     228    target = 'course_registration.pdf'
     229
     230class StudyLevelManageActionButton(ManageActionButton):
     231    grok.order(2)
     232    grok.context(IStudentStudyLevel)
     233    grok.view(StudyLevelDisplayFormPage)
     234    grok.require('waeup.manageStudent')
     235    text = 'Manage'
     236    target = 'manage'
     237
     238class StudentValidateCoursesActionButton(ManageActionButton):
     239    grok.order(3)
     240    grok.context(IStudentStudyLevel)
     241    grok.view(StudyLevelDisplayFormPage)
     242    grok.require('waeup.validateStudent')
     243    text = 'Validate courses'
     244    target = 'validate_courses'
     245    icon = 'actionicon_accept.png'
     246
     247    @property
     248    def target_url(self):
     249        if self.context.getStudent().state != REGISTERED or \
     250            str(self.context.__parent__.current_level) != self.context.__name__:
     251            return ''
     252        return self.view.url(self.view.context, self.target)
     253
     254class StudentRejectCoursesActionButton(ManageActionButton):
     255    grok.order(4)
     256    grok.context(IStudentStudyLevel)
     257    grok.view(StudyLevelDisplayFormPage)
     258    grok.require('waeup.validateStudent')
     259    text = 'Reject courses'
     260    target = 'reject_courses'
     261    icon = 'actionicon_reject.png'
     262
     263    @property
     264    def target_url(self):
     265        if self.context.getStudent().state not in (VALIDATED, REGISTERED) or \
     266            str(self.context.__parent__.current_level) != self.context.__name__:
     267            return ''
     268        return self.view.url(self.view.context, self.target)
     269
     270class CourseTicketManageActionButton(ManageActionButton):
     271    grok.order(1)
     272    grok.context(ICourseTicket)
     273    grok.view(CourseTicketDisplayFormPage)
     274    grok.require('waeup.manageStudent')
     275    text = 'Manage'
     276    target = 'manage'
     277
     278#class OnlinePaymentManageActionButton(ManageActionButton):
     279#    grok.order(1)
     280#    grok.context(IStudentPaymentsContainer)
     281#    grok.view(PaymentsDisplayFormPage)
     282#    grok.require('waeup.manageStudent')
     283#    text = 'Manage payments'
     284#    target = 'manage'
     285
     286class PaymentReceiptActionButton(ManageActionButton):
     287    grok.order(1)
     288    grok.context(IStudentOnlinePayment)
     289    grok.view(OnlinePaymentDisplayFormPage)
     290    grok.require('waeup.viewStudent')
     291    icon = 'actionicon_pdf.png'
     292    text = 'Download payment receipt'
     293    target = 'payment_receipt.pdf'
     294
     295    @property
     296    def target_url(self):
     297        if self.context.p_state != 'paid':
     298            return ''
     299        return self.view.url(self.view.context, self.target)
     300
     301class RequestCallbackActionButton(ManageActionButton):
     302    grok.order(2)
     303    grok.context(IStudentOnlinePayment)
     304    grok.view(OnlinePaymentDisplayFormPage)
     305    grok.require('waeup.payStudent')
     306    icon = 'actionicon_call.png'
     307    text = 'Request callback'
     308    target = 'callback'
     309
     310    @property
     311    def target_url(self):
     312        if self.context.p_state != 'unpaid':
     313            return ''
     314        return self.view.url(self.view.context, self.target)
     315
     316class AddBedTicketActionButton(ManageActionButton):
     317    grok.order(1)
     318    grok.context(IStudentAccommodation)
     319    grok.view(AccommodationManageFormPage)
     320    grok.require('waeup.handleAccommodation')
     321    icon = 'actionicon_home.png'
     322    text = 'Book accommodation'
     323    target = 'add'
     324
     325class BedTicketSlipActionButton(ManageActionButton):
     326    grok.order(1)
     327    grok.context(IBedTicket)
     328    grok.view(BedTicketDisplayFormPage)
     329    grok.require('waeup.handleAccommodation')
     330    icon = 'actionicon_pdf.png'
     331    text = 'Download bed allocation slip'
     332    target = 'bed_allocation.pdf'
     333
     334class RelocateStudentActionButton(ManageActionButton):
     335    grok.order(2)
     336    grok.context(IBedTicket)
     337    grok.view(BedTicketDisplayFormPage)
     338    grok.require('waeup.manageHostels')
     339    icon = 'actionicon_reload.png'
     340    text = 'Relocate student'
     341    target = 'relocate'
     342
     343class StudentBaseActionButton(ManageActionButton):
     344    grok.order(1)
     345    grok.context(IStudent)
     346    grok.view(StudentBaseDisplayFormPage)
     347    grok.require('waeup.handleStudent')
     348    text = 'Edit base data'
     349    target = 'edit_base'
     350
     351class StudentPasswordActionButton(ManageActionButton):
     352    grok.order(2)
     353    grok.context(IStudent)
     354    grok.view(StudentBaseDisplayFormPage)
     355    grok.require('waeup.handleStudent')
     356    icon = 'actionicon_key.png'
     357    text = 'Change password'
     358    target = 'change_password'
     359
     360class StudentPassportActionButton(ManageActionButton):
     361    grok.order(3)
     362    grok.context(IStudent)
     363    grok.view(StudentBaseDisplayFormPage)
     364    grok.require('waeup.handleStudent')
     365    icon = 'actionicon_portrait.png'
     366    text = 'Change portrait'
     367    target = 'change_portrait'
     368
     369    @property
     370    def target_url(self):
     371        if self.context.state != 'admitted':
     372            return ''
     373        return self.view.url(self.view.context, self.target)
     374
     375class StudentClearanceStartActionButton(ManageActionButton):
     376    grok.order(1)
     377    grok.context(IStudent)
     378    grok.view(StudentClearanceDisplayFormPage)
     379    grok.require('waeup.handleStudent')
     380    icon = 'actionicon_start.gif'
     381    text = 'Start clearance'
     382    target = 'start_clearance'
     383
     384    @property
     385    def target_url(self):
     386        if self.context.state != 'admitted':
     387            return ''
     388        return self.view.url(self.view.context, self.target)
     389
     390class StudentClearanceEditActionButton(ManageActionButton):
     391    grok.order(1)
     392    grok.context(IStudent)
     393    grok.view(StudentClearanceDisplayFormPage)
     394    grok.require('waeup.handleStudent')
     395    text = 'Edit'
     396    target = 'cedit'
     397
     398    @property
     399    def target_url(self):
     400        if self.context.clearance_locked:
     401            return ''
     402        return self.view.url(self.view.context, self.target)
     403
     404class CourseRegistrationStartActionButton(ManageActionButton):
     405    grok.order(1)
     406    grok.context(IStudentStudyCourse)
     407    grok.view(StudyCourseDisplayFormPage)
     408    grok.require('waeup.handleStudent')
     409    icon = 'actionicon_start.gif'
     410    text = 'Start course registration'
     411    target = 'start_course_registration'
     412
     413    @property
     414    def target_url(self):
     415        if not self.context.getStudent().state in (CLEARED,RETURNING):
     416            return ''
     417        return self.view.url(self.view.context, self.target)
     418
     419class AddStudyLevelActionButton(AddActionButton):
     420    grok.order(1)
     421    grok.context(IStudentStudyCourse)
     422    grok.view(StudyCourseDisplayFormPage)
     423    grok.require('waeup.handleStudent')
     424    text = 'Add course list'
     425    target = 'add'
     426
     427    @property
     428    def target_url(self):
     429        student = self.view.context.getStudent()
     430        condition1 = student.state != 'school fee paid'
     431        condition2 = str(student['studycourse'].current_level) in \
     432            self.view.context.keys()
     433        if condition1 or condition2:
     434            return ''
     435        return self.view.url(self.view.context, self.target)
     436
     437class StudyLevelEditActionButton(ManageActionButton):
     438    grok.order(1)
     439    grok.context(IStudentStudyLevel)
     440    grok.view(StudyLevelDisplayFormPage)
     441    grok.require('waeup.handleStudent')
     442    text = 'Add and remove courses'
     443    target = 'edit'
     444
     445    @property
     446    def target_url(self):
     447        student = self.view.context.getStudent()
     448        condition1 = student.state != 'school fee paid'
     449        condition2 = student[
     450            'studycourse'].current_level != self.view.context.level
     451        if condition1 or condition2:
     452            return ''
     453        return self.view.url(self.view.context, self.target)
    112454
    113455class StudentsTab(PrimaryNavTab):
Note: See TracChangeset for help on using the changeset viewer.