Skip to content

Instantly share code, notes, and snippets.

@flyingmachine
Created March 5, 2016 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyingmachine/807090935637d1644008 to your computer and use it in GitHub Desktop.
Save flyingmachine/807090935637d1644008 to your computer and use it in GitHub Desktop.
(ns cljobs.resources.manage.os-projects
(:require [cljobs.resources.common :as c]
[cljobs.db.validations :as v]
[cljobs.db.queries :as q]
[datomic.api :as d]))
(def new-data (c/query-result q/user-os-projects))
(defn process-params
[ctx]
(-> (c/assoc-user ctx :os-project/user)
(update-in [:request :params]
c/ensure-http
[:os-project/repo-url :os-project/home-page-url])))
(def result-data (c/result-data (c/query-result-owned q/user-os-projects)
(c/query-result q/published-os-projects)))
(defn resource-decisions
[_]
{:create {:post! (comp c/add-result c/create process-params)
:handle-created result-data}
:update {:authorized? (c/user-owns? :os-project/user)
:put! (comp c/add-result c/update)
:handle-ok result-data}
:delete {:authorized? (c/user-owns? :os-project/user)
:delete! (comp c/add-result c/delete)
:delete-enacted? true
:respond-with-entity? true
:handle-ok result-data}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment