parent
bf0c9814b4
commit
dda41eb8c5
@ -0,0 +1,16 @@
|
||||
(ns wanijo.user.routes
|
||||
(:require [compojure.core :refer [defroutes GET POST]]
|
||||
[ring.util.response :as resp]
|
||||
[wanijo.framework.routing :refer [register]]
|
||||
[wanijo.user.view :as view-user]
|
||||
[wanijo.user.domain :as domain]))
|
||||
|
||||
(register :user-profile "/user/profile")
|
||||
(register :user-edit "/user/edit")
|
||||
|
||||
(defn profile! [req]
|
||||
(view-user/profile! req
|
||||
(domain/find! (get-in req [:session :ident]))))
|
||||
|
||||
(defroutes routes
|
||||
(GET "/user/profile" [] profile!))
|
@ -0,0 +1,29 @@
|
||||
(ns wanijo.user.view
|
||||
(:require [hiccup.form :as hform]
|
||||
[ring.util.anti-forgery :refer [anti-forgery-field]]
|
||||
[wanijo.framework.view :as view]
|
||||
[wanijo.framework.form :as form]
|
||||
[wanijo.framework.routing :refer [path]]
|
||||
[wanijo.user.domain :as domain]))
|
||||
|
||||
(def edit-form
|
||||
{:fields {:name {:label "Nimi"
|
||||
:required false
|
||||
:spec ::domain/name}
|
||||
:ident {:label "Ident"
|
||||
:required false
|
||||
:spec ::domain/ident}
|
||||
:password {:label "Toki Pimeja"
|
||||
:required true
|
||||
:spec ::domain/password}}})
|
||||
|
||||
(defn profile! [req user]
|
||||
(view/layout!
|
||||
:session (:session req)
|
||||
:content
|
||||
[[:h1 "O, " (get-in req [:session :ident])]
|
||||
[:div (str user)]
|
||||
(hform/form-to [:post (path :user-edit)]
|
||||
(anti-forgery-field)
|
||||
(form/readonly edit-form :ident (:ident user))
|
||||
(form/field edit-form :name req (:name user)))]))
|
Loading…
Reference in new issue