Ignore:
Timestamp:
22 Feb 2022, 22:08:37 (3 years ago)
Author:
Henrik Bettermann
Message:

Add importers for previous study course data.

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

Legend:

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

    r16821 r16828  
    485485    iface_transfer = IStudentStudyCourseTransfer
    486486    factory_name = 'waeup.StudentStudyCourse'
     487    studycourse_name = 'studycourse'
    487488
    488489    def getParent(self, row, site):
     
    493494        if student is None:
    494495            return None
    495         return student.get('studycourse')
     496        return student.get(self.studycourse_name)
    496497
    497498    def updateEntry(self, obj, row, site, filename):
     
    508509            student.transfer(
    509510                certificate=certificate, current_session=current_session)
    510             obj = student['studycourse']
     511            obj = student[self.studycourse_name]
     512            # Once imported we must ensure that after export and reimport
     513            # the student is not transferred again.
     514            row['entry_mode'] = 'transferred'
    511515        items_changed = super(StudentStudyCourseProcessor, self).updateEntry(
    512516            obj, row, site, filename)
     
    585589    iface = IStudentStudyLevel
    586590    factory_name = 'waeup.StudentStudyLevel'
     591    studycourse_name = 'studycourse'
    587592
    588593    additional_fields_required = ['level']
     
    599604        if student is None:
    600605            return None
    601         return student['studycourse']
     606        return student[self.studycourse_name]
    602607
    603608    def getEntry(self, row, site):
     
    702707    iface = ICourseTicketImport
    703708    factory_name = 'waeup.CourseTicket'
     709    studycourse_name = 'studycourse'
    704710
    705711    additional_fields = ['level', 'code']
     
    721727        if student is None:
    722728            return None
    723         return student['studycourse'].get(str(row['level']))
     729        return student[self.studycourse_name].get(str(row['level']))
    724730
    725731    def getEntry(self, row, site):
     
    10791085        notify(grok.ObjectModifiedEvent(obj.__parent__))
    10801086        return
     1087
     1088class FirstStudentStudyCourseProcessor(StudentStudyCourseProcessor):
     1089    """The First Student Study Course Processor imports first
     1090    study course data of students who have been transferred.
     1091    """
     1092    util_name = 'studycourseprocessor_1'
     1093    grok.name(util_name)
     1094    name = _('FirstStudentStudyCourse Processor')
     1095    studycourse_name = 'studycourse_1'
     1096
     1097    def addEntry(self, obj, row, site):
     1098        parent = self.getParent(row, site)
     1099        parent[self.studycourse_name] = obj
     1100        return
     1101
     1102class FirstStudentStudyLevelProcessor(StudentStudyLevelProcessor):
     1103    """The First Student Study Level Processor imports study level data
     1104    into first study course containers of students who have been transferred.
     1105    """
     1106    util_name = 'studylevelprocessor_1'
     1107    grok.name(util_name)
     1108    name = _('FirstStudentStudyLevel Processor')
     1109    studycourse_name = 'studycourse_1'
     1110
     1111class FirstCourseTicketProcessor(CourseTicketProcessor):
     1112    """The First Course Ticket Processor imports course tickets into
     1113    first study level containers of students who have been transferred.
     1114    """
     1115    util_name = 'courseticketprocessor_1'
     1116    grok.name(util_name)
     1117    name = _('FirstCourseTicket Processor')
     1118    iface = ICourseTicketImport
     1119    factory_name = 'waeup.CourseTicket'
     1120    studycourse_name = 'studycourse_1'
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r16821 r16828  
    3939    StudentProcessor, StudentStudyCourseProcessor,
    4040    StudentStudyLevelProcessor, CourseTicketProcessor,
    41     StudentOnlinePaymentProcessor, StudentVerdictProcessor)
     41    StudentOnlinePaymentProcessor, StudentVerdictProcessor,
     42    FirstStudentStudyCourseProcessor,
     43    FirstStudentStudyLevelProcessor,
     44    FirstCourseTicketProcessor)
    4245from waeup.kofa.students.payments import StudentOnlinePayment
    4346from waeup.kofa.students.student import Student
     
    733736        self.assertEqual(self.student['studycourse'].certificate.code, 'CERT2')
    734737        self.assertEqual(self.student['studycourse_1'].certificate.code, 'CERT1')
    735         self.assertEqual(self.student['studycourse'].entry_mode, 'transfer')
     738        self.assertEqual(self.student['studycourse'].entry_mode, 'transferred')
    736739        self.assertEqual(self.student['studycourse_1'].entry_mode, 'ug_ft')
    737740        self.assertEqual(self.student.current_mode, 'ug_pt')
     
    745748            'INFO - system - '
    746749            'StudentStudyCourse Processor (update only) - '
    747             'sample_transfer_data - K1000000 - updated: entry_mode=transfer, '
     750            'sample_transfer_data - K1000000 - updated: entry_mode=transferred, '
    748751            'certificate=CERT2, current_session=2009, current_level=300'
    749752            in logcontent)
     
    11351138            '1,COURSE1,<IGNORE>,300,Cannot remove: no such entry\r\n'
    11361139            )
     1140        shutil.rmtree(os.path.dirname(fin_file))
     1141
     1142    def test_import_firstcourse_with_content(self):
     1143        processor = FirstStudentStudyCourseProcessor()
     1144        csv_file = os.path.join(
     1145            self.workdir, 'sample_studycourse_data.csv')
     1146        num, num_warns, fin_file, fail_file = processor.doImport(
     1147            csv_file, STUDYCOURSE_HEADER_FIELDS,'create')
     1148        self.assertEqual(num_warns,1)
     1149        content = open(fail_file).read()
     1150        self.assertTrue('current_level: not in range' in content)
     1151        studycourse = processor.getEntry(dict(reg_number='1'), self.app)
     1152        self.assertEqual(studycourse.certificate.code, u'CERT1')
     1153        self.assertEqual(studycourse.__name__, u'studycourse_1')
     1154        cat = queryUtility(ICatalog, name='students_catalog')
     1155        results = list(cat.searchResults(reg_number=('1', '1')))
     1156        self.assertEqual([i for i in results[0].keys()],
     1157            [u'accommodation', u'payments', u'studycourse', u'studycourse_1'])
     1158        processor = FirstStudentStudyLevelProcessor()
     1159        csv_file = os.path.join(
     1160            self.workdir, 'sample_studylevel_data.csv')
     1161        num, num_warns, fin_file, fail_file = processor.doImport(
     1162            csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
     1163        self.assertEqual(num_warns,3)
     1164        assert processor.entryExists(
     1165            dict(reg_number='1', level='100'), self.app) is True
     1166        studylevel = processor.getEntry(
     1167            dict(reg_number='1', level='100'), self.app)
     1168        self.assertEqual(studylevel.__parent__.certificate.code, u'CERT1')
     1169        self.assertEqual(studylevel.level_session, 2008)
     1170        self.assertEqual(studylevel.level_verdict, '0')
     1171        self.assertEqual(studylevel.level, 100)
     1172        self.assertEqual([i for i in results[0]['studycourse_1'].keys()],
     1173            [u'100', u'200'])
     1174        processor = FirstCourseTicketProcessor()
     1175        csv_file = os.path.join(
     1176            self.workdir, 'sample_courseticket_data.csv')
     1177        num, num_warns, fin_file, fail_file = processor.doImport(
     1178            csv_file, COURSETICKET_HEADER_FIELDS,'create')
     1179        assert processor.entryExists(
     1180            dict(reg_number='1', level='100', code='COURSE1'), self.app) is True
     1181        self.assertEqual([i for i in results[0]['studycourse_1']['100'].keys()],
     1182            [u'COURSE1'])
    11371183        shutil.rmtree(os.path.dirname(fin_file))
    11381184
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r16662 r16828  
    16501650        modeselect = self.browser.getControl(name='mode')
    16511651        importerselect.getControl(
    1652             'StudentStudyCourse Processor (update only)').selected = True
     1652            'StudentStudyCourse Processor (update only)',index=0).selected = True
    16531653        modeselect.getControl(value='create').selected = True
    16541654        self.browser.getControl('Proceed to step 3').click()
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/utils.py

    r16812 r16828  
    136136    STUDY_MODES_DICT = {
    137137        'transfer': 'Transfer',
     138        'transferred': 'Transferred',
    138139        'ug_ft': 'Undergraduate Full-Time',
    139140        'ug_pt': 'Undergraduate Part-Time',
Note: See TracChangeset for help on using the changeset viewer.