Ignore:
Timestamp:
18 May 2011, 15:57:39 (13 years ago)
Author:
Henrik Bettermann
Message:

Add 'Local roles' tab to facultymanagepage.pt and implement assignment of local roles on faculty level. The removal facilities and tests will follow.

File:
1 edited

Legend:

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

    r6106 r6126  
    1414from hurry.workflow.interfaces import NoTransitionAvailableError
    1515from zope import schema
    16 from waeup.sirp.browser.resources import warning, datepicker, tabs, datatable
    1716try:
    1817    from zope.authentication.interfaces import (
     
    2221    from zope.app.security.interfaces import (
    2322        IAuthentication, IUnauthenticatedPrincipal, ILogout)
     23from zope.securitypolicy.interfaces import IPrincipalRoleManager, IPrincipalRoleMap
    2424from zope.component import (
    2525    getUtility, createObject,getAllUtilitiesRegisteredFor)
     
    2727from zope.exceptions import DuplicationError
    2828from zope.session.interfaces import ISession
    29 
     29from waeup.sirp.browser.resources import warning, datepicker, tabs, datatable
    3030from waeup.sirp.browser import (
    3131    WAeUPPage, WAeUPEditFormPage, WAeUPAddFormPage,
     
    4040    IWAeUPXMLImporter, IWAeUPXMLExporter, IBatchProcessor)
    4141from waeup.sirp.university.catalog import search
     42from waeup.sirp.university.faculty import local_roles as faculty_local_roles
    4243from waeup.sirp.university.vocabularies import course_levels
    4344from waeup.sirp.widgets.restwidget import ReSTDisplayWidget
     
    950951    @grok.action('Cancel')
    951952    def cancel(self, **data):
    952         self.redirect(self.url(self.context))   
     953        self.redirect(self.url(self.context))
    953954
    954955#class RemoveFacultyFormPage(RemoveFormPage):
     
    986987    #        except:
    987988    #            self.flash('Could not delete %s.' % code)
    988 
     989   
    989990class FacultyManageFormPage(WAeUPEditFormPage):
    990991    """Manage the basic properties of a `Faculty` instance.
     
    997998    taboneactions = ['Save','Cancel']
    998999    tabtwoactions = ['Add department', 'Remove selected','Cancel']
     1000    tabthreeactions = ['Add local role']
    9991001    subunits = 'Departments'
    10001002
     
    10071009    @property
    10081010    def title(self):
    1009         return self.context.longtitle()       
     1011        return self.context.longtitle()
     1012
     1013    def getLocalRoles(self):
     1014        #import pdb; pdb.set_trace()
     1015        return faculty_local_roles
     1016       
     1017    def getUsers(self):
     1018        """Get a list of all users.
     1019        """
     1020        for key, val in grok.getSite()['users'].items():
     1021            url = self.url(val)
     1022            #import pdb; pdb.set_trace()
     1023            yield(dict(url=url, name=key, val=val))
    10101024
    10111025    def update(self):
     
    10481062        self.redirect(self.url(self.context))
    10491063        return
    1050 
     1064       
     1065    @grok.action('Add local role', validator=NullValidator)
     1066    def addLocalRole(self, **data):
     1067        form = self.request.form
     1068        localrole = form['local_role']
     1069        user = form['user']
     1070        role_manager = IPrincipalRoleManager(self.context)
     1071        role_map = IPrincipalRoleMap(self.context)
     1072        #import pdb; pdb.set_trace()
     1073        role_manager.assignRoleToPrincipal(localrole, user)
     1074        self.redirect(self.url(self.context, u'@@manage')+'#tab-3')
     1075        return
    10511076
    10521077class DepartmentAddFormPage(WAeUPAddFormPage):
Note: See TracChangeset for help on using the changeset viewer.