def goal(id = None, action = None): profile = getCurrentProfile() if id is not None: # Make the action name lowercase action = SafeLower(action) thisGoal = Goal.get_by_id(int(id), profile) if action is None: links = TaskLink.all().ancestor(thisGoal) statsDict = LoadObjectStats(thisGoal, datetime.now()) statsDict["goal"] = thisGoal statsDict["linkedTasks"] = [link.Task for link in links] statsDict["recentEntries"] = GoalEntry.all().ancestor(profile).fetch(5) return render_template('views/goal_view.html', **statsDict) elif action == "delete": return render_template('views/delete.html', goal = thisGoal, typeName = "goal") elif action == "edit": return render_template("views/goal_edit.html", goal = thisGoal, typeName = "goal") elif action == "tasks": return linkTasksToGoal(request, thisGoal, profile) elif action == "entires": return elif action is not None: action = action.lower() if action == "create": return showCreateGoal(request, profile) else: if request.method == "GET": goalList = Goal.all().ancestor(profile) if not goalList: goalList = [] return render_template("views/goal_list.html", goals = goalList) else: return showCreateGoal(request, profile)
def task(id = None, action = None): profile = getCurrentProfile() if id is not None: # Make the action name lowercase action = SafeLower(action) thisTask = Task.get_by_id(int(id), profile) if action is None: # TODO: Make this more efficient! statsDict = LoadObjectStats(thisTask, datetime.now()) statsDict["task"] = thisTask statsDict["recentEntries"] = GoalEntry.all().ancestor(profile).filter("CompletedTask =", thisTask).fetch(5) return render_template('views/task_view.html', **statsDict) elif action == "delete": return render_template('views/delete.html', task = thisTask, typeName = "task") elif action == "edit": return render_template("views/task_edit.html", task = thisTask, typeName = "task") elif action is not None: action = action.lower() if action == "create": return showCreateTask(request, profile) else: if request.method == "GET": taskList = Task.all().ancestor(profile) if not taskList: taskList = [] return render_template("views/task_list.html", tasks = taskList) else: return showCreateTask(request, profile)