Ignore:
Timestamp:
16 Aug 2019, 12:40:20 (5 years ago)
Author:
Henrik Bettermann
Message:

Add semester filter to Fix CourseTicketExporter.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students
Files:
4 edited

Legend:

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

    r15545 r15546  
    37733773        return
    37743774
     3775    def _set_semesters_values(self):
     3776        utils = getUtility(IKofaUtils)
     3777        self.semesters =[(_('All Semesters'), 'all')]
     3778        self.semesters += sorted([(value, key) for key, value in
     3779                      utils.SEMESTER_DICT.items()])
     3780        return
     3781
    37753782    def _set_mode_values(self):
    37763783        utils = getUtility(IKofaUtils)
     
    38333840    def update(self, START=None, session=None, level=None, mode=None,
    38343841               payments_start=None, payments_end=None, ct_level=None,
    3835                ct_session=None, paycat=None, paysession=None, exporter=None):
     3842               ct_session=None, ct_semester=None, paycat=None,
     3843               paysession=None, exporter=None):
    38363844        self._set_session_values()
    38373845        self._set_level_values()
     
    38393847        self._set_paycat_values()
    38403848        self._set_exporter_values()
     3849        self._set_semesters_values()
    38413850        if START is None:
    38423851            return
     
    38753884                                          ct_level = ct_level,
    38763885                                          ct_session = ct_session,
     3886                                          ct_semester = ct_semester,
    38773887                                          )
    38783888        else:
     
    38903900                                          paysession=paysession,
    38913901                                          ct_level = ct_level,
    3892                                           ct_session = ct_session,)
     3902                                          ct_session = ct_session,
     3903                                          ct_semester = ct_semester,)
    38933904        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    38943905        self.context.logger.info(
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt

    r15315 r15546  
    117117    </select>
    118118    <br />
     119    <label for="semester" i18n:translate="">
     120      Course Ticket Semester
     121    </label>
     122    <select name="ct_semester" class="form-control half">
     123      <option tal:repeat="item view/semesters"
     124              tal:attributes="value python:item[1]">
     125        <span tal:replace="python: item[0]">1st Semester</span>
     126      </option>
     127    </select>
     128    <br />
    119129  </span>
    120130
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r15297 r15546  
    5959    which belong to this course code and meet level=level
    6060    and level_session=level_session.
    61     If not, but ct_level and ct_session
     61    If not, but ct_level, ct_session and ct_semester
    6262    are passed through, filter course tickets
    63     which meet level==ct_level and level_session==ct_session.
     63    which meet level==ct_level, level_session==ct_session
     64    and semester==ct_semester.
    6465    """
    6566    tickets = []
     
    6970    ct_level = kw.get('ct_level', None)
    7071    ct_session = kw.get('ct_session', None)
     72    ct_semester = kw.get('ct_semester', None)
    7173    if code is None:
    7274        for level_obj in get_levels(students):
     
    8183                if ct_session not in ('all', None) and \
    8284                    int(ct_session) != level_obj.level_session:
     85                    continue
     86                if ct_semester not in ('all', None) and \
     87                    int(ct_semester) != ticket.semester:
    8388                    continue
    8489                tickets.append(ticket)
     
    219224            del kw['ct_level']
    220225            del kw['ct_session']
     226            del kw['ct_semester']
    221227        except KeyError:
    222228            pass
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r15333 r15546  
    690690            'Anna M. Tester\r\n'
    691691            )
    692         # We can set the course tickets level and level_session without code
    693         # (used in the datacenter)
     692        # We can set the course tickets level, semester and level_session
     693        # without code (used in the datacenter)
    694694        notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1']))
    695695        exporter.export_filtered(self.student, self.outfile, ct_level='100',
    696             ct_session='2012')
     696            ct_session='2012', ct_semester='2')
    697697        result = open(self.outfile, 'rb').read()
    698698        self.assertEqual(
     
    707707        notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1']))
    708708        exporter.export_filtered(self.student, self.outfile, ct_level='all',
    709             ct_session='2012')
     709            ct_session='2012', ct_semester='all')
    710710        result = open(self.outfile, 'rb').read()
    711711        self.assertEqual(
     
    731731        exporter.export_filtered(self.student, self.outfile,
    732732            ct_level='all', ct_session='2013')
     733        result = open(self.outfile, 'rb').read()
     734        self.assertEqual(
     735            result,
     736            'automatic,carry_over,code,course_category,credits,dcode,fcode,level,level_session,'
     737            'mandatory,outstanding,passmark,score,semester,ticket_session,title,student_id,certcode,'
     738            'display_fullname\r\n'
     739            )
     740        # 1st semester tickets do not exist.
     741        notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['CRS1']))
     742        exporter.export_filtered(self.student, self.outfile,
     743            ct_level='all', ct_session='all', ct_semester='1')
    733744        result = open(self.outfile, 'rb').read()
    734745        self.assertEqual(
Note: See TracChangeset for help on using the changeset viewer.