diff options
Diffstat (limited to 'users')
-rw-r--r-- | users/grfn/bbbg/src/bbbg/handlers/events.clj | 47 | ||||
-rw-r--r-- | users/grfn/bbbg/src/bbbg/meetup/import.clj | 3 | ||||
-rw-r--r-- | users/grfn/bbbg/src/bbbg/web.clj | 2 |
3 files changed, 38 insertions, 14 deletions
diff --git a/users/grfn/bbbg/src/bbbg/handlers/events.clj b/users/grfn/bbbg/src/bbbg/handlers/events.clj index dd50a517cceb..6308a975641a 100644 --- a/users/grfn/bbbg/src/bbbg/handlers/events.clj +++ b/users/grfn/bbbg/src/bbbg/handlers/events.clj @@ -4,13 +4,14 @@ [bbbg.db.event :as db.event] [bbbg.event :as event] [bbbg.handlers.core :refer [authenticated? page-response]] + [bbbg.meetup.import :refer [import-data!]] [bbbg.util.display :refer [format-date]] + [bbbg.util.time :as t] [bbbg.views.flash :as flash] [compojure.coercions :refer [as-uuid]] [compojure.core :refer [context GET POST]] [java-time :refer [local-date]] - [ring.util.response :refer [not-found redirect]] - [bbbg.util.time :as t])) + [ring.util.response :refer [not-found redirect]])) (defn events-index [{:keys [events authenticated?]}] [:div @@ -33,8 +34,19 @@ (if (= (t/->LocalDate (::event/date event)) (local-date)) " Signed In" - (str " Attendee" (when-not (= 1 (:num-attendees event)) "s")))] - ]]) + (str " Attendee" (when-not (= 1 (:num-attendees event)) "s")))]] + [:div + [:form {:method :post + :action (str "/events/" (::event/id event) "/attendees") + :enctype "multipart/form-data"} + [:div.form-group + [:label "Import Attendee List" + [:br] + [:input {:type :file + :name :attendees}]]] + [:div.form-group + [:input {:type :submit + :value "Import"}]]]]]) (defn event-form ([] (event-form {})) @@ -58,15 +70,24 @@ (events-index {:events events :authenticated? (authenticated? request)})))) - (GET "/:id" [id :<< as-uuid] - (if-let [event (db/fetch db - (-> {:select [:event.*] - :from [:event] - :where [:= :event.id id]} - (db.event/with-stats)))] - (page-response - (event-page {:event event})) - (not-found "Event Not Found"))) + (context "/:id" [id :<< as-uuid] + (GET "/" [] + (if-let [event (db/fetch db + (-> {:select [:event.*] + :from [:event] + :where [:= :event.id id]} + (db.event/with-stats)))] + (page-response + (event-page {:event event})) + (not-found "Event Not Found"))) + + (POST "/attendees" [attendees] + (let [num-imported (import-data! db id (:tempfile attendees))] + (-> (redirect (str "/events/" id)) + (flash/add-flash + #:flash{:type :success + :message (format "Successfully imported %d attendees" + num-imported)}))))) (GET "/new" [date] (page-response diff --git a/users/grfn/bbbg/src/bbbg/meetup/import.clj b/users/grfn/bbbg/src/bbbg/meetup/import.clj index 29aaf53e50b8..5b5cabaa4e71 100644 --- a/users/grfn/bbbg/src/bbbg/meetup/import.clj +++ b/users/grfn/bbbg/src/bbbg/meetup/import.clj @@ -99,7 +99,8 @@ (map (partial row->event-attendee {::event/id event-id :meetup-id->attendee-id meetup-id->attendee-id}) - rows)))) + rows)) + (count rows))) ;;; Spreadsheet columns: ;;; diff --git a/users/grfn/bbbg/src/bbbg/web.clj b/users/grfn/bbbg/src/bbbg/web.clj index e712c89378f7..c9d0fd0d4406 100644 --- a/users/grfn/bbbg/src/bbbg/web.clj +++ b/users/grfn/bbbg/src/bbbg/web.clj @@ -18,6 +18,7 @@ [org.httpkit.server :as http-kit] [ring.middleware.flash :refer [wrap-flash]] [ring.middleware.keyword-params :refer [wrap-keyword-params]] + [ring.middleware.multipart-params :refer [wrap-multipart-params]] [ring.middleware.params :refer [wrap-params]] [ring.middleware.session :refer [wrap-session]] [ring.middleware.session.cookie :refer [cookie-store]] @@ -88,6 +89,7 @@ wrap-dynamic-auth (wrap-discord-auth env) wrap-keyword-params + wrap-multipart-params wrap-params wrap-page-flash wrap-flash |