Commit f20469a2 authored by Geoff Pado's avatar Geoff Pado
Browse files

Add submitted parties to DB.

parent 629a62f1
Pipeline #7 skipped
......@@ -55,8 +55,10 @@
(-> (auth-view {:key username})
first admin/from-db)))
(defn add-party [party]
(clutch/put-document db (party/approved (party/from-json party) false)))
(defn submit-party [submitted-party]
(let [party (party/approved submitted-party false)
db (clutch/get-database (env :wwdc-parties-db))]
(clutch/put-document db party)))
(defn approve-party [slug]
(let [party (:value (first (submitted-view {:key slug})))]
......
......@@ -4,23 +4,6 @@
[clj-time.format :as tf]
[clojure.string :as s]))
(defn form->party [form]
{:description (:description form)
:end_time (form->date (last (form->days (:day form))) (:choice_time_end form))
:event_url ""
:excerpt ""
:location ""
:meta (form->meta (:meta form))
:name (:choice_party_name form)
:slug (name->slug (:choice_party_name form))
:sponsor_name ""
:sponsor_url ""
:start_time (form->date (first (form->days (:day form))) (:choice_time_start form))
:street_address ""
:twitter_handle ""
:type "party"
:types (form->types (:party-type form))})
(defn form->days [days]
(if (nil? days)
nil
......@@ -51,3 +34,20 @@
s/lower-case
(#(s/replace % #"[^A-Za-z\s]" ""))
(#(s/replace % #"\s" "-"))))
(defn form->party [form]
{:description (:description form)
:end_time (form->date (last (form->days (:day form))) (:choice_time_end form))
:event_url ""
:excerpt ""
:location ""
:meta (form->meta (:meta form))
:name (:choice_party_name form)
:slug (name->slug (:choice_party_name form))
:sponsor_name ""
:sponsor_url ""
:start_time (form->date (first (form->days (:day form))) (:choice_time_start form))
:street_address ""
:twitter_handle ""
:type "party"
:types (form->types (:party-type form))})
......@@ -5,6 +5,7 @@
[hiccup.core :refer [h]]
[ring.util.http-response :refer [moved-permanently found not-found]]
[wwdcparties.api.db :as db]
[wwdcparties.api.submit :as sub]
[wwdcparties.render.index :as index]
[wwdcparties.render.info :as info]
[wwdcparties.render.submit :as submit]))
......@@ -21,8 +22,9 @@
(defn submit-page []
(html5 (submit/page nil)))
(defn submitted-page [request]
(html5 (h request)))
(defn submitted-page [request]
(db/submit-party (sub/form->party request))
(html5 "yay"))
(defroutes home-routes
(GET "/" [] (moved-permanently "/parties/"))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment