Exemplo n.º 1
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.")
Exemplo n.º 2
0
def recipe_command():
    """
    Create a new recipe with steps.
    """
    c = ado.commands.conn()
    created_at = datetime.now()

    print "Creating a new recipe."

    Portfolio.printall(c)
    portfolio_id = int(ado.commands.clean_input("Enter portfolio id: "))

    # Verify portfolio choice.
    portfolio = Portfolio.get(c, portfolio_id)
    print "You chose portfolio %s - %s" % (portfolio.id, portfolio.name)

    name = ado.commands.clean_input("Enter short name for recipe: ")
    print "Name set to '%s'" % name
    description = ado.commands.clean_input("Description of recipe: ")
    print "Description set to '%s'" % description
    print "Describe each step in the recipe you wish to define."
    step = 0
    steps = []
    while True:
        step += 1
        step_text = ado.commands.clean_input("Step %s: " % step)
        if step_text:
            steps.append(step_text)
            print "Processing step text '%s'" % step_text
        else:
            print "done! %s steps recorded." % len(steps)
            break

    print "How often should you do this recipe (e.g. 1w (1 week), 1d (1 day), 12h (12 hours), 30m (30 minutes)"
    raw_frequency = ado.commands.clean_input("> ")
    if raw_frequency:
        frequency = raw_frequency
        print "This recipe should be done every %s days" % frequency
    else:
        frequency = "None"
        print "No specified frequency."

    context = ado.commands.clean_input("Context (where you can do this): ")
    recipe = Recipe.create(
            c,
            context=context,
            created_at=created_at,
            description=description,
            frequency=frequency,
            name=name,
            portfolio_id=portfolio_id
            )

    print "Created recipe", recipe.id
    for step_text in steps:
        step = Step.create(
                c,
                created_at=created_at,
                recipe_id = recipe.id,
                description = step_text
                )
        print "Created step id %s" % step.id
Exemplo n.º 3
0
 def portfolio(self, conn=None):
     from ado.portfolio import Portfolio
     if not conn:
         conn = self.conn
     return Portfolio.get(conn, self.portfolio_id)