Changeset 6126


Ignore:
Timestamp:
18 May 2011, 15:57:39 (14 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.

Location:
main/waeup.sirp/trunk/src/waeup/sirp/browser
Files:
2 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):
  • main/waeup.sirp/trunk/src/waeup/sirp/browser/templates/facultymanagepage.pt

    r6025 r6126  
    2626  <li><a href="#tab-1"><span>Settings</span></a></li>
    2727  <li><a href="#tab-2"><span tal:content="view/subunits">Contents</span></a></li>
     28  <li><a href="#tab-3"><span>Local Roles</span></a></li>
    2829</ul>
    2930   
     
    111112        </span>
    112113    </div>     
    113  
    114114</div>
     115
     116<div id="tab-3">
     117    <h3>Manage local roles</h3>
     118    <table class="zebra">
     119    <tr>
     120        <td>
     121        <label for="users">User:</label>
     122        </td>
     123        <td>
     124            <select  id="user" name="user"  tal:repeat="user view/getUsers">
     125              <option tal:attributes="value user/name">
     126                <span tal:replace="user/val/description">USERTITLE</span>
     127              </option>
     128            </select>
     129        </td>
     130    </tr>
     131    <tr>
     132        <td>
     133        <label for="local_roles">Local Role:</label>
     134        </td>
     135        <td>
     136            <select  id="local_role" name="local_role"  tal:repeat="localrole view/getLocalRoles">
     137              <option tal:attributes="value localrole/name">
     138                <span tal:replace="localrole/title">LOCALROLETITLE</span>
     139              </option>
     140            </select>
     141        </td>
     142    </tr>
     143    </table>
     144
     145    <div id="actionsView">
     146        <span class="actionButtons" tal:condition="view/availableActions">
     147            <span tal:repeat="action view/actions"
     148                  tal:omit-tag="">
     149              <input tal:condition="python:action.label in view.tabthreeactions"
     150                     tal:replace="structure action/render"/>
     151            </span>
     152        </span>
     153    </div>
     154</div>
     155
    115156</div>
    116157</form> 
Note: See TracChangeset for help on using the changeset viewer.