Changeset 9002


Ignore:
Timestamp:
13 Jul 2012, 16:36:21 (12 years ago)
Author:
Henrik Bettermann
Message:

Add lecturer local role which has no dynamic role assignment yet.

Add test_import to CourseProcessorTests?.

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

Legend:

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

    r8962 r9002  
    152152    grok.permissions('waeup.showStudents', 'waeup.viewAcademics')
    153153
     154class Lecturer(grok.Role):
     155    """The lecturer role is meant for the
     156    assignment of dynamic roles only.
     157    """
     158    grok.name('waeup.local.Lecturer')
     159    grok.title(u'Lecturer')
     160    grok.permissions('waeup.showStudents', 'waeup.viewAcademics')
     161
    154162class Owner(grok.Role):
    155163    grok.name('waeup.local.Owner')
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.txt

    r8962 r9002  
    4242
    4343    >>> len(list(get_waeup_roles(also_local=True)))
    44     28
     44    29
    4545
    4646
  • main/waeup.kofa/trunk/src/waeup/kofa/students/dynamicroles.py

    r8963 r9002  
    4646    rolename_mapping = {
    4747        'waeup.local.ClearanceOfficer':'waeup.StudentsClearanceOfficer',
    48         'waeup.local.UGClearanceOfficer':'waeup.StudentsClearanceOfficer',
    49         'waeup.local.PGClearanceOfficer':'waeup.StudentsClearanceOfficer',
    5048        }
    5149
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r8996 r9002  
    3030    grok.implements(ICourse, ICourseAdd)
    3131
    32     local_roles = []
     32    local_roles = ['waeup.local.Lecturer']
    3333
    3434    def __init__(self,
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py

    r9001 r9002  
    6464
    6565CERTIFICATE_HEADER_FIELDS = CERTIFICATE_SAMPLE_DATA.split(
     66    '\n')[0].split(',')
     67
     68COURSE_SAMPLE_DATA = open(
     69    os.path.join(os.path.dirname(__file__), 'sample_course_data.csv'),
     70    'rb').read()
     71
     72COURSE_HEADER_FIELDS = COURSE_SAMPLE_DATA.split(
    6673    '\n')[0].split(',')
    6774
     
    375382        self.row3 = dict(department_code='DEP1', faculty_code='FAC1', code="CRS2")
    376383        self.row4 = dict(department_code='DEP1', faculty_code='FAC1', code="CRS1")
     384
     385        self.csv_file_course = os.path.join(self.workdir, 'sample_course_data.csv')
     386        open(self.csv_file_course, 'wb').write(COURSE_SAMPLE_DATA)
    377387        return
    378388
     
    419429        self.assertTrue('CRS1' not in self.app['faculties']['FAC1']['DEP1'].courses.keys())
    420430        return
     431
     432    def test_import(self):
     433        num, num_warns, fin_file, fail_file = self.proc.doImport(
     434            self.csv_file_course, COURSE_HEADER_FIELDS)
     435        content = open(fail_file).read()
     436        self.assertEqual(num_warns,6)
     437        self.assertEqual(
     438            content,
     439            'faculty_code,department_code,code,local_roles,--ERRORS--\r\n'
     440            'FAC1,DEP1,CRS2,"[{\'user_name\':\'alice\',\'local_role\':\'waeup.local.Lecturer\'}]",'
     441            'local_roles: alice does not exist\r\n'
     442            'FAC1,DEP1,CRS2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.Boss\'}]",'
     443            'local_roles: waeup.local.Boss not allowed\r\n'
     444            'FAC1,DEP1,CRS2,[(\'anything\')],local_roles: no dicts\r\n'
     445            'FAC1,DEP1,CRS2,[,local_roles: Error\r\n'
     446            'FAC1,DEP1,CRS2,"[{\'user\':\'anne\',\'local\':\'waeup.local.Lecturer\'}]",'
     447            'local_roles: user_name or local_role missing\r\n'
     448            'FAC11,DEP2,CRS2,"[{\'user_name\':\'anne\',\'local_role\':\'waeup.local.Lecturer\'}]",'
     449            'Not all parents do exist yet. Skipping\r\n'
     450            )
     451        # Anne got a local role in course ABC.
     452        dep = self.app['faculties']['FAC1']['DEP1'].courses['CRS2']
     453        role_map = IPrincipalRoleMap(dep)
     454        local_role, user_name, setting = role_map.getPrincipalsAndRoles()[0]
     455        self.assertEqual(user_name, 'anne')
     456        self.assertEqual(local_role, 'waeup.local.Lecturer')
     457        shutil.rmtree(os.path.dirname(fin_file))
     458        return
     459
    421460
    422461class CertificateProcessorTests(UniversityProcessorSetup):
Note: See TracChangeset for help on using the changeset viewer.