Skip to content

Commit

Permalink
For non-admin, hide subtitle and session type fields
Browse files Browse the repository at this point in the history
Add bin/dev prod-repl
  • Loading branch information
plexus committed Sep 6, 2024
1 parent 9bd3ebf commit e8e99e5
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 28 deletions.
4 changes: 3 additions & 1 deletion bb.edn
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{:deps {com.lambdaisland/launchpad {:mvn/version "0.33.149-alpha"}}}
{:deps {com.lambdaisland/launchpad {:mvn/version "0.33.149-alpha"}
com.lambdaisland/cli {:mvn/version "0.18.74"}
com.lambdaisland/shellutils {:mvn/version "0.2.17"}}}
29 changes: 29 additions & 0 deletions bin/dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bb

(require
'[clojure.java.io :as io]
'[clojure.java.shell :as shell]
'[clojure.pprint :as pprint]
'[clojure.string :as str]
'[lambdaisland.cli :as cli]
'[lambdaisland.shellutils :as su]
)

(def init {})

(defn prod-repl
"REPL into production"
[opts]
(su/spawn "ssh" "root@compass.heartofclojure.eu" "nc" "localhost" "5555"))

(def commands
["prod-repl" #'prod-repl])

(def flags
["-v, --verbose" "Increase verbosity"
"-n, --dry-run" "Show shell commands, but don't execute them"])

(cli/dispatch
{:init init
:commands commands
:flags flags})
4 changes: 2 additions & 2 deletions deps.edn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{:paths ["src" "resources"]

:deps
{org.clojure/clojure {:mvn/version "1.11.4"}
{org.clojure/clojure {:mvn/version "1.12.0"}
ring/ring-jetty-adapter {:mvn/version "2.0.0-alpha1"}
fi.metosin/reitit {:mvn/version "0.7.0-alpha6"}
integrant/integrant {:mvn/version "0.11.0"}
Expand All @@ -12,7 +12,7 @@

com.lambdaisland/cli {:mvn/version "0.18.74"}

com.lambdaisland/hiccup {:mvn/version "0.9.48"}
com.lambdaisland/hiccup {:mvn/version "0.10.51"}
com.lambdaisland/ornament {:git/sha "0af129132bfbfeba940705031f83b60250e71dcf" ;; ornament-next with defprop/defrules/import-tokens
:git/url "https://github.com/lambdaisland/ornament.git"}
#_{:local/root "/home/arne/github/lambdaisland/ornament"}
Expand Down
5 changes: 2 additions & 3 deletions repl-sessions/revoke.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns repl-sessions.revoke
"Prepare some testing data for revoke contacts feature
How to use:
1. You first login by Discord
2. Run this revoke namespace to create another 10 temp users
Expand Down Expand Up @@ -45,7 +45,6 @@
(range 1 11)))))

(def tx (temp-user-tx
(test-user-eid "Laurence")))
(test-user-eid "Arne")))

(db/transact tx)

39 changes: 39 additions & 0 deletions resources/public/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ body {
stroke: var(--text-1);
}

.graphics-person_remove {
--_remove-color: #ff4d4d;
}

.graphics-person_remove path {
fill: var(--_remove-color);
}

.graphics-cross {
stroke-width: 13%;
stroke-linecap: round;
Expand Down Expand Up @@ -406,6 +414,37 @@ body {
--profiles-arc-thickness: 7%;
}

.profiles-profile_detail .contact-list {
display: flex;
flex-wrap: wrap;
gap: var(--size-4);
}

.profiles-profile_detail .remove-btn, .profiles-profile_detail cursor-pointer {
border-style: none;
background-color: var(--surface-3);
}

.profiles-profile_detail .remove-btn:hover {
background-color: var(--surface-4);
}

.profiles-profile_detail .contact {
display: flex;
align-items: center;
}

.profiles-profile_detail .contact .profiles-image_frame {
width: 50px;
--profiles-arc-thickness: 7%;
margin-right: var(--size-2);
}

.profiles-profile_form .profiles-image_frame {
width: 100px;
--profiles-arc-thickness: 7%;
}

.profiles-profile_form label, .profiles-profile_form input {
display: block;
}
Expand Down
7 changes: 7 additions & 0 deletions src/co/gaiwan/compass/db/queries.clj
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,10 @@
:where
[?l :profile-link/user ?u]]
(db/db) user-eid)))

(defn all-session-types []
(db/q
'[:find [(pull ?t [*]) ...]
:where
[?t :session.type/name]]
(db/db)))
30 changes: 19 additions & 11 deletions src/co/gaiwan/compass/html/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@
[:span.datetime
(str (time/truncate-to (time/local-time time) :minutes)) " · "]
title]]
[:h3.subtitle subtitle]
[:h3.subtitle (if-let [organizer-name (and (str/blank? subtitle) (-> session :session/organized :public-profile/name))]
(str "organized by " organizer-name)
subtitle)]
#_[:div.expansion
[session-card-actions session user]]
[:div.loc (fmt-dur duration) " @ " (:location/name location)]
Expand Down Expand Up @@ -311,8 +313,6 @@

;; Create / edit

(def xxx #time/zdt "2024-08-16T10:30+02:00[Europe/Brussels]")

(o/defstyled session-form :div
[#{:label :input} :block]
[:label
Expand All @@ -327,7 +327,8 @@
:flex
:gap-3]]
[:div.date-time :flex :gap-2]
([user session]
([user session session-types]
(def session session)
[:<>
(if session
[:h2 "Edit Activity"]
Expand All @@ -343,7 +344,8 @@
:required true :min-length 2}
session
(assoc :value (:session/title session)))]
[:label {:for "subtitle"} "Subtitle (optional)"]
(when (user/admin? user)
[:label {:for "subtitle"} "Subtitle (optional)"])
[:input (cond-> {:id "subtitle" :name "subtitle" :type "text"
:min-length 10}
session
Expand All @@ -355,9 +357,9 @@
(str (time/local-date (:session/time session)))
(str (java.time.LocalDate/now)))}]
[:input (cond->
{:id "start-time" :name "start-time" :type "time"
:min "06:00" :max "23:00" :required true
:step 60}
{:id "start-time" :name "start-time" :type "time"
:min "06:00" :max "23:00" :required true
:step 60}
session
(assoc :value
(str (time/local-time (:session/time session)))))]]
Expand All @@ -369,9 +371,15 @@
(session/duration (:session/duration session))
45)}]

[:label {:for "type"} "Type"]
[:select {:id "type" :name "type"}
[:option {:value "activity"} "Activity"]]
(when (user/admin? user)
[:<>
[:label {:for "type"} "Type"]
[:select {:id "type" :name "type"}
(for [{n :session.type/name id :db/id} session-types]
[:option (cond-> {:value id}
(= id (:db/id (:session/type session)))
(assoc :selected "selected"))
n])]])

[:label {:for "location"} "Location"]
[:select (cond-> {:id "location" :name "location"}
Expand Down
9 changes: 9 additions & 0 deletions src/co/gaiwan/compass/repl.clj
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
(ns co.gaiwan.compass.repl
"REPL utility functions for quick maintenance tasks
See also `bin/dev prod-repl`
"
(:require
[co.gaiwan.compass.db :as db :refer :all]
[co.gaiwan.compass.model.user :as u]))

(comment
(require 'co.gaiwan.compass.repl)
(in-ns 'co.gaiwan.compass.repl)
)

(defn user [name-or-email]
(db/entity
(db/q '[:find ?e .
Expand Down
20 changes: 9 additions & 11 deletions src/co/gaiwan/compass/routes/sessions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
:headers {"HX-Trigger" "login-required"}} #_(util/redirect)
{:html/head [:title "Create new session"]
:html/body [session-html/session-form (:identity req)
nil]}))
nil
(q/all-session-types)]}))

(defn GET-session-edit [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
{:html/body [session-html/session-form
(:identity req)
(db/pull '[* {:session/type [*]
:session/location [*]
:session.type [*]}] session-eid)]}))
(q/session session-eid)
(q/all-session-types)]}))

(defn GET-session [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
{:html/body [session-html/session-detail
Expand All @@ -40,9 +41,7 @@
(defn GET-session-card [req]
(let [session-eid (parse-long (get-in req [:path-params :id]))]
{:html/body [session-html/session-card
(db/pull '[* {:session/type [*]
:session/location [*]
:session.type [*]}] session-eid)
(q/session session-eid)
(:identity req)]}))

(defn params->session-data
Expand All @@ -51,8 +50,7 @@
type location
capacity organizer-id
ticket-required? published?
image]
:or {type "activity"}}]
image]}]
(let [local-date (time/local-date start-date)
local-time (time/local-time start-time)
local-date-time (time/local-date-time local-date local-time)
Expand All @@ -65,7 +63,7 @@
:session/time start
:session/duration duration
:session/description description
:session/type (keyword "session.type" type)
:session/type (or (some-> type parse-long) :session.type/activity)
:session/location (keyword "location.type" location)
:session/organized (parse-long organizer-id)
:session/capacity (parse-long capacity)}
Expand Down Expand Up @@ -98,7 +96,7 @@
[{:keys [params path-params identity]}]
(let [{:keys [id]} path-params
id (parse-long id)
session (db/pull '[*] id)
session (q/session id)
organizer-id (get-in session [:session/organized :db/id])]
(if session
(if (or (user/admin? identity)
Expand Down

0 comments on commit e8e99e5

Please sign in to comment.