          (case operation
            :create (POST uri options)
            :read   (GET  uri options)
-           :update (check-id PUT)
+           :update (PUT uri options)
            :delete (check-id DELETE)
            :create-no-read (POST uri options)
            (POST (str uri "/" (name operation)) options)))))


(defroute events-route
  "/events" []
  (if (:token @session)
    (reset! current-page [#'events-page])
    (location.replace (events-explore-route))))

(defroute event-add-route
  "/events/add" []

                                          (d/entity @attendees-db attendee-id)
                                          nil))]
    (fn []
      (if (:token @session)
        (let [attending-events
              (doall (map (fn [[event-id attendee-id]]
                            (merge
                              (into {} (d/entity @events-db event-id))
                              {:AttendeeId attendee-id}))
                          (d/q '[:find ?event-id ?attendee-id
                                 :in $ ?user-id
                                 :where
                                 [?attendee-id :UserId  ?user-id]
                                 [?attendee-id :EventId ?event-id]]
                               @attendees-db
                               (get-in @session [:user :UserId]))))]
          [:div.sixteen.wide.column
           [:div.ui.top.attached.tabular.menu
            [:a.active.item {:href (events-route)}
             "Events"]
            [:a.item {:href (events-explore-route)}
             "Explore"]
            [:a.item {:href (events-owned-route)}
             "Owned"]
            [:a.item {:href (event-add-route)}
             "Add"]]
           [:div.ui.bottom.attached.segment
            [:div
             [:div.ui.vertical.segment
              [:h1.ui.header "Events You're Attending"]]
             [:div.ui.vertical.segment
              (if (seq attending-events)
                [:div.ui.divided.items
                 (for [event attending-events]
                   ^{:key (:EventId event)}
                   [:div.item
                    [:div.content
                     [:a.header {:href (event-route event)}
                      (:Name event)]
                     [:div.meta
                      [:strong "Date:"]
                      (let [start (from-string (:StartDate event))
                            end   (from-string (:EndDate   event))]
                        (str (unparse datetime-formatter start)
                             (when (after? end start)
                               (str " to " (unparse datetime-formatter end)))))]
                     [:div.meta
                      [:strong "Venue:"]
                      (:Venue event)]
                     [:div.description
                      (:Description event)]
                     [:div.extra
                      [:a.ui.right.floated.small.button {:href (event-schedule-route event)}
                       "Your activities"
                       [:i.right.chevron.icon]]
                      [:a.ui.right.floated.small.button
                       {:on-click #(leave-event (:AttendeeId event))}
                       [:i.red.remove.icon]
                       "Leave event"]]]])]
                [:p "You aren't attending any events."])]]
            [:div.ui.dimmer {:class (when (empty? @events) "active")}
             [:div.ui.loader]]]])
        (do
          (js/location.replace (events-explore-route))
          [:div])))))

(defn events-explore-page []
  (let [unattending-events
