def check_if_project_can_be_transfered(project, new_owner):
 if (project.owner is None):
  return {'can_be_updated': False, 'reason': ERROR_PROJECT_WITHOUT_OWNER}
 if (project.owner == new_owner):
  return (True, None)
 if project.is_private:
  current_projects = new_owner.owned_projects.filter(is_private=True).count()
  max_projects = new_owner.max_private_projects
  error_project_exceeded = _("You can't have more private projects")
  current_memberships = project.memberships.count()
  max_memberships = new_owner.max_memberships_private_projects
  error_memberships_exceeded = _('This project reaches your current limit of memberships for private projects')
 else:
  current_projects = new_owner.owned_projects.filter(is_private=False).count()
  max_projects = new_owner.max_public_projects
  error_project_exceeded = _("You can't have more public projects")
  current_memberships = project.memberships.count()
  max_memberships = new_owner.max_memberships_public_projects
  error_memberships_exceeded = _('This project reaches your current limit of memberships for public projects')
 if ((max_projects is not None) and (current_projects >= max_projects)):
  return (False, error_project_exceeded)
 if ((max_memberships is not None) and (current_memberships > max_memberships)):
  return (False, error_memberships_exceeded)
 return (True, None)

def check_if_project_can_be_transfered ( project , new_owner ) : if ( project . owner is None ) : return { 'can_be_updated' : False , 'reason' : ERROR_PROJECT_WITHOUT_OWNER } if ( project . owner == new_owner ) : return ( True , None ) if project . is_private : current_projects = new_owner . owned_projects . filter ( is_private = True ) . count ( ) max_projects = new_owner . max_private_projects error_project_exceeded = _ ( "You can't have more private projects" ) current_memberships = project . memberships . count ( ) max_memberships = new_owner . max_memberships_private_projects error_memberships_exceeded = _ ( 'This project reaches your current limit of memberships for private projects' ) else : current_projects = new_owner . owned_projects . filter ( is_private = False ) . count ( ) max_projects = new_owner . max_public_projects error_project_exceeded = _ ( "You can't have more public projects" ) current_memberships = project . memberships . count ( ) max_memberships = new_owner . max_memberships_public_projects error_memberships_exceeded = _ ( 'This project reaches your current limit of memberships for public projects' ) if ( ( max_projects is not None ) and ( current_projects >= max_projects ) ) : return ( False , error_project_exceeded ) if ( ( max_memberships is not None ) and ( current_memberships > max_memberships ) ) : return ( False , error_memberships_exceeded ) return ( True , None )
return if the project can be transfered to another member .