Permalink
Browse files

Support updating todo notes.

  • Loading branch information...
1 parent 2b7d7fb commit 2b19667f3e5ebf2003e85a642e183343ee33a1e0 @neotyk committed Nov 16, 2011
Showing with 18 additions and 0 deletions.
  1. +7 −0 src/clj_webapp/core.clj
  2. +11 −0 src/clj_webapp/web.clj
View
@@ -47,3 +47,10 @@
(when (contains? @store id)
(dosync
(alter store dissoc id))))
+
+(defn update-todo!
+ "Updates todo note"
+ [store id todo]
+ (when (contains? @store id)
+ (dosync
+ (alter store assoc id todo))))
View
@@ -42,6 +42,17 @@
(response/response "")
(response/status (response/response (str "Failed to remove " id))
404)))
+ (web/PUT "/todos/:id" {{id :id} :route-params
+ {body "todo[body]"
+ done? "todo[isDone]"
+ :as params} :form-params
+ :as req}
+ (log/info req)
+ (if (core/update-todo! store id {:body body
+ :isDone (= done? "true")})
+ (response/response "")
+ (response/status (response/response (str "Failed to update " id))
+ 404)))
(route/not-found "not here")))
(defn wrap-logging

0 comments on commit 2b19667

Please sign in to comment.