Changeset 15920


Ignore:
Timestamp:
13 Jan 2020, 23:51:00 (5 years ago)
Author:
Henrik Bettermann
Message:

Add TranscriptDataExporter and reorganize exporter names.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r15918 r15920  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Add `TranscriptDataExporter` and reorganize exporter names.
    68
    79* Add `session_level`filter to `StudentStudyLevelExporter`.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser_templates/exportconfig.pt

    r15918 r15920  
    155155          document.getElementById('exporter').value == 'studentpayments' ||
    156156          document.getElementById('exporter').value == 'accommodationpayments' ||
    157           document.getElementById('exporter').value == 'studentunpaidpayments') {
     157          document.getElementById('exporter').value == 'unpaidpayments') {
    158158          document.getElementById('payment_dates').style.display = 'block';
    159159          document.getElementById('paycat').style.display = 'block';
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r15918 r15920  
    329329        'password', 'state', 'history', 'certcode', 'is_postgrad',
    330330        'current_level', 'current_session')
    331     title = _(u'Students')
     331    title = _(u'Students (Data Backup)')
    332332
    333333    def mangle_value(self, value, name, context=None):
     
    355355
    356356    fields = tuple(sorted(iface_names(IStudentStudyCourse))) + ('student_id',)
    357     title = _(u'Student Study Courses')
     357    title = _(u'Student Study Courses (Data Backup)')
    358358
    359359    def filter_func(self, x, **kw):
     
    386386        IStudentStudyLevel))) + (
    387387        'student_id', 'number_of_tickets','certcode')
    388     title = _(u'Student Study Levels')
     388    title = _(u'Student Study Levels (Data Backup)')
    389389
    390390    def filter_func(self, x, **kw):
     
    420420        ['level', 'code', 'level_session'])) + ('student_id',
    421421        'certcode', 'display_fullname')
    422     title = _(u'Course Tickets')
     422    title = _(u'Course Tickets (Data Backup)')
    423423
    424424    def filter_func(self, x, **kw):
     
    474474    or nottaken (registered but not taken).
    475475    """
    476     grok.name('studentoutstandingcourses')
     476    grok.name('outstandingcourses')
    477477
    478478    fields = ('student_id', 'certcode', 'display_fullname','missed',
    479479              'failed', 'nottaken')
    480     title = _(u'Student Outstanding Courses')
     480    title = _(u'Outstanding Courses')
    481481
    482482    def filter_func(self, x, **kw):
     
    514514            omit=['display_item', 'certificate', 'student']))) + (
    515515            'student_id','state','current_session')
    516     title = _(u'Student Payments')
     516    title = _(u'Student Payments (Data Backup)')
    517517
    518518    def filter_func(self, x, **kw):
     
    538538    payment ticket.
    539539    """
    540     grok.name('studentunpaidpayments')
    541 
    542     title = _(u'Student Unpaid Payments')
     540    grok.name('unpaidpayments')
     541
     542    title = _(u'Unpaid Payment Tickets')
    543543
    544544    def filter_func(self, x, **kw):
     
    618618            omit=['display_coordinates', 'maint_payment_made']))) + (
    619619            'student_id', 'actual_bed_type')
    620     title = _(u'Bed Tickets')
     620    title = _(u'Bed Tickets (Data Backup)')
    621621
    622622    def filter_func(self, x, **kw):
     
    655655        'entry_session', 'reg_number'
    656656        ) + year_range_tuple
    657     title = _(u'Student School Fee Payments Overview')
     657    title = _(u'School Fee Payments Overview')
    658658
    659659    def mangle_value(self, value, name, context=None):
     
    768768        'entry_session', 'current_level', 'current_session',
    769769        ) + avail_levels
    770     title = _(u'Student Study Levels Overview')
     770    title = _(u'Study Levels Overview')
    771771
    772772    def mangle_value(self, value, name, context=None):
     
    823823            ComboCardDataExporter, self).mangle_value(
    824824            value, name, context=context)
     825
     826class StudentTranscriptDataExporter(StudentExporter):
     827    """The Student Transcript Data Exporter first filters the set of
     828    students by searching the students catalog. Then it exports student data
     829    along with their transcript data.
     830    """
     831    grok.name('transcriptdata')
     832
     833    fields = ('student_id', ) + (
     834        'state', 'certcode', 'faccode', 'depcode',
     835        'entry_session', 'current_level', 'current_session',
     836        'transcript_data')
     837    title = _(u'Transcript Data')
     838
     839    def mangle_value(self, value, name, context=None):
     840        """The mangler determines the trascript data.
     841        """
     842        if name == 'transcript_data':
     843            value = {}
     844            td = context['studycourse'].getTranscriptData()[0]
     845            for level in td:
     846                tickets_1 = ','.join(i.code for i in level['tickets_1'])
     847                tickets_2 = ','.join(i.code for i in level['tickets_2'])
     848                tickets_3 = ','.join(i.code for i in level['tickets_3'])
     849                value = "Level %s; 1st: %s; 2nd: %s; 3rd: %s; sgpa: %s" % (
     850                    level['level_key'], tickets_1, tickets_2,
     851                    tickets_3, level['sgpa'],
     852                    )
     853        return super(
     854            StudentTranscriptDataExporter, self).mangle_value(
     855            value, name, context=context)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r15918 r15920  
    3636    StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter,
    3737    StudentOutstandingCoursesExporter,
    38     AccommodationPaymentsExporter, get_students,)
     38    AccommodationPaymentsExporter,
     39    StudentTranscriptDataExporter,
     40    get_students,)
    3941from waeup.kofa.students.accommodation import BedTicket
    4042from waeup.kofa.students.interfaces import ICSVStudentExporter
     
    813815    def test_get_as_utility(self):
    814816        # we can get an student exporter as utility
    815         result = queryUtility(ICSVExporter, name="studentoutstandingcourses")
     817        result = queryUtility(ICSVExporter, name="outstandingcourses")
    816818        self.assertTrue(result is not None)
    817819        return
     
    15301532            )
    15311533        return
     1534
     1535class StudentTranscriptDataExporterTest(StudentImportExportSetup):
     1536
     1537    layer = FunctionalLayer
     1538
     1539    def setUp(self):
     1540        super(StudentTranscriptDataExporterTest, self).setUp()
     1541        self.setup_for_export()
     1542        return
     1543
     1544    def test_export_all(self):
     1545        self.setup_student(self.student)
     1546        exporter = StudentTranscriptDataExporter()
     1547        exporter.export_all(self.app, self.outfile)
     1548        result = open(self.outfile, 'rb').read()
     1549        self.assertTrue(
     1550            'student_id,state,certcode,faccode,depcode,entry_session,'
     1551            'current_level,current_session,transcript_data\r\n'
     1552            'A111111,created,CERT1,NA,NA,2010,200,2012,'
     1553            'Level 100; 1st: ; 2nd: CRS1; 3rd: ; sgpa: 0.0\r\n'
     1554            in result
     1555            )
     1556        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15889 r15920  
    11501150    #: A tuple containing all exporter names referring to students or
    11511151    #: subobjects thereof.
    1152     STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses',
    1153             'studentstudylevels', 'coursetickets','studentoutstandingcourses',
    1154             'studentpayments', 'studentunpaidpayments',
    1155             'sfpaymentsoverview', 'sessionpaymentsoverview',
    1156             'studylevelsoverview','bedtickets',
    1157             'combocard', 'bursary',
    1158             'accommodationpayments',)
     1152    STUDENT_EXPORTER_NAMES = (
     1153            'students',
     1154            'studentstudycourses',
     1155            'studentstudylevels',
     1156            'coursetickets',
     1157            'studentpayments',
     1158            'bedtickets',
     1159            'outstandingcourses',
     1160            'unpaidpayments',
     1161            'sfpaymentsoverview',
     1162            'sessionpaymentsoverview',
     1163            'studylevelsoverview',
     1164            'combocard',
     1165            'bursary',
     1166            'accommodationpayments',
     1167            'transcriptdata')
    11591168
    11601169    #: A tuple containing all exporter names needed for backing
Note: See TracChangeset for help on using the changeset viewer.