Ejemplo n.º 1
0
def share(observer, tid):
    """Share task with other users"""
    try:
        manager = Actions()
        manager.share_task(observer, tid)
    except Exception as e:
        click.echo(e)
Ejemplo n.º 2
0
def change(login):
    """Set user as current (Sign In)"""
    try:
        manager = Actions()
        manager.change_user(login)
    except Exception as e:
        print(e)
Ejemplo n.º 3
0
def delete_task(tid):
    """Deleting task"""
    try:
        manager = Actions()
        manager.delete_task(tid)
    except IndexError as e:
        click.echo("Can't find task")
Ejemplo n.º 4
0
def archieve():
    """Show list of completed tasks"""
    manager = Actions()
    archieved_tasks = manager.get_archieve()
    if archieved_tasks is None:
        click.secho("Archieve is empty", bg='red', fg='white')
        return

    console_utils.print_tree(manager, archieved_tasks)
Ejemplo n.º 5
0
def plans():
    manager = Actions()
    schedulers = manager.get_schedulers()
    for scheduler in schedulers:
        click.echo("Scheduler ID(sid): " + scheduler.sid +
                   click.style("\nTask title: " + scheduler.task.title +
                               "\n\n",
                               fg='white',
                               bold=True))
Ejemplo n.º 6
0
def planned(sid):
    """Show list of completed tasks"""
    manager = Actions()
    tasks = manager.get_planned_list(sid)
    if not tasks:
        click.echo("No tasks with such sid")
        return
    click.secho("Scheduler ID: " + sid, fg='yellow')
    for task in tasks:
        click.echo(task.tid + " - " + task.title)
Ejemplo n.º 7
0
def tag(name):
    """Ordering task by tag"""
    try:
        manager = Actions()
        ordered_tasks = manager.order_by_tag(name)
        click.echo("Ordered by tag:" + name)
        click.echo()
        console_utils.format_print_ordered(ordered_tasks)
    except IndexError as e:
        click.echo(e)
    except Exception as e:
        click.echo(e)
Ejemplo n.º 8
0
def show(tid):
    """Showing full info about task: choose INDEX or TID"""

    try:
        manager = Actions()
        task = manager.get_task_by_tid(tid)
        subtasks = manager.get_subtasks(tid)
        console_utils.format_print_info(task, subtasks, manager)

    except IndexError as e:
        click.echo("IndexError: " + e)
    except Exception as e:
        click.echo("Something went wrong: {}".format(e))
Ejemplo n.º 9
0
def priority(name):
    """Ordering task by priority"""
    try:
        manager = Actions()
        priority = Priority[name]
        ordered_tasks = manager.order_by_priority(priority)
        click.echo("Ordered by priority:" +
                   click.style(name, bg='red', fg='white'))
        click.echo()
        console_utils.format_print_ordered(ordered_tasks)
    except IndexError as e:
        click.echo("IndexError: " + e)
    except Exception as e:
        click.echo(e)
Ejemplo n.º 10
0
def edit(tid, tag, description, title, priority, end):
    """Editing tasks. Choose index and field"""
    try:
        manager = Actions()
        if tid is None:
            raise ValueError("Input tid!")
        manager.edit_task(tid,
                          title=title,
                          tag=tag,
                          priority=priority,
                          description=description,
                          end=end)
    except Exception as e:
        click.echo(e)
Ejemplo n.º 11
0
def scheduler(startdate, enddate, tag, description, title, reminder, observers,
              priority, interval):
    """Crating new scheduler for task"""
    observers = console_utils.split_str_to_list(observers)
    priority = Priority[priority]
    tag = Tag(tag)
    manager = Actions()
    manager.add_scheduler(title,
                          datetime.strptime(startdate, "%Y-%m-%d"),
                          datetime.strptime(enddate, "%Y-%m-%d"),
                          interval,
                          tag=tag,
                          description=description,
                          observers=observers,
                          reminder=datetime.strptime(reminder, "%H:%M"),
                          priority=priority)
Ejemplo n.º 12
0
def current():
    """Showing current user"""
    try:
        manager = Actions()
        current = manager.task_storage.load_user(
            manager.task_storage.current_uid)
        click.echo("Login: {}".format(current.login))
        click.echo("Full name: {} {}".format(current.name, current.surname))
        click.echo("UID: {}".format(current.uid))
    except Exception as e:
        print(e)
Ejemplo n.º 13
0
def status(tid, status):
    """Change status of task: done, undone, process. Required data: TID, status name"""
    try:
        manager = Actions()
        status = Status[status]

        if status == Status.DONE:
            manager.complete_task(tid)
        elif status == Status.PROCESS:
            manager.begin_task(tid)
        elif status == Status.UNDONE:
            manager.uncomplete_task(tid)

    except ValueError as e:
        print(e)
    except Exception as e:
        print(e)
Ejemplo n.º 14
0
def add(startdate, enddate, tag, description, title, reminder, observers,
        priority, parent):
    """Adding new task"""
    try:
        observers = console_utils.split_str_to_list(observers)
        priority = Priority[priority]
        tag = Tag(tag)
        manager = Actions()
        manager.add_task(title,
                         datetime.strptime(startdate, "%Y-%m-%d"),
                         datetime.strptime(enddate, "%Y-%m-%d"),
                         tag=tag,
                         description=description,
                         observers=observers,
                         reminder=datetime.strptime(reminder, "%H:%M"),
                         priority=priority,
                         parent=parent)

    except ValueError as e:
        click.echo("ValueError:" + str(e))
    except TypeError:
        click.echo("Check your data!")
    except Exception as e:
        click.echo("Exception:" + str(type(e)))
Ejemplo n.º 15
0
def main():
    actions = Actions()
    # TODO Nespresso, what else?
    print("Exiting application...")
Ejemplo n.º 16
0
def add_user(login, name, surname):
    """Add new user"""
    manager = Actions()
    manager.add_new_user(login, name, surname)
Ejemplo n.º 17
0
def edit(sid, title, interval):
    manager = Actions()
    manager.edit_scheduler(sid, title=title, interval=interval)
Ejemplo n.º 18
0
def cli():
    """Task Manager (tman) application for managing tasks and events"""
    #try:
    manager = Actions()
    manager.get_schedulers()
Ejemplo n.º 19
0
def list():
    """Showing list of user's tasks"""
    manager = Actions()
    tasks_list = manager.get_tasks_list()
    console_utils.print_tree(manager, tasks_list)
Ejemplo n.º 20
0
def make_link(first, second):
    """Make link between 2 tasks """
    manager = Actions()
    manager.make_link(first, second)