Ignore:
Timestamp:
11 Jun 2016, 13:59:58 (9 years ago)
Author:
uli
Message:

pep8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/uli-scores-upload/src/waeup/kofa/students/viewlets.py

    r13913 r13915  
    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 (
    3128    StudentsContainerPage,
     
    4239    IStudentPaymentsContainer, IStudentsUtils
    4340    )
     41from waeup.kofa.students.workflow import (
     42    ADMITTED, PAID, REQUESTED, RETURNING, CLEARED, REGISTERED,
     43    VALIDATED, GRADUATED, TRANSCRIPT)
    4444from waeup.kofa.university.interfaces import ICourse
    4545
    46 grok.context(IKofaObject) # Make IKofaObject the default context
     46
     47grok.context(IKofaObject)  # Make IKofaObject the default context
    4748grok.templatedir('browser_templates')
    4849
     
    5051class StudentManageSidebar(grok.ViewletManager):
    5152    grok.name('left_studentmanage')
     53
    5254
    5355class StudentManageLink(grok.Viewlet):
     
    7072        # Here we know that the cookie has been set
    7173        lang = self.request.cookies.get('kofa.language')
    72         text = translate(self.text, 'waeup.kofa',
    73             target_language=lang)
     74        text = translate(
     75            self.text, 'waeup.kofa', target_language=lang)
    7476        if not self.link:
    7577            return ''
    7678        return u'<li><a href="%s">%s</a></li>' % (
    77                 url, text)
     79            url, text)
     80
    7881
    7982class StudentManageApplicationLink(StudentManageLink):
     
    8790        if slip:
    8891            lang = self.request.cookies.get('kofa.language')
    89             text = translate(self.text, 'waeup.kofa',
    90                 target_language=lang)
    91             url = self.view.url(self.context.student,self.link)
     92            text = translate(
     93                self.text, 'waeup.kofa', target_language=lang)
     94            url = self.view.url(self.context.student, self.link)
    9295            return u'<li><a href="%s">%s</a></li>' % (
    93                     url, text)
     96                url, text)
    9497        return ''
     98
    9599
    96100class StudentManageBaseLink(StudentManageLink):
     
    98102    link = 'index'
    99103    text = _(u'Base Data')
     104
    100105
    101106class StudentManageClearanceLink(StudentManageLink):
     
    105110    text = _(u'Clearance Data')
    106111
     112
    107113class StudentManagePersonalLink(StudentManageLink):
    108114    grok.order(4)
     
    111117    text = _(u'Personal Data')
    112118
     119
    113120class StudentManageStudyCourseLink(StudentManageLink):
    114121    grok.order(5)
    115122    link = 'studycourse'
    116123    text = _(u'Study Course')
     124
    117125
    118126class StudentManagePaymentsLink(StudentManageLink):
     
    121129    link = 'payments'
    122130    text = _(u'Payments')
     131
    123132
    124133class StudentManageAccommodationLink(StudentManageLink):
     
    129138    text = _(u'Accommodation')
    130139
     140
    131141class StudentManageHistoryLink(StudentManageLink):
    132142    grok.order(8)
     
    142152    text = _('Manage students section')
    143153
     154
    144155class StudentsContainerAddActionButton(AddActionButton):
    145156    grok.order(1)
     
    149160    text = _('Add student')
    150161    target = 'addstudent'
     162
    151163
    152164class ContactActionButton(ManageActionButton):
     
    159171    target = 'contactstudent'
    160172
     173
    161174class StudentBaseManageActionButton(ManageActionButton):
    162175    grok.order(1)
     
    166179    text = _('Manage')
    167180    target = 'manage_base'
     181
    168182
    169183class StudentTrigTransActionButton(ManageActionButton):
     
    176190    target = 'trigtrans'
    177191
     192
    178193class StudentLoginAsActionButton(ManageActionButton):
    179194    grok.order(3)
     
    185200    target = 'loginasstep1'
    186201
     202
    187203class AdmissionSlipActionButton(ManageActionButton):
    188204    grok.order(4)
     
    194210    target = 'admission_slip.pdf'
    195211
     212
    196213class StudentTransferButton(ManageActionButton):
    197214    grok.order(6)
     
    203220    icon = 'actionicon_redo.png'
    204221
     222
    205223class StudentDeactivateActionButton(ManageActionButton):
    206224    grok.order(7)
     
    223241            "'A history message will be added. Are you sure?'")
    224242
     243
    225244class StudentActivateActionButton(ManageActionButton):
    226245    grok.order(7)
     
    243262            "'A history message will be added. Are you sure?'")
    244263
     264
    245265class StudentClearanceManageActionButton(ManageActionButton):
    246266    grok.order(1)
     
    250270    text = _('Manage')
    251271    target = 'manage_clearance'
     272
    252273
    253274class StudentClearActionButton(ManageActionButton):
     
    262283    @property
    263284    def target_url(self):
    264         cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context)
     285        cdm = getUtility(
     286            IStudentsUtils).clearance_disabled_message(self.context)
    265287        if cdm:
    266288            return ''
     
    268290            return ''
    269291        return self.view.url(self.view.context, self.target)
     292
    270293
    271294class StudentRejectClearanceActionButton(ManageActionButton):
     
    280303    @property
    281304    def target_url(self):
    282         cdm = getUtility(IStudentsUtils).clearance_disabled_message(self.context)
     305        cdm = getUtility(
     306            IStudentsUtils).clearance_disabled_message(self.context)
    283307        if cdm:
    284308            return ''
     
    286310            return ''
    287311        return self.view.url(self.view.context, self.target)
     312
    288313
    289314class ClearanceSlipActionButton(ManageActionButton):
     
    296321    target = 'clearance_slip.pdf'
    297322
     323
    298324class ClearanceViewActionButton(ManageActionButton):
    299325    grok.order(1)
     
    305331    target = 'view_clearance'
    306332
     333
    307334class PersonalViewActionButton(ManageActionButton):
    308335    grok.order(1)
     
    314341    target = 'view_personal'
    315342
     343
    316344class StudentPersonalManageActionButton(ManageActionButton):
    317345    grok.order(1)
     
    322350    target = 'manage_personal'
    323351
     352
    324353class StudentPersonalEditActionButton(ManageActionButton):
    325354    grok.order(2)
     
    329358    text = _('Edit')
    330359    target = 'edit_personal'
     360
    331361
    332362class StudyCourseManageActionButton(ManageActionButton):
     
    343373            return self.view.url(self.view.context, self.target)
    344374        return False
     375
    345376
    346377class StudyCourseTranscriptActionButton(ManageActionButton):
     
    359390        return False
    360391
     392
    361393class TranscriptSlipActionButton(ManageActionButton):
    362394    grok.order(1)
     
    374406        return False
    375407
     408
    376409class RevertTransferActionButton(ManageActionButton):
    377410    grok.order(1)
     
    389422        return False
    390423
     424
    391425class StudyLevelManageActionButton(ManageActionButton):
    392426    grok.order(1)
     
    403437            return ''
    404438        return self.view.url(self.view.context, self.target)
     439
    405440
    406441class StudentValidateCoursesActionButton(ManageActionButton):
     
    415450    @property
    416451    def target_url(self):
    417         is_current = self.context.__parent__.is_current
    418         if self.context.student.state != REGISTERED or \
    419             str(self.context.__parent__.current_level) != self.context.__name__ or\
    420             not is_current:
    421             return ''
    422         return self.view.url(self.view.context, self.target)
     452        if not self.context.__parent__.is_current:
     453            return ''
     454        if self.context.student.state != REGISTERED:
     455            return ''
     456        if str(self.context.__parent__.current_level) != self.context.__name__:
     457            return ''
     458        return self.view.url(self.view.context, self.target)
     459
    423460
    424461class StudentRejectCoursesActionButton(ManageActionButton):
     
    433470    @property
    434471    def target_url(self):
    435         is_current = self.context.__parent__.is_current
    436         if self.context.student.state not in (VALIDATED, REGISTERED) or \
    437             str(self.context.__parent__.current_level) != self.context.__name__ or\
    438             not is_current:
    439             return ''
    440         return self.view.url(self.view.context, self.target)
     472        if not self.context.__parent__.is_current:
     473            return ''
     474        if self.context.student.state not in (VALIDATED, REGISTERED):
     475            return ''
     476        if str(self.context.__parent__.current_level) != self.context.__name__:
     477            return ''
     478        return self.view.url(self.view.context, self.target)
     479
    441480
    442481class StudentUnregisterCoursesActionButton(ManageActionButton):
     
    451490    @property
    452491    def target_url(self):
    453         is_current = self.context.__parent__.is_current
    454         if self.context.student.state != REGISTERED or \
    455             str(self.context.__parent__.current_level) != self.context.__name__ or\
    456             not is_current:
    457             return ''
    458         return self.view.url(self.view.context, self.target)
     492        if not self.context.__parent__.is_current:
     493            return ''
     494        if self.context.student.state != REGISTERED:
     495            return ''
     496        if str(self.context.__parent__.current_level) != self.context.__name__:
     497            return ''
     498        return self.view.url(self.view.context, self.target)
     499
    459500
    460501class CourseRegistrationSlipActionButton(ManageActionButton):
     
    474515        return self.view.url(self.view.context, self.target)
    475516
     517
    476518class CourseTicketManageActionButton(ManageActionButton):
    477519    grok.order(1)
     
    482524    target = 'manage'
    483525
    484 #class OnlinePaymentManageActionButton(ManageActionButton):
    485 #    grok.order(1)
    486 #    grok.context(IStudentPaymentsContainer)
    487 #    grok.view(PaymentsDisplayFormPage)
    488 #    grok.require('waeup.manageStudent')
    489 #    text = 'Manage payments'
    490 #    target = 'manage'
    491526
    492527class PaymentReceiptActionButton(ManageActionButton):
    493     grok.order(9) # This button should always be the last one.
     528    grok.order(9)  # This button should always be the last one.
    494529    grok.context(IStudentOnlinePayment)
    495530    grok.view(OnlinePaymentDisplayFormPage)
     
    504539        #    return ''
    505540        return self.view.url(self.view.context, self.target)
     541
    506542
    507543class ApprovePaymentActionButton(ManageActionButton):
     
    520556        return self.view.url(self.view.context, self.target)
    521557
     558
    522559class BedTicketSlipActionButton(ManageActionButton):
    523560    grok.order(1)
     
    529566    target = 'bed_allocation_slip.pdf'
    530567
     568
    531569class RelocateStudentActionButton(ManageActionButton):
    532570    grok.order(2)
     
    538576    target = 'relocate'
    539577
     578
    540579class StudentBaseActionButton(ManageActionButton):
    541580    grok.order(1)
     
    545584    text = _('Edit')
    546585    target = 'edit_base'
     586
    547587
    548588class StudentPasswordActionButton(ManageActionButton):
     
    555595    target = 'change_password'
    556596
     597
    557598class StudentPassportActionButton(ManageActionButton):
    558599    grok.order(3)
     
    566607    @property
    567608    def target_url(self):
    568         PORTRAIT_CHANGE_STATES = getUtility(IStudentsUtils).PORTRAIT_CHANGE_STATES
     609        PORTRAIT_CHANGE_STATES = getUtility(
     610            IStudentsUtils).PORTRAIT_CHANGE_STATES
    569611        if self.context.state not in PORTRAIT_CHANGE_STATES:
    570612            return ''
    571613        return self.view.url(self.view.context, self.target)
     614
    572615
    573616class StudentClearanceStartActionButton(ManageActionButton):
     
    586629        return self.view.url(self.view.context, self.target)
    587630
     631
    588632class StudentClearanceEditActionButton(ManageActionButton):
    589633    grok.order(1)
     
    599643            return ''
    600644        return self.view.url(self.view.context, self.target)
     645
    601646
    602647class StartSessionActionButton(ManageActionButton):
     
    614659            return self.view.url(self.view.context, self.target)
    615660        return False
     661
    616662
    617663class AddStudyLevelActionButton(AddActionButton):
     
    633679            return ''
    634680        return self.view.url(self.view.context, self.target)
     681
    635682
    636683class StudyLevelEditActionButton(ManageActionButton):
     
    652699        return ''
    653700
     701
    654702class AddPaymentActionButton(AddActionButton):
    655703    grok.order(1)
     
    659707    text = _('Add current session payment ticket')
    660708    target = 'addop'
     709
    661710
    662711class AddPreviousPaymentActionButton(AddActionButton):
     
    676725        return self.view.url(self.view.context, self.target)
    677726
     727
    678728class AddBalancePaymentActionButton(AddActionButton):
    679729    grok.order(3)
     
    691741        return self.view.url(self.view.context, self.target)
    692742
     743
    693744class RequestTranscriptActionButton(ManageActionButton):
    694745    grok.order(8)
     
    705756            return ''
    706757        return self.view.url(self.view.context, self.target)
     758
    707759
    708760class ProcessTranscriptRequestActionButton(ManageActionButton):
     
    721773        return self.view.url(self.view.context, self.target)
    722774
     775
    723776class StudentsTab(PrimaryNavTab):
    724777    """Students tab in primary navigation.
    725778    """
    726 
    727779    grok.context(IKofaObject)
    728780    grok.order(4)
     
    737789        return self.view.application_url('students')
    738790
     791
    739792class PrimaryStudentNavManager(grok.ViewletManager):
    740793    """Viewlet manager for the primary navigation tab.
    741794    """
    742795    grok.name('primary_nav_student')
     796
    743797
    744798class PrimaryStudentNavTab(grok.Viewlet):
     
    764818            return 'active'
    765819        return ''
     820
    766821
    767822class MyStudentDataTab(PrimaryStudentNavTab):
     
    790845        targets = []
    791846        if app_slip:
    792             targets = [{'url':student_url + '/application_slip',
    793                         'title':_('Application Slip')},]
     847            targets = [{'url': student_url + '/application_slip',
     848                        'title': _('Application Slip')}, ]
    794849        targets += [
    795             {'url':student_url, 'title':'Base Data'},
    796             {'url':student_url + '/view_clearance',
    797              'title':_('Clearance Data')},
    798             {'url':student_url + '/view_personal', 'title':_('Personal Data')},
    799             {'url':student_url + '/studycourse', 'title':_('Study Course')},
    800             {'url':student_url + '/payments', 'title':_('Payments')},
    801             {'url':student_url + '/accommodation',
    802              'title':_('Accommodation Data')},
    803             {'url':student_url + '/history', 'title':_('History')},
     850            {'url': student_url, 'title': 'Base Data'},
     851            {'url': student_url + '/view_clearance',
     852             'title': _('Clearance Data')},
     853            {'url': student_url + '/view_personal',
     854             'title': _('Personal Data')},
     855            {'url': student_url + '/studycourse', 'title': _('Study Course')},
     856            {'url': student_url + '/payments', 'title': _('Payments')},
     857            {'url': student_url + '/accommodation',
     858             'title': _('Accommodation Data')},
     859            {'url': student_url + '/history', 'title': _('History')},
    804860            ]
    805861        return targets
     862
    806863
    807864class DownloadCSVFileActionButton(ManageActionButton):
     
    817874    grok.order(1)
    818875
     876
    819877class DownloadTicketOverviewActionButton(ManageActionButton):
    820878    """ 'Download ticket overview' button for courses.
Note: See TracChangeset for help on using the changeset viewer.