예제 #1
0
파일: __init__.py 프로젝트: ananelson/ado
def portfolio_command(name=None, description=None):
    """
    Creates a new portfolio.
    """
    c = conn()
    portfolio = Portfolio.create(c, name=name, description=description, created_at=datetime.now())
    print portfolio.id,
예제 #2
0
파일: __init__.py 프로젝트: ananelson/ado
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.")
예제 #3
0
파일: recipe.py 프로젝트: ananelson/ado
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
예제 #4
0
파일: __init__.py 프로젝트: ananelson/ado
def portfolios_command():
    c = conn()
    portfolios = Portfolio.all(c)

    for portfolio in portfolios:
        print portfolio.display_line()
예제 #5
0
 def portfolios(self):
     return Portfolio.all(conn())
예제 #6
0
inbox = {
        "name" : "inbox",
        "children" : [{
            "name" : "inbox",
            "children" : [dict_for_task(t) for t in Task.inbox(conn)]
            }]
        }

data = {
    "name" : 'ado',
    "children" : [inbox]
    }


for portfolio in Portfolio.all(conn):
    projects = []
    for project in portfolio.projects():
        tasks = [dict_for_task(t) for t in project.tasks()]

        project_info = dict_for_project(project)

        if len(tasks) > 0:
            project_info["children"] = tasks
        else:
            project_info["size"] = 1

        projects.append(project_info)

    portfolio_info = dict_for_portfolio(portfolio)
예제 #7
0
파일: project.py 프로젝트: ananelson/ado
 def portfolio(self, conn=None):
     from ado.portfolio import Portfolio
     if not conn:
         conn = self.conn
     return Portfolio.get(conn, self.portfolio_id)