Ignore:
Timestamp:
14 Jun 2016, 01:38:12 (8 years ago)
Author:
uli
Message:

Merge changes from uli-scores-upload back into trunk.

Location:
main/waeup.kofa/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk

  • main/waeup.kofa/trunk/src/waeup/kofa

  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r13610 r13935  
    1818import grok
    1919from zope.component import getUtility
     20from zope.i18n import translate
    2021from zope.interface import Interface
    21 from zope.i18n import translate
    22 from waeup.kofa.interfaces import IExtFileStore, IKofaObject
    23 from waeup.kofa.interfaces import MessageFactory as _
     22from waeup.kofa.browser.layout import default_primary_nav_template
    2423from waeup.kofa.browser.viewlets import (
    2524    PrimaryNavTab, ManageActionButton, AddActionButton)
    26 from waeup.kofa.browser.layout import default_primary_nav_template
    27 from waeup.kofa.students.workflow import (
    28     ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
    29     VALIDATED, GRADUATED, TRANSCRIPT)
     25from waeup.kofa.interfaces import MessageFactory as _
     26from waeup.kofa.interfaces import IExtFileStore, IKofaObject
    3027from waeup.kofa.students.browser import (
    31     StudentsContainerPage,
    32     StudentsContainerManagePage, StudentBaseDisplayFormPage,
    33     StudentClearanceDisplayFormPage, StudentPersonalDisplayFormPage,
    34     StudyCourseDisplayFormPage, StudyLevelDisplayFormPage,
    35     CourseTicketDisplayFormPage, OnlinePaymentDisplayFormPage,
    36     AccommodationManageFormPage, BedTicketDisplayFormPage,
     28    StudentsContainerPage, StudentsContainerManagePage,
     29    StudentBaseDisplayFormPage, StudentClearanceDisplayFormPage,
     30    StudentPersonalDisplayFormPage, StudyCourseDisplayFormPage,
     31    StudyLevelDisplayFormPage, CourseTicketDisplayFormPage,
     32    OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage,
    3733    StudentClearanceEditFormPage, StudentPersonalEditFormPage,
    38     PaymentsManageFormPage, StudyCourseTranscriptPage)
     34    PaymentsManageFormPage, StudyCourseTranscriptPage, EditScoresPage)
    3935from waeup.kofa.students.interfaces import (
    40     IStudentsContainer, IStudent, IStudentStudyCourse, IStudentAccommodation,
    41     IStudentStudyLevel, ICourseTicket, IStudentOnlinePayment, IBedTicket,
     36    IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel,
     37    ICourseTicket, IStudentOnlinePayment, IBedTicket,
    4238    IStudentPaymentsContainer, IStudentsUtils
    4339    )
    44 
    45 grok.context(IKofaObject) # Make IKofaObject the default context
     40from waeup.kofa.students.workflow import (
     41    ADMITTED, PAID, REQUESTED, CLEARED, REGISTERED, VALIDATED, GRADUATED,
     42    TRANSCRIPT)
     43from waeup.kofa.university.interfaces import ICourse
     44
     45
     46grok.context(IKofaObject)  # Make IKofaObject the default context
    4647grok.templatedir('browser_templates')
    4748
     
    4950class StudentManageSidebar(grok.ViewletManager):
    5051    grok.name('left_studentmanage')
     52
    5153
    5254class StudentManageLink(grok.Viewlet):
     
    6971        # Here we know that the cookie has been set
    7072        lang = self.request.cookies.get('kofa.language')
    71         text = translate(self.text, 'waeup.kofa',
    72             target_language=lang)
     73        text = translate(
     74            self.text, 'waeup.kofa', target_language=lang)
    7375        if not self.link:
    7476            return ''
    7577        return u'<li><a href="%s">%s</a></li>' % (
    76                 url, text)
     78            url, text)
     79
    7780
    7881class StudentManageApplicationLink(StudentManageLink):
     
    8689        if slip:
    8790            lang = self.request.cookies.get('kofa.language')
    88             text = translate(self.text, 'waeup.kofa',
    89                 target_language=lang)
    90             url = self.view.url(self.context.student,self.link)
     91            text = translate(
     92                self.text, 'waeup.kofa', target_language=lang)
     93            url = self.view.url(self.context.student, self.link)
    9194            return u'<li><a href="%s">%s</a></li>' % (
    92                     url, text)
     95                url, text)
    9396        return ''
     97
    9498
    9599class StudentManageBaseLink(StudentManageLink):
     
    97101    link = 'index'
    98102    text = _(u'Base Data')
     103
    99104
    100105class StudentManageClearanceLink(StudentManageLink):
     
    104109    text = _(u'Clearance Data')
    105110
     111
    106112class StudentManagePersonalLink(StudentManageLink):
    107113    grok.order(4)
     
    110116    text = _(u'Personal Data')
    111117
     118
    112119class StudentManageStudyCourseLink(StudentManageLink):
    113120    grok.order(5)
    114121    link = 'studycourse'
    115122    text = _(u'Study Course')
     123
    116124
    117125class StudentManagePaymentsLink(StudentManageLink):
     
    120128    link = 'payments'
    121129    text = _(u'Payments')
     130
    122131
    123132class StudentManageAccommodationLink(StudentManageLink):
     
    128137    text = _(u'Accommodation')
    129138
     139
    130140class StudentManageHistoryLink(StudentManageLink):
    131141    grok.order(8)
     
    141151    text = _('Manage students section')
    142152
     153
    143154class StudentsContainerAddActionButton(AddActionButton):
    144155    grok.order(1)
     
    148159    text = _('Add student')
    149160    target = 'addstudent'
     161
    150162
    151163class ContactActionButton(ManageActionButton):
     
    158170    target = 'contactstudent'
    159171
     172
    160173class StudentBaseManageActionButton(ManageActionButton):
    161174    grok.order(1)
     
    165178    text = _('Manage')
    166179    target = 'manage_base'
     180
    167181
    168182class StudentTrigTransActionButton(ManageActionButton):
     
    175189    target = 'trigtrans'
    176190
     191
    177192class StudentLoginAsActionButton(ManageActionButton):
    178193    grok.order(3)
     
    184199    target = 'loginasstep1'
    185200
     201
    186202class AdmissionSlipActionButton(ManageActionButton):
    187203    grok.order(4)
     
    193209    target = 'admission_slip.pdf'
    194210
     211
    195212class StudentTransferButton(ManageActionButton):
    196213    grok.order(6)
     
    202219    icon = 'actionicon_redo.png'
    203220
     221
    204222class StudentDeactivateActionButton(ManageActionButton):
    205223    grok.order(7)
     
    222240            "'A history message will be added. Are you sure?'")
    223241
     242
    224243class StudentActivateActionButton(ManageActionButton):
    225244    grok.order(7)
     
    242261            "'A history message will be added. Are you sure?'")
    243262
     263
    244264class StudentClearanceManageActionButton(ManageActionButton):
    245265    grok.order(1)
     
    249269    text = _('Manage')
    250270    target = 'manage_clearance'
     271
    251272
    252273class StudentClearActionButton(ManageActionButton):
     
    261282    @property
    262283    def target_url(self):
    263         cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context)
     284        cdm = getUtility(
     285            IStudentsUtils).clearance_disabled_message(self.context)
    264286        if cdm:
    265287            return ''
     
    267289            return ''
    268290        return self.view.url(self.view.context, self.target)
     291
    269292
    270293class StudentRejectClearanceActionButton(ManageActionButton):
     
    279302    @property
    280303    def target_url(self):
    281         cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context)
     304        cdm = getUtility(
     305            IStudentsUtils).clearance_disabled_message(self.context)
    282306        if cdm:
    283307            return ''
     
    285309            return ''
    286310        return self.view.url(self.view.context, self.target)
     311
    287312
    288313class ClearanceSlipActionButton(ManageActionButton):
     
    295320    target = 'clearance_slip.pdf'
    296321
     322
    297323class ClearanceViewActionButton(ManageActionButton):
    298324    grok.order(1)
     
    304330    target = 'view_clearance'
    305331
     332
    306333class PersonalViewActionButton(ManageActionButton):
    307334    grok.order(1)
     
    313340    target = 'view_personal'
    314341
     342
    315343class StudentPersonalManageActionButton(ManageActionButton):
    316344    grok.order(1)
     
    321349    target = 'manage_personal'
    322350
     351
    323352class StudentPersonalEditActionButton(ManageActionButton):
    324353    grok.order(2)
     
    328357    text = _('Edit')
    329358    target = 'edit_personal'
     359
    330360
    331361class StudyCourseManageActionButton(ManageActionButton):
     
    342372            return self.view.url(self.view.context, self.target)
    343373        return False
     374
    344375
    345376class StudyCourseTranscriptActionButton(ManageActionButton):
     
    358389        return False
    359390
     391
    360392class TranscriptSlipActionButton(ManageActionButton):
    361393    grok.order(1)
     
    373405        return False
    374406
     407
    375408class RevertTransferActionButton(ManageActionButton):
    376409    grok.order(1)
     
    388421        return False
    389422
     423
    390424class StudyLevelManageActionButton(ManageActionButton):
    391425    grok.order(1)
     
    402436            return ''
    403437        return self.view.url(self.view.context, self.target)
     438
    404439
    405440class StudentValidateCoursesActionButton(ManageActionButton):
     
    414449    @property
    415450    def target_url(self):
    416         is_current = self.context.__parent__.is_current
    417         if self.context.student.state != REGISTERED or \
    418             str(self.context.__parent__.current_level) != self.context.__name__ or\
    419             not is_current:
    420             return ''
    421         return self.view.url(self.view.context, self.target)
     451        if not self.context.__parent__.is_current:
     452            return ''
     453        if self.context.student.state != REGISTERED:
     454            return ''
     455        if str(self.context.__parent__.current_level) != self.context.__name__:
     456            return ''
     457        return self.view.url(self.view.context, self.target)
     458
    422459
    423460class StudentRejectCoursesActionButton(ManageActionButton):
     
    432469    @property
    433470    def target_url(self):
    434         is_current = self.context.__parent__.is_current
    435         if self.context.student.state not in (VALIDATED, REGISTERED) or \
    436             str(self.context.__parent__.current_level) != self.context.__name__ or\
    437             not is_current:
    438             return ''
    439         return self.view.url(self.view.context, self.target)
     471        if not self.context.__parent__.is_current:
     472            return ''
     473        if self.context.student.state not in (VALIDATED, REGISTERED):
     474            return ''
     475        if str(self.context.__parent__.current_level) != self.context.__name__:
     476            return ''
     477        return self.view.url(self.view.context, self.target)
     478
    440479
    441480class StudentUnregisterCoursesActionButton(ManageActionButton):
     
    450489    @property
    451490    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)
     491        if not self.context.__parent__.is_current:
     492            return ''
     493        if self.context.student.state != REGISTERED:
     494            return ''
     495        if str(self.context.__parent__.current_level) != self.context.__name__:
     496            return ''
     497        return self.view.url(self.view.context, self.target)
     498
    458499
    459500class CourseRegistrationSlipActionButton(ManageActionButton):
     
    473514        return self.view.url(self.view.context, self.target)
    474515
     516
    475517class CourseTicketManageActionButton(ManageActionButton):
    476518    grok.order(1)
     
    481523    target = 'manage'
    482524
    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'
    490525
    491526class PaymentReceiptActionButton(ManageActionButton):
    492     grok.order(9) # This button should always be the last one.
     527    grok.order(9)  # This button should always be the last one.
    493528    grok.context(IStudentOnlinePayment)
    494529    grok.view(OnlinePaymentDisplayFormPage)
     
    503538        #    return ''
    504539        return self.view.url(self.view.context, self.target)
     540
    505541
    506542class ApprovePaymentActionButton(ManageActionButton):
     
    519555        return self.view.url(self.view.context, self.target)
    520556
     557
    521558class BedTicketSlipActionButton(ManageActionButton):
    522559    grok.order(1)
     
    528565    target = 'bed_allocation_slip.pdf'
    529566
     567
    530568class RelocateStudentActionButton(ManageActionButton):
    531569    grok.order(2)
     
    537575    target = 'relocate'
    538576
     577
    539578class StudentBaseActionButton(ManageActionButton):
    540579    grok.order(1)
     
    544583    text = _('Edit')
    545584    target = 'edit_base'
     585
    546586
    547587class StudentPasswordActionButton(ManageActionButton):
     
    554594    target = 'change_password'
    555595
     596
    556597class StudentPassportActionButton(ManageActionButton):
    557598    grok.order(3)
     
    565606    @property
    566607    def target_url(self):
    567         PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
     608        PORTRAIT_CHANGE_STATES = getUtility(
     609            IStudentsUtils).PORTRAIT_CHANGE_STATES
    568610        if self.context.state not in PORTRAIT_CHANGE_STATES:
    569611            return ''
    570612        return self.view.url(self.view.context, self.target)
     613
    571614
    572615class StudentClearanceStartActionButton(ManageActionButton):
     
    585628        return self.view.url(self.view.context, self.target)
    586629
     630
    587631class StudentClearanceEditActionButton(ManageActionButton):
    588632    grok.order(1)
     
    598642            return ''
    599643        return self.view.url(self.view.context, self.target)
     644
    600645
    601646class StartSessionActionButton(ManageActionButton):
     
    613658            return self.view.url(self.view.context, self.target)
    614659        return False
     660
    615661
    616662class AddStudyLevelActionButton(AddActionButton):
     
    632678            return ''
    633679        return self.view.url(self.view.context, self.target)
     680
    634681
    635682class StudyLevelEditActionButton(ManageActionButton):
     
    651698        return ''
    652699
     700
    653701class AddPaymentActionButton(AddActionButton):
    654702    grok.order(1)
     
    658706    text = _('Add current session payment ticket')
    659707    target = 'addop'
     708
    660709
    661710class AddPreviousPaymentActionButton(AddActionButton):
     
    675724        return self.view.url(self.view.context, self.target)
    676725
     726
    677727class AddBalancePaymentActionButton(AddActionButton):
    678728    grok.order(3)
     
    690740        return self.view.url(self.view.context, self.target)
    691741
     742
    692743class RequestTranscriptActionButton(ManageActionButton):
    693744    grok.order(8)
     
    704755            return ''
    705756        return self.view.url(self.view.context, self.target)
     757
    706758
    707759class ProcessTranscriptRequestActionButton(ManageActionButton):
     
    720772        return self.view.url(self.view.context, self.target)
    721773
     774
    722775class StudentsTab(PrimaryNavTab):
    723776    """Students tab in primary navigation.
    724777    """
    725 
    726778    grok.context(IKofaObject)
    727779    grok.order(4)
     
    736788        return self.view.application_url('students')
    737789
     790
    738791class PrimaryStudentNavManager(grok.ViewletManager):
    739792    """Viewlet manager for the primary navigation tab.
    740793    """
    741794    grok.name('primary_nav_student')
     795
    742796
    743797class PrimaryStudentNavTab(grok.Viewlet):
     
    763817            return 'active'
    764818        return ''
     819
    765820
    766821class MyStudentDataTab(PrimaryStudentNavTab):
     
    789844        targets = []
    790845        if app_slip:
    791             targets = [{'url':student_url + '/application_slip',
    792                         'title':_('Application Slip')},]
     846            targets = [{'url': student_url + '/application_slip',
     847                        'title': _('Application Slip')}, ]
    793848        targets += [
    794             {'url':student_url, 'title':'Base Data'},
    795             {'url':student_url + '/view_clearance',
    796              'title':_('Clearance Data')},
    797             {'url':student_url + '/view_personal', 'title':_('Personal Data')},
    798             {'url':student_url + '/studycourse', 'title':_('Study Course')},
    799             {'url':student_url + '/payments', 'title':_('Payments')},
    800             {'url':student_url + '/accommodation',
    801              'title':_('Accommodation Data')},
    802             {'url':student_url + '/history', 'title':_('History')},
     849            {'url': student_url, 'title': 'Base Data'},
     850            {'url': student_url + '/view_clearance',
     851             'title': _('Clearance Data')},
     852            {'url': student_url + '/view_personal',
     853             'title': _('Personal Data')},
     854            {'url': student_url + '/studycourse', 'title': _('Study Course')},
     855            {'url': student_url + '/payments', 'title': _('Payments')},
     856            {'url': student_url + '/accommodation',
     857             'title': _('Accommodation Data')},
     858            {'url': student_url + '/history', 'title': _('History')},
    803859            ]
    804860        return targets
     861
     862
     863class DownloadCSVFileActionButton(ManageActionButton):
     864    """ 'Download csv file' button for courses.
     865    """
     866    grok.context(ICourse)
     867    grok.view(EditScoresPage)
     868    grok.name('downloadcsv')
     869    grok.require('waeup.editScores')
     870    icon = 'actionicon_down.png'
     871    text = _('Download editable tickets')
     872    target = 'download_scores'
     873    grok.order(1)
     874
     875
     876class DownloadTicketOverviewActionButton(ManageActionButton):
     877    """ 'Download ticket overview' button for courses.
     878    """
     879    grok.context(ICourse)
     880    grok.view(EditScoresPage)
     881    grok.name('coursetickets')
     882    grok.require('waeup.editScores')
     883    icon = 'actionicon_pdf.png'
     884    text = _('Download pdf file')
     885    target = 'coursetickets.pdf'
     886    grok.order(2)
Note: See TracChangeset for help on using the changeset viewer.