Changeset 2467


Ignore:
Timestamp:
11/13/07 15:03:30 (7 years ago)
Author:
ems174@…
Message:

Adding Editor and Contributor roles so workflow works with Plone 2.5. Also adding hte Personnel Manager role. Refs #297.

Location:
weblion/FacultyStaffDirectory/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • weblion/FacultyStaffDirectory/trunk/Committee.py

    r2449 r2467  
    1313from Products.FacultyStaffDirectory.config import * 
    1414from zope.interface import implements 
    15 from Products.CMFCore.permissions import ManageUsers 
    1615from Products.CMFCore.utils import getToolByName 
    1716from Products.membrane.interfaces import IPropertiesProvider, ICategoryMapper 
    1817from Products.membrane.utils import getFilteredValidRolesForPortal 
    19 from Products.FacultyStaffDirectory.interfaces.committee import ICommittee, ICommitteeExtender 
     18from Products.FacultyStaffDirectory.interfaces.committee import ICommittee, ICommitteeExtender, ICommitteeModifiedEvent 
    2019from Acquisition import aq_inner, aq_parent 
    21 from Products.FacultyStaffDirectory.permissions import ASSIGN_COMMITTIES_TO_PEOPLE 
     20from Products.FacultyStaffDirectory.permissions import ASSIGN_COMMITTIES_TO_PEOPLE, CHANGE_ROLES 
     21from zope.event import notify 
    2222 
    2323schema = Schema(( 
     
    4040    ), 
    4141     
    42     LinesField('roles_', 
     42    LinesField('localroles', 
    4343        accessor='getRoles', 
    4444        mutator='setRoles', 
     
    4747        vocabulary='getRoleSet', 
    4848        multiValued=1, 
    49         write_permission=ManageUsers, 
     49        write_permission=CHANGE_ROLES, 
    5050        widget=MultiSelectionWidget( 
    5151            label=u'Roles', 
    52             description=u"The roles all employees in this department will have", 
     52            description=u"The roles all people belonging to committee will have", 
    5353            ), 
    5454        ), 
     
    5757 
    5858Committee_schema = getattr(PersonGrouping, 'schema', Schema(())).copy() + schema.copy() 
     59 
     60class CommitteeModifiedEvent(object): 
     61    """Event that happens when edits to a Committee have been saved""" 
     62    implements(ICommitteeModifiedEvent) 
     63 
     64    def __init__(self, context): 
     65        self.context = context 
    5966 
    6067class Committee(PersonGrouping): 
     
    8996 
    9097    # Methods 
     98    security.declareProtected(View, 'at_post_create_script') 
     99    def at_post_create_script(self): 
     100        """Notify that the Person has been modified. 
     101        """ 
     102        notify(CommitteeModifiedEvent(self)) 
     103 
     104    security.declareProtected(View, 'at_post_edit_script') 
     105    def at_post_edit_script(self): 
     106        """Notify that the Person has been modified. 
     107        """ 
     108        notify(CommitteeModifiedEvent(self)) 
    91109 
    92110    def getMembershipInformation(self, person): 
     
    121139        allowed_roles = [r for r in portal_roles if r not in INVALID_ROLES] 
    122140        return allowed_roles 
    123      
     141 
    124142    # 
    125143    # Validators 
  • weblion/FacultyStaffDirectory/trunk/events/configure.zcml

    r2112 r2467  
    66  <subscriber for="..interfaces.person.IPersonModifiedEvent" 
    77              handler=".person.modifyPersonOwnership" /> 
     8  <subscriber for="..interfaces.committee.ICommitteeModifiedEvent" 
     9              handler=".committee.modifyCommitteeRoles" /> 
    810 
    911</configure> 
  • weblion/FacultyStaffDirectory/trunk/interfaces/committee.py

    r2163 r2467  
    44__docformat__ = 'plaintext' 
    55 
    6 from zope.interface import Interface 
     6from zope.interface import Interface, Attribute 
    77from Products.SchemaExtensibility.interfaces import ISchemaExtender 
    88 
     
    1515    """ 
    1616 
     17class ICommitteeModifiedEvent(Interface): 
     18    """An event fired when a Committee object is saved. 
     19    """ 
     20     
     21    context = Attribute("The content object that was saved.") 
    1722 
     23 
     24 
  • weblion/FacultyStaffDirectory/trunk/profiles/default/rolemap.xml

    r2456 r2467  
    22<rolemap> 
    33  <roles> 
     4    <role name="Editor"/> 
     5    <role name="Contributor"/> 
     6    <role name="Personnel Manager"/> 
    47    <role name="User Preferences Editor"/> 
    58  </roles> 
  • weblion/FacultyStaffDirectory/trunk/profiles/default/workflows.xml

    r2451 r2467  
    1010      <bound-workflow workflow_id="plone_workflow"/> 
    1111    </type> 
     12    <type type_id="Classification"> 
     13      <bound-workflow workflow_id="fsd_persongrouping_workflow" /> 
     14    </type> 
     15    <type type_id="Department"> 
     16      <bound-workflow workflow_id="fsd_persongrouping_workflow" /> 
     17    </type> 
     18    <type type_id="Committee"> 
     19      <bound-workflow workflow_id="fsd_persongrouping_workflow" /> 
     20    </type> 
     21    <type type_id="Specialty"> 
     22      <bound-workflow workflow_id="fsd_persongrouping_workflow" /> 
     23    </type> 
    1224    <type type_id="FacultyStaffDirectoryTool"> 
    1325      <bound-workflow workflow_id="fsd_tool_workflow" /> 
  • weblion/FacultyStaffDirectory/trunk/profiles/default/workflows/fsd_person_workflow/definition.xml

    r2458 r2467  
    2929   <permission-role>Owner</permission-role> 
    3030   <permission-role>Manager</permission-role> 
     31   <permission-role>Personnel Manager</permission-role> 
    3132  </permission-map> 
    3233  <permission-map name="Add portal content" acquired="False"> 
     
    3435   <permission-role>Manager</permission-role> 
    3536   <permission-role>Contributor</permission-role> 
     37   <permission-role>Personnel Manager</permission-role> 
    3638  </permission-map> 
    3739  <permission-map name="Set own password" acquired="False"> 
     
    4951   <permission-role>Owner</permission-role> 
    5052   <permission-role>Manager</permission-role> 
     53   <permission-role>Personnel Manager</permission-role> 
    5154  </permission-map> 
    5255  <permission-map name="FacultyStaffDirectory: Assign Committees to People" acquired="True"> 
    5356   <permission-role>Owner</permission-role> 
    5457   <permission-role>Manager</permission-role> 
     58   <permission-role>Personnel Manager</permission-role> 
    5559  </permission-map> 
    5660  <permission-map name="FacultyStaffDirectory: Assign Classifications to People" acquired="True"> 
    5761   <permission-role>Owner</permission-role> 
    5862   <permission-role>Manager</permission-role> 
     63   <permission-role>Personnel Manager</permission-role> 
    5964  </permission-map>   
    6065  <permission-map name="FacultyStaffDirectory: Assign Specialties to People" acquired="True"> 
    6166   <permission-role>Owner</permission-role> 
    6267   <permission-role>Manager</permission-role> 
     68   <permission-role>Personnel Manager</permission-role> 
    6369  </permission-map> 
    6470 </state> 
     
    8086   <permission-role>Owner</permission-role> 
    8187   <permission-role>Manager</permission-role> 
     88   <permission-role>Personnel Manager</permission-role> 
    8289  </permission-map> 
    8390  <permission-map name="Set own password" acquired="False"> 
     
    95102   <permission-role>Owner</permission-role> 
    96103   <permission-role>Manager</permission-role> 
     104   <permission-role>Personnel Manager</permission-role> 
    97105  </permission-map> 
    98106  <permission-map name="FacultyStaffDirectory: Assign Committees to People" acquired="True"> 
    99107   <permission-role>Owner</permission-role> 
    100108   <permission-role>Manager</permission-role> 
     109   <permission-role>Personnel Manager</permission-role> 
    101110  </permission-map> 
    102111  <permission-map name="FacultyStaffDirectory: Assign Classifications to People" acquired="True"> 
    103112   <permission-role>Owner</permission-role> 
    104113   <permission-role>Manager</permission-role> 
     114   <permission-role>Personnel Manager</permission-role> 
    105115  </permission-map>     
    106116  <permission-map name="FacultyStaffDirectory: Assign Specialties to People" acquired="True"> 
    107117   <permission-role>Owner</permission-role> 
    108118   <permission-role>Manager</permission-role> 
     119   <permission-role>Personnel Manager</permission-role> 
    109120  </permission-map>   
    110121 </state> 
  • weblion/FacultyStaffDirectory/trunk/tests/testPerson.py

    r2451 r2467  
    2020from Products.FacultyStaffDirectory.config import TOOLNAME 
    2121from Products.FacultyStaffDirectory.SpecialtyInformation import SpecialtyInformation 
     22from AccessControl.unauthorized import Unauthorized 
    2223 
    2324def loadImage(name, size=0): 
     
    292293 
    293294    ## End tests for membrane stuff 
     295     
     296    def testUserPermissions(self): 
     297        """ Make sure permissions are working properly and that certain fields are only available to the user defined by the Person object. """ 
     298        self.loginAsPortalOwner() 
     299        self.anotherPerson = self.getPerson(id='bbb111', firstName="Another", lastName="Person", password="bbb111") 
     300        self.login('abc123') 
     301         
     302        user = IMembraneUserManagement(self.person); 
     303        auth = IUserAuthentication(self.person); 
     304        user.doChangeUser('bbb111', 'bbb111') 
     305 
     306         
     307         
     308        # A logged in user shouldn't be able to edit another Person without proper permissions. 
     309        try: 
     310            self.anotherPerson.base_edit() 
     311        except Unauthorized: 
     312            # Yup, that's what we want. 
     313            pass 
     314        else: 
     315            self.fail("User should not be able to edit another person without at least Editor role.") 
     316         
     317        #Make our user an Editor of anotherPerson 
     318        self.anotherPerson.manage_setLocalRoles('abc123', ['Editor']) 
     319        try: 
     320            html = self.anotherPerson.base_edit() 
     321        except Unauthorized: 
     322            self.fail("Users with the Editor role should be able to edit a Person object.") 
     323        else: 
     324            # Double-check to make sure our user is an Editor. 
     325            self.failUnlessEqual(self.anotherPerson.get_local_roles_for_userid('abc123'), ('Editor',)) 
     326            # Editor shouldn't be able to see the password field. 
     327            self.failIf('Password' in html, "Editor role is able to modify Person's password field.") 
     328            # Editor shouldn't be able to see any of the items in the User information schemata. 
     329            self.failIf('User information' in html, "Editor role is able to modify Person's user information fields.") 
     330         
     331        # Make sure the user defined by this Person can edit passwords and user settings. 
     332        self.login('bbb111') 
     333        try: 
     334            html = self.anotherPerson.base_edit() 
     335        except Unauthorized: 
     336            self.fail("User should be able to edit their own Person object.") 
     337        else: 
     338            # User should be able to see the password field. 
     339            self.failIf('Password' not in html, "User is unable to modify own password field.") 
     340            # Editor shouldn't be able to see any of the items in the User information schemata. 
     341            self.failIf('User information' not in html, "User is unable to modify own user information fields.") 
     342     
     343 
     344     
    294345 
    295346class testWithSpecialties(testPerson): 
     
    352403        self.failUnlessEqual(self.person.getResearchTopics(), ['<p>Picking up sprockets from bowls of soup</p>']) 
    353404 
    354  
    355405def test_suite(): 
    356406    from unittest import TestSuite, makeSuite 
Note: See TracChangeset for help on using the changeset viewer.