Exemple #1
0
def assign_command(n=-1, p=-1, t=-1):
    """
    Assign a note to a project or task, or a task to a project.
    """
    c = conn()
    if n > 0:
        # We are assigning a note to a project or task.
        if p > 0:
            element = Project.get(c, p)
        elif t > 0:
            element = Task.get(c, t)
        else:
            raise Exception("You must specify either a project id or a task id.")
        note = Note.get(c, n)
        note.assign(c, element)
    elif t > 0:
        task = Task.get(c, t)
        # We are assigning a task to a project.
        if p > 0:
            project = Project.get(c, p)
            task.assign(c, project)
        else:
            raise Exception("You must specify a project id to assign the task to.")
    else:
        raise Exception("You didn't specify anything to assign!")
Exemple #2
0
def project_command(
    name=None,  # the name of the project (required)
    description="",  # an optional description for this project
    p=-1,  # portfolio id for this project (required unless parent project specified)
    parent=-1,  # parent project id, if this is a subproject
):
    """
    Create a new project.
    """
    c = conn()

    if parent > 0:
        parent_project_id = parent
        parent_project = Project.get(c, parent)
        portfolio_id = parent_project.portfolio_id
    else:
        parent_project_id = None
        if p > 0:
            portfolio_id = p
        else:
            raise Exception(
                "You must provide a portfolo id using the -p parameter if this project doesn't have a parent project."
            )

    project = Project.create(
        c,
        created_at=datetime.now(),
        description=description,
        parent_project_id=parent_project_id,
        name=name,
        portfolio_id=portfolio_id,
    )
    print project.id,
Exemple #3
0
def note_command(
    note="",  # the contents of the note
    p=-1,  # the project id to link the new note to (optional)
    t=-1,  # the task id to link the new note to (optional)
):
    """
    Create a new note. If note contents are not specified, will read from
    STDIN.
    """
    c = conn()

    if len(note) == 0:
        note = sys.stdin.read().strip()
    if len(note) == 0:
        raise Exception("You didn't pass any content for your note!")

    n = Note.create(c, note=note, created_at=datetime.now())

    print "Created note", n.id

    if p > 0:
        project = Project.get(c, p)
        n.assign(c, project)
        print "Assigned to project %s" % p

    elif t > 0:
        task = Task.get(c, t)
        n.assign(c, task)
        print "Assigned to task %s" % t
Exemple #4
0
def test_create_project():
    conn = get_conn()
    project = Project.create(conn, name="My New Project", created_at = datetime.datetime.now())
    assert project.id == 1
    assert project.elapsed_seconds() < 0.01

    lookup_project = Project.get(conn, 1)
    assert lookup_project.name == "My New Project"
    assert project.elapsed_seconds() < 0.01
Exemple #5
0
def complete_command(p=-1, t=-1):  # id of the project to mark complete  # id of the task to mark complete
    """
    Mark the project or task as completed.
    """
    c = conn()
    if p > 0:
        project = Project.get(c, p)
        project.complete(c)
        Project.archive(c, project.id)
        print "Project %s marked as complete!" % p
    elif t > 0:
        task = Task.get(c, t)
        task.complete(c)
        print "Task %s marked as complete!" % t
    else:
        raise Exception()
Exemple #6
0
def show_command(
    t=-1,  # id of task to show detail on
    n=-1,  # id of note to show detail on
    p=-1,  # id of project to show detail on
    portfolio=-1,  # id of portfolio to show detail on
):
    """
    Print detailed information for a project, task, note or portfolio.
    """
    c = conn()
    if t > 0:
        task = Task.get(c, t)
        print task.show()
    elif n > 0:
        note = Note.get(c, n)
        print note.show()
    elif p > 0:
        project = Project.get(c, p)
        print project.show()
    elif portfolio > 0:
        portfolio = Portfolio.get(c, portfolio)
        print portfolio.show()
    else:
        raise Exception("Must specify one of t (task), n (note), p (project) or portfolio.")