Beispiel #1
0
def remove_project(user: User):
    """
    Remove a project for user
    :param user: user with all projects
    """

    user.projects = get_projects_by_user_id(user.user_id)

    if not len(user.projects):
        return

    msg = "Insert the project id to remove: "
    user_input = helpers.get_int(msg)

    # get all project ids
    all_projects_id = user.get_projects_id()

    while user_input not in all_projects_id:
        print("invalid option, Try again. Type 0 for exit")
        user_input = helpers.get_int(msg)

        if user_input == 0:
            return

    # Remove project from db
    project_was_removed = conn.remove_project_by_id(user_input)

    if not project_was_removed:
        print("Cannot remove the project")
        return

    user.remove_project(user_input)

    print("Project is removed!")
Beispiel #2
0
def show_projects_by_user(user: User):
    """
    Print all the projects for a user
    :param user: user object
    :return all user projects:
    """

    projects = get_projects_by_user_id(user.user_id)

    if not len(projects):
        return

    user.projects = projects

    print("\n========================PROJECTS================================")
    message = "ID: {}, Name: {}, Description: {}"

    for project in projects:
        print(message.format(project.project_id, project.name, project.description))
    print("==================================================================\n")