Changeset 10266 for main


Ignore:
Timestamp:
31 May 2013, 17:48:29 (12 years ago)
Author:
Henrik Bettermann
Message:

Define correct dictionaries. level_dict must include probation levels.

Add buttons for navigating to transcripts.

Add property attribute 'transcript_enabled' which eases defining conditions in custom packages.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
7 edited

Legend:

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

    r10262 r10266  
    166166    return True
    167167
     168def level_dict(studycourse):
     169    portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     170    level_dict = {}
     171    studylevelsource = StudyLevelSource().factory
     172    for code in studylevelsource.getValues(studycourse):
     173        title = translate(studylevelsource.getTitle(studycourse, code),
     174            'waeup.kofa', target_language=portal_language)
     175        level_dict[code] = title
     176    return level_dict
     177
    168178class StudentsBreadcrumb(Breadcrumb):
    169179    """A breadcrumb for the students container.
     
    9911001
    9921002    @property
    993     def level_dict(self):
     1003    def level_dicts(self):
    9941004        studylevelsource = StudyLevelSource().factory
    9951005        for code in studylevelsource.getValues(self.context):
     
    9981008
    9991009    @property
    1000     def session_dict(self):
     1010    def session_dicts(self):
    10011011        yield(dict(code='', title='--'))
    10021012        for item in academic_sessions():
     
    10581068
    10591069    def update(self):
     1070        if not self.context.student.transcript_enabled:
     1071            self.flash(_('You are not allowed to view the transcript.'))
     1072            self.redirect(self.url(self.context))
     1073            return
    10601074        super(StudyCourseTranscriptPage, self).update()
    10611075        self.semester_dict = getUtility(IKofaUtils).SEMESTER_DICT
     1076        self.level_dict = level_dict(self.context)
    10621077        self.session_dict = dict(
    10631078            [(item[1], item[0]) for item in academic_sessions()])
    1064         self.course_levels = course_levels
    10651079        self.studymode_dict = getUtility(IKofaUtils).STUDY_MODES_DICT
    10661080        return
     
    10871101
    10881102    def update(self):
     1103        if not self.context.student.transcript_enabled:
     1104            self.flash(_('You are not allowed to download the transcript.'))
     1105            self.redirect(self.url(self.context))
     1106            return
    10891107        super(ExportPDFTranscriptPage, self).update()
    10901108        self.semester_dict = getUtility(IKofaUtils).SEMESTER_DICT
     1109        self.level_dict = level_dict(self.context)
    10911110        self.session_dict = dict(
    10921111            [(item[1], item[0]) for item in academic_sessions()])
    1093         self.course_levels = course_levels
    10941112        self.studymode_dict = getUtility(IKofaUtils).STUDY_MODES_DICT
    10951113        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/studycoursemanagepage.pt

    r9437 r10266  
    7171        </span>
    7272        <select id="addlevel" name="addlevel" class='span5'>
    73           <option tal:attributes="value level/code" tal:repeat="level view/level_dict">
     73          <option tal:attributes="value level/code" tal:repeat="level view/level_dicts">
    7474            <span tal:replace="level/title">LEVELTITLE
    7575          </span>
     
    7878        &nbsp;&nbsp;<span i18n:translate="">in session</span>&nbsp;&nbsp;
    7979        <select id="level_session" name="level_session" class='span3'>
    80           <option tal:attributes="value session/code" tal:repeat="session view/session_dict">
     80          <option tal:attributes="value session/code" tal:repeat="session view/session_dicts">
    8181            <span tal:replace="session/title">LEVELSESSION
    8282          </span>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/transcript.pt

    r10262 r10266  
    4646                                      level['tickets_2'], level['tickets_3'])">
    4747      <tr tal:repeat="ticket semester_tickets" class="gradeC">
    48         <td tal:content="python: view.course_levels.getTerm(ticket.level).title">LEVEL</td>
     48        <td tal:content="python: view.level_dict[ticket.level]">LEVEL</td>
    4949        <td tal:content="python: view.session_dict[ticket.level_session]">SESSION</td>
    5050        <td tal:content="python: view.semester_dict[ticket.semester]">SEMESTER</td>
  • main/waeup.kofa/trunk/src/waeup/kofa/students/student.py

    r10245 r10266  
    232232        return False
    233233
     234    @property
     235    def transcript_enabled(self):
     236        return True
     237
    234238    def transfer(self, certificate, current_session=None,
    235239        current_level=None, current_verdict=None, previous_verdict=None):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10260 r10266  
    22052205        self.assertTrue('Course list has been registered' in self.browser.contents)
    22062206        self.assertEqual(self.student.state, 'courses registered')
    2207         # Students can open the pdf transcript
    2208         self.browser.open(self.student_path + '/studycourse/transcript.pdf')
     2207        # Students can view the transcript
     2208        self.browser.open(self.studycourse_path)
     2209        self.browser.getLink("Transcript").click()
     2210        self.browser.getLink("Academic Transcript").click()
    22092211        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    22102212        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r10262 r10266  
    216216    data = []
    217217    style = getSampleStyleSheet()
    218 
    219218    for level in levels_data:
    220219        level_obj = level['level']
     
    226225            view.session_dict[level_obj.level_session],
    227226            trans(_('Level'), lang),
    228             view.course_levels.getTerm(level_obj.level).title)
     227            view.level_dict[level_obj.level])
    229228        data.append(Paragraph(subheader, HEADING_STYLE))
    230229        for element in tableheader:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py

    r10080 r10266  
    4545    AccommodationManageFormPage, BedTicketDisplayFormPage,
    4646    StudentClearanceEditFormPage, StudentPersonalEditFormPage,
    47     PaymentsManageFormPage)
     47    PaymentsManageFormPage, StudyCourseTranscriptPage)
    4848from waeup.kofa.students.interfaces import (
    4949    IStudentsContainer, IStudent, IStudentStudyCourse, IStudentAccommodation,
     
    341341    def target_url(self):
    342342        if self.context.is_current:
     343            return self.view.url(self.view.context, self.target)
     344        return False
     345
     346class StudyCourseTranscriptActionButton(ManageActionButton):
     347    grok.order(2)
     348    grok.context(IStudentStudyCourse)
     349    grok.view(StudyCourseDisplayFormPage)
     350    grok.require('waeup.viewStudent')
     351    text = _('Transcript')
     352    target = 'transcript'
     353    icon = 'actionicon_transcript.png'
     354
     355    @property
     356    def target_url(self):
     357        if self.context.student.transcript_enabled:
     358            return self.view.url(self.view.context, self.target)
     359        return False
     360
     361class TranscriptSlipActionButton(ManageActionButton):
     362    grok.order(1)
     363    grok.context(IStudentStudyCourse)
     364    grok.view(StudyCourseTranscriptPage)
     365    grok.require('waeup.viewStudent')
     366    text = _('Academic Transcript')
     367    target = 'transcript.pdf'
     368    icon = 'actionicon_pdf.png'
     369
     370    @property
     371    def target_url(self):
     372        if self.context.student.transcript_enabled:
    343373            return self.view.url(self.view.context, self.target)
    344374        return False
Note: See TracChangeset for help on using the changeset viewer.