From be8376c8fabd6201ff786f1db646bde1844f0db9 Mon Sep 17 00:00:00 2001 From: Sanj Date: Sun, 19 Feb 2012 18:27:08 +0530 Subject: [PATCH] get / edit stop --- chaloBEST/mumbai/apiurls.py | 1 + chaloBEST/mumbai/apiviews.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/chaloBEST/mumbai/apiurls.py b/chaloBEST/mumbai/apiurls.py index 56704dc..7360b4e 100644 --- a/chaloBEST/mumbai/apiurls.py +++ b/chaloBEST/mumbai/apiurls.py @@ -3,4 +3,5 @@ import apiviews urlpatterns = patterns('', (r'^route/(?P.*)$', apiviews.route), #FIXME: better regexp for route alias? + (r'^stop/(?P[0-9]*)$', apiviews.stop), ) diff --git a/chaloBEST/mumbai/apiviews.py b/chaloBEST/mumbai/apiviews.py index 6c8f6ce..d2548ce 100644 --- a/chaloBEST/mumbai/apiviews.py +++ b/chaloBEST/mumbai/apiviews.py @@ -14,9 +14,14 @@ def route(request, alias): } }) -@login_required(request, id): - if not id: - stop = Stop() #FIXME: should this return an error instead? + +def stop:(request, id): + if request.POST: + if not id: + stop = Stop() #FIXME: should this return an error instead? + else: + stop = get_object_or_404_json(Stop, id=id) + return stop.from_geojson(request.POST) else: stop = get_object_or_404_json(Stop, id=id) - return stop.from_geojson(request.POST) + return stop.get_geojson()