Assign roles - reg

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...:slight_smile:

At least

context=api.content.get("/".join(self.context.getPhysicalPath()))

make little sense...why don't you use

context=self.context

?

Look (in the ZMI) in portal_catalog -> Contents for an object that does not show up. It will show you all indexed values for the particular content object...check why the values don't match with the query...it's either the path aka context or the portal_type. In addition you have to be aware that a search query returns only content visible and accessible for the current user.

Kindly reply to my actual problem . I have changed the above code but didn't update here. Thank you.

I clearly responded to your problem and I clearly pointed you how debug this catalog query issue.

No bro thats not the problem I changed it to self.context

Please, learn reading answers.

Ooh .. thank you for the suggestions

Please stop being a sorehead.

Your question was "I am able to retrieve the projects except for the projects that are assigned to multiple employees."

The related code here and key to your problem is that the catalog query does not return what you want.

And I gave you clear instructions how to investigate yourself based on your data and your installation.

So come up with facts instead of smashing us with code and configuration that we can hardly verify ourselves with a reasonable amount of time.