Ignore:
Timestamp:
26 Apr 2018, 08:50:56 (7 years ago)
Author:
Henrik Bettermann
Message:

Allow lecturer role assignment also at department level.

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

Legend:

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

    r14939 r14992  
    6161    IPasswordValidator, IContactForm, IKofaUtils, ICSVExporter,
    6262    academic_sessions_vocab, DOCLINK, registration_states_vocab)
     63from waeup.kofa.university.department import Department
     64from waeup.kofa.university.course import Course
    6365from waeup.kofa.permissions import (
    6466    get_users_with_local_roles, get_all_roles, get_all_users,
     
    10111013    @property
    10121014    def getCourses(self):
     1015        courses = []
    10131016        local_roles = get_user_account(self.request).getLocalRoles()
    1014         return local_roles['waeup.local.Lecturer']
     1017        for item in local_roles.get('waeup.local.Lecturer', []):
     1018            if isinstance(item, Course):
     1019                courses.append(item)
     1020            elif isinstance(item, Department):
     1021                courses += [i for i in item.courses.values()]
     1022        return courses
    10151023
    10161024#
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/templates/mycourses.pt

    r13908 r14992  
    55<div tal:repeat="course view/getCourses">
    66    <a tal:attributes="href python:view.url(course)">
    7       <span tal:content="course/title">ROLE</span>
    8       (<span tal:content="course/code">ROLE</span>)
     7      <span tal:content="python:course.__parent__.__parent__.__parent__.code">FAC</span> /
     8      <span tal:content="python:course.__parent__.__parent__.code">DEP</span> /
     9      <span tal:content="course/longtitle">COURSE</span>
    910    </a>
    1011</div>
  • main/waeup.kofa/trunk/src/waeup/kofa/permissions.py

    r14949 r14992  
    205205
    206206
     207class DepartmentOfficer(grok.Role):
     208    """The local DepartmentOfficer role can be assigned at faculty or
     209    department level. The role allows to list all student data within the
     210    faculty/department the local role is assigned.
     211    """
     212    grok.name('waeup.local.DepartmentOfficer')
     213    grok.title(u'Department Officer')
     214    grok.permissions('waeup.showStudents',
     215                     'waeup.viewAcademics',
     216                     'waeup.exportPaymentsOverview')
     217
     218
    207219class DepartmentManager(grok.Role):
    208220    """The local DepartmentManager role can be assigned at faculty or
     
    218230                     'waeup.showStudents',
    219231                     'waeup.exportData')
    220 
    221 
    222 class DepartmentOfficer(grok.Role):
    223     """The local DepartmentOfficer role can be assigned at faculty or
    224     department level. The role allows to list all student data within the
    225     faculty/department the local role is assigned.
    226 
    227     Department Managers (Dean of Faculty or Head of Department respectively)
    228     can also list student data but not access student pages. They can
    229     furthermore export payment overviews.
    230     """
    231     grok.name('waeup.local.DepartmentOfficer')
    232     grok.title(u'Department Officer')
    233     grok.permissions('waeup.showStudents',
    234                      'waeup.viewAcademics',
    235                      'waeup.exportPaymentsOverview')
    236232
    237233
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r14896 r14992  
    39803980        self.student['studycourse'].addStudentStudyLevel(
    39813981            self.certificate, studylevel)
    3982         # Assign local Lecturer role for a certificate.
     3982        # Assign local Lecturer role for a course.
    39833983        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
    39843984        prmlocal = IPrincipalRoleManager(course)
     
    40114011        self.assertMatches('...You logged in...', self.browser.contents)
    40124012        self.assertEqual(self.browser.url, URL_LECTURER_LANDING)
     4013        self.assertTrue(
     4014            "<span>Unnamed Course (COURSE1)</span>"
     4015            in self.browser.contents)
     4016
     4017    def test_lecturer_department_role(self):
     4018        # lecturers can login and will be led to landing page also if
     4019        # role is assigned at department level.
     4020        self.login_as_lecturer()
     4021        # we remove the role granted above
     4022        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
     4023        prmlocal = IPrincipalRoleManager(course)
     4024        prmlocal.removeRoleFromPrincipal('waeup.local.Lecturer', 'mrslecturer')
     4025        notify(LocalRoleSetEvent(
     4026            course, 'waeup.local.Lecturer', 'mrslecturer', granted=False))
     4027        self.browser.open(URL_LECTURER_LANDING)
     4028        # no course appears
     4029        self.assertFalse(
     4030            "<span>Unnamed Course (COURSE1)</span>"
     4031            in self.browser.contents)
     4032        # we assign lecturer at department level
     4033        dep = self.app['faculties']['fac1']['dep1']
     4034        prmlocal = IPrincipalRoleManager(dep)
     4035        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
     4036        notify(LocalRoleSetEvent(
     4037            dep, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
     4038        self.browser.open(URL_LECTURER_LANDING)
     4039        # course appears again
     4040        self.assertTrue(
     4041            "<span>Unnamed Course (COURSE1)</span>"
     4042            in self.browser.contents)
    40134043
    40144044    def test_my_roles_link_works(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r14511 r14992  
    5858        'waeup.local.CourseAdviser800',
    5959        'waeup.local.LocalStudentsManager',
     60        'waeup.local.Lecturer',
    6061        ]
    6162
Note: See TracChangeset for help on using the changeset viewer.