Friends,
Kindly help me with this scenario.
Scenario: I have two employees 'A' and 'B' under a manager 'X'. X assigns a module to 'A' and 'B'. .
I have a folder called 'Projects' . I have a multiple choice field that contains the list of employees. I am selecting 'A' first and 'B' second from the list. Once the page is created selected members will be assigned the role of 'tech_team'. When I log in as 'A' or 'B' I must be able to view the 'Project' folder but the folder is visible only for the last selected person.
Note: No error is displaying.
Code Snippet:
sub_project.xml:
<field name="assigned_to" type="zope.schema.Set">
<description/>
<title>Assigned To</title>
<value_type type="zope.schema.Choice">
<vocabulary>plonexp.techTeam</vocabulary>
</value_type>
</field>
Retrives all the employee.
Assign Roles:
for member in self.context.assigned_to:
user=member.id
role='tech_team'
if not role in api.user.get_roles(username=str(user),obj=self.context):
api.content.disable_roles_acquisition(self.context)
self.context.plone_log('disabled for Sub Project')
api.content.disable_roles_acquisition(portal[current_path[2]][current_path[3]])
self.context.plone_log('Disabled for main Project')
api.user.grant_roles(username=str(user),roles=[role],obj=self.context)
self.context.plone_log('roles granted for sub project')
api.user.grant_roles(username=str(user),roles=[role],obj=portal[current_path[2]][current_path[3]])
self.context.plone_log('roles granted for project')
self.context.plone_log(api.user.get_roles(username=str(user),obj=self.context))
Assigns tech_team roles to the employee in the list. This gives the view and access content information feature to that particular set of employees.
Retriving the project list (Sub Project)
subProjectList=[]
portal_catalog=api.portal.get_tool('portal_catalog')
subProject=api.content.find(portal_type="sub_project",context=self.context)
self.context.plone_log(subProject)
for brain in subProject:
sub=brain.getObject()
subProjectList.append({
'title':sub.title,
'assigned_to':sub.assigned_to,
'hours_of_work':sub.hours_of_work,
'url':brain.getURL(),
})
self.context.plone_log(subProjectList)
return subProjectList
I am able to retrieve the projects except for the projects that are assigned to multiple employees.
Kindly help me...