def get(self, d): # Run after admin user logs in u = User.query().get() if u: today = datetime.today() g = Goal.CreateMonthly(u, date=today) g.Update(text=["Get it done"]) g2 = Goal.Create(u, str(today.year)) g2.Update(text=["Make progress"]) ndb.put_multi([g, g2]) h = Habit.Create(u) h.Update(name="Run") h.put() p = Project.Create(u) p.Update(title="Blog post", subhead="How Flow works") p.put() Task.Create(u, "Get this done").put() t = Task.Create(u, "Think hard", due=datetime.today()) t2 = Task.Create(u, "Think even harder", due=datetime.today()) message = "OK" else: message = "No user" self.json_out({'message': message})
def update(self, d): ''' Create or update ''' id = self.request.get('id') params = tools.gets(self, strings=['text1', 'text2', 'text3', 'text4'], integers=['assessment'] ) goal = self.user.get(Goal, id=id) if not goal: goal = Goal.Create(self.user, id=id) if goal: text = [] for i in range(1, 5): key = 'text%d' % i if key in params: text_i = params.get(key) if text_i: text.append(text_i) if text: params['text'] = text goal.Update(**params) goal.put() self.message = "Goal saved" self.success = True else: self.message = "Couldn't create goal" self.set_response({ 'goal': goal.json() if goal else None })
def setUp(self): self.set_application(tst_app) self.setup_testbed() self.init_standard_stubs() self.init_app_basics() u = self.users[0] self.goal_annual = Goal.Create(u, '2017') self.goal_annual.Update(text=["Annual goal 1", "Annual goal 2"]) self.goal_monthly = Goal.CreateMonthly(u) self.goal_monthly.put() self.goal_annual.put()
def test_goal_report(self): g = Goal.Create(self.u, "2017") g.Update(text=["Goal 1", "Goal 2"], assessments=[3, 4]) g.put() self._test_report( {'type': REPORT.GOAL_REPORT}, [[ 'Goal Period', 'Date Created', 'Text 1', 'Text 2', 'Text 3', 'Text 4', 'Goal Assessments', 'Overall Assessment' ], [ "2017", tools.sdatetime(g.dt_created, fmt="%Y-%m-%d %H:%M:%S %Z"), "Goal 1", "Goal 2", "", "", "\"3,4\"", "3.5" ]])