def remove_cla_manager(username, signature_id, lfid): """ Removes the LFID from the project ACL :param username: username of the user :type username: string :param project_id: The ID of the project :type project_id: UUID :param lfid: the lfid (manager username) to be removed to the project acl :type lfid: string """ # Find project signature = Signature() try: signature.load(str(signature_id)) except DoesNotExist as err: return {'errors': {'signature_id': str(err)}} # Validate user is the manager of the project signature_acl = signature.get_signature_acl() if username not in signature_acl: return {'errors': {'user': "******"}} # Avoid to have an empty acl if len(signature_acl) == 1 and username == lfid: return {'errors': {'user': "******"}} # Remove LFID from the acl signature.remove_signature_acl(lfid) signature.save() # Return modified managers return get_managers_dict(signature_acl)
def remove_cla_manager(username, signature_id, lfid): """ Removes the LFID from the project ACL :param username: username of the user :type username: string :param project_id: The ID of the project :type project_id: UUID :param lfid: the lfid (manager username) to be removed to the project acl :type lfid: string """ # Find project signature = Signature() try: signature.load(str(signature_id)) except DoesNotExist as err: return {'errors': {'signature_id': str(err)}} # Validate user is the manager of the project signature_acl = signature.get_signature_acl() if username not in signature_acl: return { 'errors': { 'user': "******" } } # Avoid to have an empty acl if len(signature_acl) == 1 and username == lfid: return { 'errors': { 'user': "******" } } # Remove LFID from the acl signature.remove_signature_acl(lfid) signature.save() # get cla managers for email content managers = get_cla_managers(username, signature_id) # Get Company and Project instances try: project = get_project(signature.get_signature_project_id()) except DoesNotExist as err: return err try: company_instance = get_company(signature.get_signature_reference_id()) except DoesNotExist as err: return err # Send email to removed CLA manager # send email to newly added CLA manager try: subject, body, recipients = remove_cla_manager_email_content( lfid, project, company_instance, managers) get_email_service().send(subject, body, recipients) except Exception as err: return { 'errors': {'Failed to send email for lfid: %s , %s ' % (lfid, err)} } event_data = f'User with lfid {lfid} removed from project ACL with signature {signature.get_signature_id()}' Event.create_event( event_data=event_data, event_summary=event_data, event_type=EventType.RemoveCLAManager, contains_pii=True, ) # Return modified managers return get_managers_dict(signature_acl)