Beispiel #1
0
def cli_project_search(project_name, is_closed, date, date_filter,
                       date_operator):
    """Search projects by criteria. Returns list of projects"""
    projects = project_search(project_name, is_closed, date, date_filter,
                              date_operator)
    print_success("Search properly finished")
    print_projects(projects)
Beispiel #2
0
def cli_project_delete(project_identifier, identifier_type):
    """Delete project with provided name. Returns total deleted projects"""
    project_identifier_arg = project_identifier
    logger.info("about to delete project by {0} = {1}".format(
        identifier_type, project_identifier))
    if identifier_type == "id":
        project_identifier_arg = int(project_identifier)
    project_delete(project_identifier_arg)
    print_success(
        "Successfuly deleted project name: {0}".format(project_identifier))
Beispiel #3
0
def cli_project_create(project_name, description, planned_start_date,
                       planned_end_date):
    """Creates new project"""
    try:
        project = project_create(project_name, description, planned_start_date,
                                 planned_end_date)
        print_success("Project created successfully")
        print_projects(project)
    except Exception:
        traceback.print_exc()
        print_fail("Failed to create project")
Beispiel #4
0
def cli_task_delete(project_identifier, task_number, identifier_type):
    """Delete task with provided task number and project name. Returns total deleted tasks"""
    project_identifier_arg = project_identifier
    if identifier_type == "id":
        project_identifier_arg = int(project_identifier)
    try:
        task_delete(project_identifier_arg, task_number)
        print_success("Successfuly deleted task, task number: {0} of project: {1}".format(task_number, project_identifier))
    except Exception:
        traceback.print_exc()
        print_fail("Failed to delete task, task number: {0} of project: {1}".format(task_number, project_identifier))
Beispiel #5
0
def cli_task_find(project_identifier, task_number, identifier_type):
    """Find task by project name and task number. Returns one task or None"""
    project_identifier_arg = project_identifier
    if identifier_type == "id":
        project_identifier_arg = int(project_identifier)
    task = task_find(project_identifier_arg, task_number)
    if task is None:
        print_success("Not found task with project {0} and task number {1}".format(project_identifier, task_number))
    else:
        print_success("Found task with project {0} and task number {1}".format(project_identifier, task_number))
        print_tasks(task)
Beispiel #6
0
def cli_task_create(project_identifier, task_number, identifier_type, description):
    """Creates new task"""
    try:
        project_identifier_arg = project_identifier
        if identifier_type == "id":
            project_identifier_arg = int(project_identifier)
        task = task_create(project_identifier_arg, task_number, description)
        print_success("Task created successfully")
        print_tasks(task)
    except Exception:
        traceback.print_exc()
        print_fail("Failed to create task")
Beispiel #7
0
def cli_project_find(project_identifier, identifier_type):
    """Find project by its identifier. Returns one project or None"""
    project_identifier_arg = project_identifier
    logger.info("find project by {0} = {1}".format(identifier_type,
                                                   project_identifier))
    if identifier_type == "id":
        project_identifier_arg = int(project_identifier)
    project = project_find(project_identifier_arg)
    if project is None:
        print_success(
            "Not found project with identifier {0}".format(project_identifier))
    else:
        print_success(
            "Found project with identifier {0}".format(project_identifier))
        print_projects(project)
Beispiel #8
0
def cli_task_update(project_identifier, task_number, identifier_type, description, end_date, user_external_id):
    """Updates existing task"""
    try:
        project_identifier_arg = project_identifier
        if identifier_type == "id":
            project_identifier_arg = int(project_identifier)
        user = None
        if user_external_id == "":
            user = ""
        elif not user_external_id is None:
            user = user_find(user_external_id)
        task = task_update(project_identifier_arg, task_number, description, end_date, user)
        print_success("Successfuly updated task number: {0} of project: {1}".format(task_number, project_identifier))
        print_tasks(task)
    except Exception as e:
        if isinstance(e, Task.DoesNotExist):
            print_fail("Not found task to update, task number: {0} of project: {1}".format(task_number, project_identifier))
        else:
            traceback.print_exc()
            print_fail("Failed to update task, task number: {0} of project: {1}".format(task_number, project_identifier))
Beispiel #9
0
def cli_project_update(project_identifier, identifier_type, project_name,
                       description, planned_start_date, planned_end_date,
                       closed_date):
    """Updates existing project"""
    project_identifier_arg = project_identifier
    logger.info("about to update project by {0} = {1}".format(
        identifier_type, project_identifier))
    if identifier_type == "id":
        project_identifier_arg = int(project_identifier)
    try:
        project = project_update(project_identifier_arg, project_name,
                                 description, planned_start_date,
                                 planned_end_date, closed_date)
        print_success(
            "Successfuly updated project name: {0}".format(project_identifier))
        print_projects(project)
    except Exception as e:
        if isinstance(e, Project.DoesNotExist):
            print_fail("Not found project to update, name:{0}".format(
                project_identifier))
        else:
            traceback.print_exc()
            print_fail("Failed to update project with name: {0}".format(
                project_identifier))
Beispiel #10
0
def cli_task_search(project_name, task_number, is_closed, end_date, date_operator, user_external_id):
    """Search tasks by criteria. Returns list of tasks"""
    tasks = task_search(project_name, is_closed, task_number, end_date, date_operator, user_external_id)
    print_success("Search properly finished")
    print_tasks(tasks)