Beispiel #1
0
def get_user_goal(id):
    user_data = models.UserData.current()
    if not user_data:
        return api_invalid_param_response("User not logged in")

    goal = Goal.get_by_id(id, parent=user_data)

    if not goal:
        return api_invalid_param_response("Could not find goal with ID " + str(id))

    return goal.get_visible_data(None)
Beispiel #2
0
def put_user_goal(id):
    user_data = models.UserData.current()
    if not user_data:
        return api_invalid_param_response("User not logged in")

    goal = Goal.get_by_id(id, parent=user_data)

    if not goal:
        return api_invalid_param_response("Could not find goal with ID " + str(id))

    goal_json = request.json

    # currently all you can modify is the title
    if goal_json['title'] != goal.title:
        goal.title = goal_json['title']
        goal.put()

    # or abandon something
    if goal_json.get('abandoned') and not goal.abandoned:
        goal.abandon()
        goal.put()

    return goal.get_visible_data(None)