Skip to content

Commit

Permalink
Expose the entire current day with links, not just the activities
Browse files Browse the repository at this point in the history
  • Loading branch information
alf committed Oct 12, 2011
1 parent 7b3f357 commit 0929f0f
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
from .auth import requires_auth
from . import ct
from . import url
from .dates import get_current_day


@requires_auth
def index():
return jsonify({
"description": "REST API for CT version 1.0",
"activities": ct.get_current_day(),
"current-day": current_day(),
"available-projects": ct.get_projects(),
"links": [{
"rel": "available-projects",
Expand All @@ -39,12 +40,21 @@ def index():
})


def current_day():
y, m, d = get_current_day()
return get_day_data(y, m, d)


@requires_auth
def day(year, month, day):
if request.method == "PUT":
ct.set_day(year, month, day, request.json['activities'])

return jsonify({
return jsonify(get_day_data(year, month, day))


def get_day_data(year, month, day):
return {
"activities": ct.get_day(year, month, day),
"links": [{
"rel": "current",
Expand All @@ -65,7 +75,7 @@ def day(year, month, day):
"rel": "self",
"href": url.get_day(year, month, day)
}]
})
}


@requires_auth
Expand Down

0 comments on commit 0929f0f

Please sign in to comment.