Skip to content

Commit

Permalink
Merge pull request 4clojure#169 from arajek/develop
Browse files Browse the repository at this point in the history
Fixing a bug when requesting a non-existing user's profile page
  • Loading branch information
dbyrne committed Nov 7, 2011
2 parents 20d8b17 + bc6ddd0 commit e251d61
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/foreclojure/users.clj
Expand Up @@ -3,7 +3,7 @@
[clojure.string :as string]
[sandbar.stateful-session :as session]
[cheshire.core :as json])
(:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user]]
(:use [foreclojure.utils :only [from-mongo row-class rank-class get-user if-user with-user flash-error ]]
[foreclojure.template :only [def-page content-page]]
[foreclojure.ring-utils :only [*http-scheme* static-url]]
[foreclojure.config :only [config repo-url]]
Expand Down Expand Up @@ -164,7 +164,7 @@
:heading-note [:span#all-users-link]
:sub-heading (list (format-user-ranking user-ranking)
[:span.contributor "*"] " "
(link-to repo-url "4clojure contributor"))
(link-to repo-url "4clojure contributor") [:br])
:main (generate-user-list top-100 "user-table")})}))

;; TODO: this is snagged from problems.clj but can't be imported due to cyclic dependency, must refactor this out.
Expand Down Expand Up @@ -294,7 +294,10 @@
(defroutes users-routes
(GET "/users" [] (top-users-page))
(GET "/users/all" [] (all-users-page))
(GET "/user/:username" [username] (user-profile username))
(GET "/user/:username" [username]
(if (nil? (get-user username))
{:status 404 :headers {"Content-Type" "text/plain"} :body "Error: This user does not exist, nice try though."}
(user-profile username)))
(POST "/user/follow/:username" [username] (static-follow-user username true))
(POST "/user/unfollow/:username" [username] (static-follow-user username false))
(POST "/rest/user/follow/:username" [username] (rest-follow-user username true))
Expand Down

0 comments on commit e251d61

Please sign in to comment.