Changeset 10279


Ignore:
Timestamp:
6 Jun 2013, 05:15:00 (12 years ago)
Author:
Henrik Bettermann
Message:

Add local department officer role which is allowed to export payments overviews only.

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

Legend:

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

    r10278 r10279  
    7171    grok.name('waeup.exportData')
    7272
     73class ExportPaymentsOverview(grok.Permission):
     74    grok.name('waeup.exportPaymentsOverview')
     75
     76class ExportBursaryData(grok.Permission):
     77    grok.name('waeup.exportBursaryData')
     78
    7379class ViewTranscript(grok.Permission):
    7480    grok.name('waeup.viewTranscript')
     
    9399                     'waeup.exportData')
    94100
     101class DepartmentOfficer(grok.Role):
     102    grok.name('waeup.local.DepartmentOfficer')
     103    grok.title(u'Department Officer')
     104    grok.permissions('waeup.showStudents',
     105                     'waeup.viewAcademics',
     106                     'waeup.exportPaymentsOverview')
     107
    95108class ClearanceOfficer(grok.Role):
    96109    """The clearance officer role is meant for the
     
    255268    grok.name('waeup.BursaryOfficer')
    256269    grok.title(u'Bursary Officer')
    257     grok.permissions('waeup.showStudents', 'waeup.viewAcademics')
     270    grok.permissions('waeup.showStudents',
     271                     'waeup.viewAcademics',
     272                     'waeup.exportBursaryData')
    258273
    259274class TranscriptOfficer(grok.Role):
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt

    r10278 r10279  
    4242
    4343    >>> len(list(get_waeup_roles(also_local=True)))
    44     40
     44    41
    4545
    4646
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10278 r10279  
    29612961    def _set_exporter_values(self):
    29622962        # We provide all student exporters, nothing else, yet.
    2963         # Bursary Officers don't have the general exportData permission
    2964         # and are only allowed to export bursary data.
     2963        # Bursary or Department Officers don't have the general exportData
     2964        # permission and are only allowed to export bursary or payments
     2965        # overview data respectively. This is the only place where
     2966        # waeup.exportBursaryData and waeup.exportPaymentsOverview
     2967        # are used.
     2968        exporters = []
    29652969        if not checkPermission('waeup.exportData', self.context):
    2966             self.exporters = [('Bursary Data', 'bursary')]
    2967             return
    2968         exporters = []
     2970            if checkPermission('waeup.exportBursaryData', self.context):
     2971                exporters += [('Bursary Data', 'bursary')]
     2972            if checkPermission('waeup.exportPaymentsOverview', self.context):
     2973                exporters += [('Student Payments Overview', 'paymentsoverview')]
     2974            self.exporters = exporters
     2975            return
    29692976        for name in EXPORTER_NAMES:
    29702977            util = getUtility(ICSVExporter, name=name)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10278 r10279  
    31833183            )
    31843184
     3185    def test_export_departmet_officers(self):
     3186        # Create department officer
     3187        self.app['users'].addUser('mrdepartment', 'mrdepartmentsecret')
     3188        self.app['users']['mrdepartment'].email = 'mrdepartment@foo.ng'
     3189        self.app['users']['mrdepartment'].title = 'Carlo Pitter'
     3190        # Assign local role
     3191        department = self.app['faculties']['fac1']['dep1']
     3192        prmlocal = IPrincipalRoleManager(department)
     3193        prmlocal.assignRoleToPrincipal('waeup.local.DepartmentOfficer', 'mrdepartment')
     3194        # Login as department officer
     3195        self.browser.open(self.login_path)
     3196        self.browser.getControl(name="form.login").value = 'mrdepartment'
     3197        self.browser.getControl(name="form.password").value = 'mrdepartmentsecret'
     3198        self.browser.getControl("Login").click()
     3199        self.assertMatches('...You logged in...', self.browser.contents)
     3200        self.browser.open("http://localhost/app/faculties/fac1/dep1")
     3201        self.browser.getLink("Export student data").click()
     3202        self.browser.getControl("Configure new export").click()
     3203        # Only the paymentsoverview exporter is available for department officers
     3204        self.assertFalse('<option value="students">' in self.browser.contents)
     3205        self.assertTrue(
     3206            '<option value="paymentsoverview">' in self.browser.contents)
     3207        self.browser.getControl(name="exporter").value = ['paymentsoverview']
     3208        self.browser.getControl(name="session").value = ['2004']
     3209        self.browser.getControl(name="level").value = ['100']
     3210        self.browser.getControl("Create CSV file").click()
     3211        self.assertTrue('Export started' in self.browser.contents)
     3212        # Thew job can be discarded
     3213        self.assertEqual(len(self.app['datacenter'].running_exports), 1)
     3214        #job_id = self.app['datacenter'].running_exports[0][0]
     3215        job_id = self.wait_for_export_job_completed()
     3216        self.browser.open("http://localhost/app/faculties/fac1/dep1/exports")
     3217        self.browser.getControl("Discard").click()
     3218        self.assertEqual(len(self.app['datacenter'].running_exports), 0)
     3219
    31853220    def test_export_bursary_officers(self):
    31863221        # Create bursary officer
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r10226 r10279  
    4040    local_roles = [
    4141        'waeup.local.ApplicationsManager',
     42        'waeup.local.DepartmentOfficer',
    4243        'waeup.local.DepartmentManager',
    4344        'waeup.local.ClearanceOfficer',
  • main/waeup.kofa/trunk/src/waeup/kofa/university/facultiescontainer.py

    r10247 r10279  
    2525
    2626class VirtualFacultiesExportJobContainer(VirtualExportJobContainer):
    27     """A virtual export job container for certificates.
     27    """A virtual export job container for the faculties container.
    2828    """
    2929
  • main/waeup.kofa/trunk/src/waeup/kofa/university/faculty.py

    r10064 r10279  
    3333
    3434    local_roles = [
     35        'waeup.local.DepartmentOfficer',
    3536        'waeup.local.DepartmentManager',
    3637        'waeup.local.ClearanceOfficer',
Note: See TracChangeset for help on using the changeset viewer.