Luigi Posted September 19, 2017 Report Share Posted September 19, 2017 When a team member is added to a project in ftrack and it is not added to the global project team space but to a subgroup, the sync to our DB is not trigged and user does not show up there. Also although the user shows up in the global team member space it can not be removed from there. It needs to be removed from the group it was originally added to it. Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted September 20, 2017 Report Share Posted September 20, 2017 On 19/09/2017 at 11:22 AM, Luigi said: When a team member is added to a project in ftrack and it is not added to the global project team space but to a subgroup, the sync to our DB is not trigged and user does not show up there. Is this the ftrack.update event not being emitted? Quote Also although the user shows up in the global team member space it can not be removed from there. It needs to be removed from the group it was originally added to it. Not sure I fully understand this. Could you give an example to explain the issue more? Link to comment Share on other sites More sharing options...
Luigi Posted September 27, 2017 Author Report Share Posted September 27, 2017 Quote Is this the ftrack.update event not being emitted? Yes, no ftrack event being emitted, unfortunately. Quote Could you give an example When a user is directly added to a group, there is no event. I have first to assign him/her ungrouped and then add him/her to a group Link to comment Share on other sites More sharing options...
Mattias Lagergren Posted October 2, 2017 Report Share Posted October 2, 2017 Thanks, I will report these issues as bugs Link to comment Share on other sites More sharing options...
Remus Avram Posted October 3, 2017 Report Share Posted October 3, 2017 As a workaround we run a script every X minutes which adds the uses added only to the groups to the project, too. """ @package bin.check_projects_members @brief Check if the members of the projects have been added to the project. @details If the user has been added to the project group, but not to the project, then we need to add him/her to the project @author remusav """ import logging import ftrack_session_manager log = logging.module_logger(__name__) session = ftrack_session_manager.main_session def get_grouped_users(project): """ @param project: Ftrack Project @return list() of all grouped users from the project """ grouped_users = [] for allocation in project['allocations']: user_or_group = allocation['resource'] if user_or_group.entity_type == "Group": for membership in user_or_group['memberships']: grouped_users.append(membership['user']) return grouped_users def get_project_users(project): """ @param project: Ftrack Project @return list() of all users added to the project """ users = [] for allocation in project['allocations']: user_or_group = allocation['resource'] if user_or_group.entity_type == "User": users.append(user_or_group) return users def add_user_to_project(user, project): """ Add the user to the Ftrack project @param user: Ftrack user @param project: Ftrack project """ try: session.create("Appointment", {"context": project, "resource": user, "type": "allocation" }) session.commit() log.info("user '{0}' added to project '{1}'".format(user['username'], project['name'])) except Exception, e: session.rollback() log.error("user '{0}' couldn't be added to project '{1}'".format(user['username'], project['name'])) log.error(e) def main(): """ Main function. """ projects = session.query("Project where status is 'active'").all() for project in projects: grouped_users = get_grouped_users(project=project) project_users = get_project_users(project=project) users_not_assigned_to_project = set(grouped_users) - set(project_users) for user in users_not_assigned_to_project: add_user_to_project(user, project) if __name__ == '__main__': main() Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.