Ignore:
Timestamp:
19 Dec 2018, 22:50:36 (6 years ago)
Author:
Henrik Bettermann
Message:

Add AccommodationPaymentsExporter which can be used by accommodation officers.

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

Legend:

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

    r15254 r15277  
    35673567    def _set_exporter_values(self):
    35683568        # We provide all student exporters, nothing else, yet.
    3569         # Bursary or Department Officers don't have the general exportData
    3570         # permission and are only allowed to export bursary or payments
    3571         # overview data respectively. This is the only place where
     3569        # Bursary, Department or Accommodation Officers don't
     3570        # have the general exportData
     3571        # permission and are only allowed to export bursary, payments
     3572        # overview or accommodation data respectively.
     3573        # This is the only place where waeup.exportAccommodationData,
    35723574        # waeup.exportBursaryData and waeup.exportPaymentsOverview
    35733575        # are used.
     
    35813583                              ('Session Payments Overview',
    35823584                               'sessionpaymentsoverview')]
     3585            if checkPermission('waeup.exportAccommodationData', self.context):
     3586                exporters += [('Bed Tickets', 'bedtickets'),
     3587                              ('Accommodation Payments',
     3588                               'accommodationpayments')]
    35833589            self.exporters = exporters
    35843590            return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/export.py

    r15062 r15277  
    508508            value, name, context=context)
    509509
     510class AccommodationPaymentsExporter(DataForBursaryExporter):
     511    """The AccommodationPayments Exporter works just like the Student
     512    Payment Exporter but it exports much more information about the student.
     513    It combines     payment and student data in one table in order to spare
     514    postprocessing of     two seperate export files. The exporter is primarily
     515    used by bursary officers who have exclusively access to this exporter.
     516    The exporter exports ``paid`` and ``waived`` payment tickets with category
     517    ``bed_allocation`` or ``hostel_maintenance``.
     518    """
     519    grok.name('accommodationpayments')
     520
     521    def filter_func(self, x, **kw):
     522        kw['paycat'] = 'bed_allocation'
     523        payments = get_payments(x, p_states=('paid', 'waived'), **kw)
     524        kw['paycat'] = 'hostel_maintenance'
     525        payments += get_payments(x, p_states=('paid', 'waived'), **kw)
     526        return payments
     527
     528    title = _(u'Accommodation Payments')
     529
    510530class BedTicketExporter(grok.GlobalUtility, StudentExporterBase):
    511531    """The Bed Ticket Exporter first filters the set of students
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r15250 r15277  
    41814181        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
    41824182
     4183    def test_export_accommodation_officers(self):
     4184        # Create bursary officer
     4185        self.app['users'].addUser('mracco', 'mraccosecret')
     4186        self.app['users']['mracco'].email = 'mracco@foo.ng'
     4187        self.app['users']['mracco'].title = 'Carlo Pitter'
     4188        prmglobal = IPrincipalRoleManager(self.app)
     4189        prmglobal.assignRoleToPrincipal('waeup.AccommodationOfficer', 'mracco')
     4190        # Login as bursary officer
     4191        self.browser.open(self.login_path)
     4192        self.browser.getControl(name="form.login").value = 'mracco'
     4193        self.browser.getControl(name="form.password").value = 'mraccosecret'
     4194        self.browser.getControl("Login").click()
     4195        self.assertMatches('...You logged in...', self.browser.contents)
     4196        self.browser.getLink("Academics").click()
     4197        self.browser.getLink("Export student data").click()
     4198        self.browser.getControl("Configure new export").click()
     4199        # accommodationpayments and beds exporters are available
     4200        # not only at facultiescontainer level ...
     4201        self.assertFalse('<option value="students">' in self.browser.contents)
     4202        self.assertTrue('<option value="accommodationpayments">'
     4203            in self.browser.contents)
     4204        self.assertTrue('<option value="bedtickets">' in self.browser.contents)
     4205        self.browser.getControl(
     4206            name="exporter").value = ['accommodationpayments']
     4207        self.browser.getControl(name="session").value = ['2004']
     4208        self.browser.getControl(name="level").value = ['100']
     4209        self.browser.getControl("Create CSV file").click()
     4210        self.assertTrue('Export started' in self.browser.contents)
     4211        # ... but also at other levels
     4212        self.browser.open('http://localhost/app/faculties/fac1/dep1')
     4213        self.browser.getLink("Export student data").click()
     4214        self.browser.getControl("Configure new export").click()
     4215        self.assertFalse('<option value="students">' in self.browser.contents)
     4216        self.assertTrue('<option value="accommodationpayments">'
     4217            in self.browser.contents)
     4218        self.assertTrue('<option value="bedtickets">' in self.browser.contents)
     4219        # Thew job can be discarded
     4220        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     4221        self.wait_for_export_job_completed()
     4222        self.browser.open('http://localhost/app/faculties/exports')
     4223        self.browser.getControl("Discard").click()
     4224        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     4225
    41834226
    41844227UPLOAD_CSV_TEMPLATE = (
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py

    r15203 r15277  
    3333    ComboCardDataExporter, DataForBursaryExporter,
    3434    StudentUnpaidPaymentExporter, SessionPaymentsOverviewExporter,
    35     get_students,)
     35    AccommodationPaymentsExporter, get_students,)
    3636from waeup.kofa.students.accommodation import BedTicket
    3737from waeup.kofa.students.interfaces import ICSVStudentExporter
     
    10431043            'Anna,M.,Tester,created,2012,2010,ug_ft,NA,NA,CERT1\r\n'
    10441044            % (curr_year-6, curr_year-6, curr_year-6)
     1045            )
     1046        return
     1047
     1048class AccommodationPaymentsExporterTest(StudentImportExportSetup):
     1049
     1050    layer = FunctionalLayer
     1051
     1052    def setUp(self):
     1053        super(AccommodationPaymentsExporterTest, self).setUp()
     1054        self.setup_for_export()
     1055        return
     1056
     1057    def test_export_all(self):
     1058        self.setup_student(self.student)
     1059        # add accommodation payments
     1060        payment = StudentOnlinePayment()
     1061        payment.creation_date = datetime.datetime(curr_year-6, 4, 1, 13, 12, 1)
     1062        payment.p_id = 'id1'
     1063        payment.p_category = u'bed_allocation'
     1064        payment.p_state = 'paid'
     1065        payment.ac = u'abc'
     1066        payment.p_item = u'xyz'
     1067        payment.p_level = 100
     1068        payment.p_session = curr_year - 6
     1069        payment.payment_date = datetime.datetime(curr_year-6, 4, 1, 14, 12, 1)
     1070        payment.amount_auth = 12.12
     1071        payment.r_amount_approved = 12.12
     1072        payment.r_code = u'cde'
     1073        payment2 = StudentOnlinePayment()
     1074        payment2.creation_date = datetime.datetime(curr_year-6, 4, 1, 13, 12, 1)
     1075        payment2.p_id = 'id2'
     1076        payment2.p_category = u'hostel_maintenance'
     1077        payment2.p_state = 'paid'
     1078        payment2.ac = u'abc'
     1079        payment2.p_item = u'xyz'
     1080        payment2.p_level = 100
     1081        payment2.p_session = curr_year - 6
     1082        payment2.payment_date = datetime.datetime(curr_year-6, 4, 1, 14, 12, 1)
     1083        payment2.amount_auth = 12.12
     1084        payment2.r_amount_approved = 12.12
     1085        payment2.r_code = u'cde'
     1086        # XXX: there is no addPayment method to give predictable names
     1087        self.payment = self.student['payments']['id1'] = payment
     1088        self.payment = self.student['payments']['id2'] = payment2
     1089        exporter = AccommodationPaymentsExporter()
     1090        exporter.export_all(self.app, self.outfile)
     1091        result = open(self.outfile, 'rb').read()
     1092        # only accommodation payments are exported
     1093        self.assertEqual(
     1094            result,
     1095            'ac,amount_auth,creation_date,p_category,p_current,p_id,p_item,'
     1096            'p_level,p_session,p_state,payment_date,r_amount_approved,r_code,'
     1097            'r_desc,student_id,matric_number,reg_number,firstname,middlename,lastname,'
     1098            'state,current_session,entry_session,entry_mode,faccode,depcode,certcode\r\n'
     1099            'abc,12.12,%s-04-01 13:12:01#,bed_allocation,1,id1,xyz,100,%s,'
     1100            'paid,%s-04-01 14:12:01#,12.12,cde,,A111111,234,123,'
     1101            'Anna,M.,Tester,created,2012,2010,ug_ft,NA,NA,CERT1\r\n'
     1102            'abc,12.12,%s-04-01 13:12:01#,hostel_maintenance,1,id2,xyz,100,%s,'
     1103            'paid,%s-04-01 14:12:01#,12.12,cde,,A111111,234,123,'
     1104            'Anna,M.,Tester,created,2012,2010,ug_ft,NA,NA,CERT1\r\n'
     1105            % (curr_year-6, curr_year-6, curr_year-6,
     1106               curr_year-6, curr_year-6, curr_year-6)
    10451107            )
    10461108        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py

    r15246 r15277  
    11141114            'studentpayments', 'studentunpaidpayments',
    11151115            'bedtickets', 'sfpaymentsoverview', 'sessionpaymentsoverview',
    1116             'studylevelsoverview', 'combocard', 'bursary')
     1116            'studylevelsoverview', 'combocard', 'bursary',
     1117            'accommodationpayments')
    11171118
    11181119    #: A tuple containing all exporter names needed for backing
Note: See TracChangeset for help on using the changeset viewer.