Jump to content

Yas Opisso

Members
  • Posts

    15
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Yas Opisso

  1. Hi there, can I get an invite? contact@yasopisso.com
  2. I think that bids are stored in seconds. You will need to convert the 5 bid days to seconds (assuming an 8 hour / day or whatever you have setup as default). Best, - Yas
  3. Hi, You essentially have to delete the user assignment, here's a function below that removes all users given a specific task_id, it might not be exactly what you need since you might only want to remove a specific user but this should point you in the right direction. # Assumes a session is already established def unassing_users_from_task(task_id): # Queries users assigned to a task users_assigned_to_tasks = session.query( 'select assignments.context_id from User ' 'where assignments any (context_id = "{0}")'.format(task_id) ) for user in users_assigned_to_tasks: assignments = user['assignments'] for assignment in assignments: if assignment['context_id'] == task_id: session.delete(assignment) # Remember to use session.commit() I would only do this if you had in fact removed an assignment. session.commit()
  4. If you want to go directly through the project, you can look at its "assignments" key. You can tweak the code above to query Assignment instead of Task. Edit: Although to be fair I'm not sure the "assignments" key in a project will give you assignments for every children. I don't believe the project has assignee so it might work. I haven't tried doing so this way.
  5. Here is a quick example; let's suppose you have the user ID and you need to find out the list of projects he/she has assigned. session = #<build your session here> user_id = '805cf360-115e-11e5-ax81-002593f15914' # This query looks at active projects only task_query = 'select project.id, project.name, project.full_name from Task where project.status is active and assignments any (resource_id={})'.format(user_id) ft_tasks = session.query(task_query).all() for task in ft_tasks: project_id = task['project']['id'] project_code = task['project']['name'] project_name = task['project']['full_name'] print(project_code, project_name, project_id)
  6. What's your end goal? Find a list of projects that user X is assigned to? If so I would instead query the assignments for the user and find the project from there.
  7. If you don't want Ftrack to manage the locations for you, you could use the ftrack.unmanaged location and publish the files using that location. You can query the location like this: location = session.query('Location where name is "ftrack.unmanaged"').first()
  8. Hi, I would change the Asset query from .one() to .first() if you leave .one() it will complain that the Asset doesn't exist (ftrack_api.exception.NoResultFoundError), setting it to .first() will return None which will properly trigger your if not asset: code block. There should only be one Asset with the same name under the same parent so .first() should work just fine. If you still need to set the version numbers yourself (at times we do that to make sure that the version has the same number that the component published) and you want to avoid duplicate errors, much like what you did with the Asset, you can query the AssetVersion with the specific version number under the same asset and see if it returns a value. If it does you could either notify the user that a previous version exist, and perhaps as if overwriting is desired (this can be dangerous but useful at times). As a side note, on the code you provided you are setting the value of asset_version the first time to a query that returns the first entry it finds under the asset, than overriding it with a new AssetVersion entity you create.
×
×
  • Create New...