refactorings and corrections

integration-tests
Josha von Gizycki 6 years ago
parent 05384a9f2d
commit 3982f5728f

@ -22,10 +22,13 @@
:plugins [[joshavg/lein-neo4j "0.3.0"]
[lein-less "1.7.5"]
[lein-ring "0.9.7"]
[lein-ancient "0.6.15"]]}
[lein-ancient "0.6.15"]
[jonase/eastwood "0.2.9"]
[lein-bikeshed "0.5.0"]]}
:uberjar {:aot :all}}
:ring {:handler wanijo.handler/app}
:less {:source-paths ["resources/app/stylesheets"]
:target-path "resources/public/css"}
:hiera {:cluster-depth 2})
:hiera {:cluster-depth 2}
:eastwood {:namespaces [:source-paths]})

@ -5,7 +5,8 @@
[wanijo.framework.routing :refer [register! path]]
[wanijo.attribute.domain :as domain]
[wanijo.schema.view :as view-schema]
[wanijo.schema.domain :as domain-schema]))
[wanijo.schema.domain :as domain-schema]
[wanijo.schema.routes :as routes-schema]))
(defn new! [req]
(let [schema-uuid (get-in req [:params :schema])]
@ -16,20 +17,14 @@
schema-uuid
(get-in req [:session :uuid]))
(resp/redirect (path :schema-show {:uuid schema-uuid})))
(view-schema/show-schema!
(domain-schema/find-by-uuid! schema-uuid)
(domain/find-by-schema! schema-uuid)
req))))
(routes-schema/view! schema-uuid req))))
(defn edit! [schema-uuid req]
(if (form/valid? view-schema/attr-form req)
(do
(domain/edit! (:params req))
(resp/redirect (path :schema-show {:uuid schema-uuid})))
(view-schema/show-schema!
(domain-schema/find-by-uuid! schema-uuid)
(domain/find-by-schema! schema-uuid)
req)))
(routes-schema/view! schema-uuid req)))
(defn delete! [uuid req]
(domain/delete-by-uuid! uuid)

@ -110,7 +110,11 @@
options
(if validate? req-value value))))
(defn render-multiselect [id {:keys [label spec options]} value req-value validate?]
(defn render-multiselect [id
{:keys [label spec options]}
value
req-value
validate?]
(list
(when (and validate? (not (spec/valid? spec req-value)))
(spec-to-errmsg label spec value))

@ -9,12 +9,12 @@
assoc id path)
path)
(defn check-params [id path params]
(defn check-params [path params]
(when (nil? path)
(throw
(ex-info
(str "Path " id " is not registered")
{:id id
"Path is not registered"
{:path path
:params params})))
(let [matcher (re-matcher #":[^/]+" path)
matches (take-while some? (repeatedly #(re-find matcher)))]
@ -28,10 +28,10 @@
"' does not exist in parameter map for path "
path)
{:path path
:params params
:id id}))))))
:params params}))))))
(defn parse-path [path params]
(check-params path params)
(reduce-kv
(fn [new-path param-id param-value]
(string/replace
@ -46,5 +46,4 @@
(path id {}))
([id params]
(let [path (id @all-routes)]
(check-params id path params)
(parse-path path params))))

@ -18,17 +18,6 @@
(resp/redirect (path :schema-overview)))
(view-schema/overview! req)))
(defn edit! [req]
(let [uuid (get-in req [:params :uuid])]
(if (form/valid? view-schema/form req)
(do
(domain/edit! (:params req))
(resp/redirect (path :schema-show (:params req))))
(view-schema/show-schema!
(domain/find-by-uuid! uuid)
(domain-attr/find-by-schema! uuid)
req))))
(defn delete-schema! [uuid session]
(if (domain/can-user-modify? uuid (:uuid session))
(do
@ -46,6 +35,14 @@
(domain-user/all!)))
req))
(defn edit! [req]
(let [uuid (get-in req [:params :uuid])]
(if (form/valid? view-schema/form req)
(do
(domain/edit! (:params req))
(resp/redirect (path :schema-show (:params req))))
(view! uuid req))))
(defn assign! [req]
(let [uuid (get-in req [:params :uuid])
users (get-in req [:params :assigned])]
@ -59,8 +56,6 @@
(resp/redirect (path :schema-show (:params req))))
(view! uuid req))))
;; random change
(defroutes routes
(GET (register! :schema-overview "/schema")
[]

@ -89,7 +89,8 @@
(anti-forgery-field)
(hform/hidden-field "schema" (:uuid schema))
(hform/submit-button {:class "delete-btn"} "Delete!")
[:label "Created at " [:em (prettify-dt (:created_at attr))]])])]
[:label "Created at "
[:em (prettify-dt (:created_at attr))]])])]
[:h3 "New attribute"]
(hform/form-to [:post (path :attribute-new)]
(form/render-widgets attr-form {} req)

@ -14,4 +14,4 @@
(testing "additional params are ignored"
(is (= (parse-path ":a" {:a 1 :b 2}) "1")))
(testing "all params are required"
(is (thrown? RuntimeException (parse-path ":a")))))
(is (thrown? RuntimeException (parse-path ":a" {})))))

Loading…
Cancel
Save