add card layouts, convert postgresql querries to mysql
This commit is contained in:
parent
b5a66e6645
commit
eb5ed906fd
15 changed files with 171 additions and 222 deletions
10
README.md
10
README.md
|
@ -69,16 +69,6 @@ In this case you need to shutdown and restart using run or repl.
|
||||||
|
|
||||||
You can find these function available in the [userspace definitions][2]
|
You can find these function available in the [userspace definitions][2]
|
||||||
|
|
||||||
### Notes
|
|
||||||
#### Database
|
|
||||||
* ENUM TYPE
|
|
||||||
|
|
||||||
Because of the lack of typing in clojure and the forced typing of the jdbc driver
|
|
||||||
we need to manually manage conversion of enum types to clojure keywords.
|
|
||||||
|
|
||||||
When adding an enum to the database, make sure to add it to the '+schema-enums+' set see [db][3]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Production
|
## Production
|
||||||
|
|
||||||
|
|
4
cat.iml
4
cat.iml
|
@ -71,7 +71,7 @@
|
||||||
<orderEntry type="library" name="Leiningen: com.google.javascript/closure-compiler-externs:v20180805" level="project" />
|
<orderEntry type="library" name="Leiningen: com.google.javascript/closure-compiler-externs:v20180805" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.google.javascript/closure-compiler-unshaded:v20180805" level="project" />
|
<orderEntry type="library" name="Leiningen: com.google.javascript/closure-compiler-unshaded:v20180805" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.google.jsinterop/jsinterop-annotations:1.0.0" level="project" />
|
<orderEntry type="library" name="Leiningen: com.google.jsinterop/jsinterop-annotations:1.0.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.google.protobuf/protobuf-java:3.0.2" level="project" />
|
<orderEntry type="library" name="Leiningen: com.google.protobuf/protobuf-java:3.6.1" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.googlecode.json-simple/json-simple:1.1.1" level="project" />
|
<orderEntry type="library" name="Leiningen: com.googlecode.json-simple/json-simple:1.1.1" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.lambdaworks/scrypt:1.4.0" level="project" />
|
<orderEntry type="library" name="Leiningen: com.lambdaworks/scrypt:1.4.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: com.layerware/hugsql-adapter-clojure-java-jdbc:0.4.9" level="project" />
|
<orderEntry type="library" name="Leiningen: com.layerware/hugsql-adapter-clojure-java-jdbc:0.4.9" level="project" />
|
||||||
|
@ -127,6 +127,7 @@
|
||||||
<orderEntry type="library" name="Leiningen: metosin/vega-tools:0.2.0" level="project" />
|
<orderEntry type="library" name="Leiningen: metosin/vega-tools:0.2.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: migratus:1.2.0" level="project" />
|
<orderEntry type="library" name="Leiningen: migratus:1.2.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: mount:0.1.15" level="project" />
|
<orderEntry type="library" name="Leiningen: mount:0.1.15" level="project" />
|
||||||
|
<orderEntry type="library" name="Leiningen: mysql/mysql-connector-java:8.0.12" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: net.cgrand/parsley:0.9.3" level="project" />
|
<orderEntry type="library" name="Leiningen: net.cgrand/parsley:0.9.3" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: net.cgrand/regex:1.1.0" level="project" />
|
<orderEntry type="library" name="Leiningen: net.cgrand/regex:1.1.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: net.cgrand/sjacket:0.1.1" level="project" />
|
<orderEntry type="library" name="Leiningen: net.cgrand/sjacket:0.1.1" level="project" />
|
||||||
|
@ -185,7 +186,6 @@
|
||||||
<orderEntry type="library" name="Leiningen: org.openid4java/openid4java-nodeps:0.9.6" level="project" />
|
<orderEntry type="library" name="Leiningen: org.openid4java/openid4java-nodeps:0.9.6" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: org.ow2.asm/asm-all:4.2" level="project" />
|
<orderEntry type="library" name="Leiningen: org.ow2.asm/asm-all:4.2" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: org.ow2.asm/asm:5.1" level="project" />
|
<orderEntry type="library" name="Leiningen: org.ow2.asm/asm:5.1" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: org.postgresql/postgresql:42.2.5" level="project" />
|
|
||||||
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-clojure:0.13.1" level="project" />
|
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-clojure:0.13.1" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-core:0.13.1" level="project" />
|
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-core:0.13.1" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-web-undertow:0.13.1" level="project" />
|
<orderEntry type="library" name="Leiningen: org.projectodd.wunderboss/wunderboss-web-undertow:0.13.1" level="project" />
|
||||||
|
|
|
@ -12,4 +12,4 @@
|
||||||
:access-token-uri "https://api.twitter.com/oauth/access_token"
|
:access-token-uri "https://api.twitter.com/oauth/access_token"
|
||||||
:authorize-uri "https://api.twitter.com/oauth/authenticate"
|
:authorize-uri "https://api.twitter.com/oauth/authenticate"
|
||||||
; set your dev database connection URL here
|
; set your dev database connection URL here
|
||||||
:database-url "postgresql://localhost:5432/a_db_name?user=a_username&password=a_password"}
|
:database-url "mysql://localhost:3306/a_db_name?user=a_username&password=a_password"}
|
|
@ -27,7 +27,9 @@
|
||||||
[org.clojure/clojurescript "1.10.439" :scope "provided"]
|
[org.clojure/clojurescript "1.10.439" :scope "provided"]
|
||||||
[org.clojure/tools.cli "0.4.1"]
|
[org.clojure/tools.cli "0.4.1"]
|
||||||
[org.clojure/tools.logging "0.4.1"]
|
[org.clojure/tools.logging "0.4.1"]
|
||||||
[org.postgresql/postgresql "42.2.5"]
|
;[org.postgresql/postgresql "42.2.5"]
|
||||||
|
[mysql/mysql-connector-java "8.0.12"]
|
||||||
|
[com.google.protobuf/protobuf-java "3.6.1"]
|
||||||
;https://www.webjars.org/
|
;https://www.webjars.org/
|
||||||
[org.webjars.npm/bulma "0.7.2"]
|
[org.webjars.npm/bulma "0.7.2"]
|
||||||
[org.webjars/font-awesome "5.6.1"]
|
[org.webjars/font-awesome "5.6.1"]
|
||||||
|
|
|
@ -101,8 +101,16 @@
|
||||||
{% if user %}
|
{% if user %}
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-narrow">
|
<div class="column">
|
||||||
<h3 class="subtitle is-3">Your cuddles</h3>
|
<div class="card">
|
||||||
|
<header class="card-header">
|
||||||
|
<p class="card-header-title">
|
||||||
|
Your cuddles
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="content">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -120,7 +128,18 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
<div class="card">
|
||||||
|
<header class="card-header">
|
||||||
|
<p class="card-header-title">
|
||||||
|
Outgoing requests
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="content">
|
||||||
<form action="/request_relation" method="post">
|
<form action="/request_relation" method="post">
|
||||||
{% csrf-field %}
|
{% csrf-field %}
|
||||||
<div class="field has-addons">
|
<div class="field has-addons">
|
||||||
|
@ -138,8 +157,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div class="columns">
|
<br/>
|
||||||
<div class="column">
|
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -158,7 +176,18 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
<div class="card">
|
||||||
|
<header class="card-header">
|
||||||
|
<p class="card-header-title">
|
||||||
|
Incoming requests
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="content">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -171,7 +200,8 @@
|
||||||
<td>
|
<td>
|
||||||
<span>{{rr.from_name}}</span>
|
<span>{{rr.from_name}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td {% ifunequal rr.status "open" %}colspan='2'{% endifunequal %}>
|
<td {% ifunequal rr.status
|
||||||
|
"open" %}colspan='2'{% endifunequal %}>
|
||||||
{% include "parts/colored-status.html" %}
|
{% include "parts/colored-status.html" %}
|
||||||
</td>
|
</td>
|
||||||
{% ifequal rr.status "open" %}
|
{% ifequal rr.status "open" %}
|
||||||
|
@ -181,12 +211,14 @@
|
||||||
<div class="field has-addons is-right">
|
<div class="field has-addons is-right">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit" name="accept"
|
<button type="submit" name="accept"
|
||||||
class="button is-success is-small is-rounded is-outlined">Accept
|
class="button is-success is-small is-rounded is-outlined">
|
||||||
|
Accept
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="submit" name="decline"
|
<button type="submit" name="decline"
|
||||||
class="button is-danger is-small is-rounded is-outlined">Decline
|
class="button is-danger is-small is-rounded is-outlined">
|
||||||
|
Decline
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -200,6 +232,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user.admin.enabled %}
|
{% if user.admin.enabled %}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
CREATE TABLE users
|
CREATE TABLE users
|
||||||
(id SERIAL PRIMARY KEY,
|
(id INT NOT NULL AUTO_INCREMENT,
|
||||||
name VARCHAR(255) NOT NULL,
|
name VARCHAR(255) NOT NULL,
|
||||||
gender VARCHAR(255));
|
gender VARCHAR(255),
|
||||||
|
|
||||||
|
PRIMARY KEY(id));
|
|
@ -1,6 +1,8 @@
|
||||||
CREATE TABLE relations
|
CREATE TABLE relations
|
||||||
(id SERIAL PRIMARY KEY,
|
(id INT NOT NULL AUTO_INCREMENT,
|
||||||
from_id INTEGER NOT NULL,
|
from_id INT NOT NULL,
|
||||||
to_id INTEGER NOT NULL,
|
to_id INT NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY(id),
|
||||||
FOREIGN KEY (from_id) REFERENCES users(id),
|
FOREIGN KEY (from_id) REFERENCES users(id),
|
||||||
FOREIGN KEY (to_id) REFERENCES users(id));
|
FOREIGN KEY (to_id) REFERENCES users(id));
|
|
@ -1 +0,0 @@
|
||||||
DROP TYPE STATUS;
|
|
|
@ -1,2 +0,0 @@
|
||||||
CREATE TYPE STATUS as ENUM
|
|
||||||
('open', 'accepted', 'declined');
|
|
|
@ -1,7 +1,9 @@
|
||||||
CREATE TABLE relation_requests
|
CREATE TABLE relation_requests
|
||||||
(id SERIAL PRIMARY KEY,
|
(id INT NOT NULL AUTO_INCREMENT,
|
||||||
from_id INTEGER NOT NULL,
|
from_id INT NOT NULL,
|
||||||
to_id INTEGER NOT NULL,
|
to_id INT NOT NULL,
|
||||||
status STATUS NOT NULL,
|
status ENUM('open', 'accepted', 'declined') NOT NULL,
|
||||||
|
|
||||||
|
PRIMARY KEY (id),
|
||||||
FOREIGN KEY (from_id) REFERENCES users (id),
|
FOREIGN KEY (from_id) REFERENCES users (id),
|
||||||
FOREIGN KEY (to_id) REFERENCES users (id));
|
FOREIGN KEY (to_id) REFERENCES users (id));
|
|
@ -4,10 +4,6 @@ body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
|
||||||
margin-top: 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.loader-container {
|
.loader-container {
|
||||||
width: 700px;
|
width: 700px;
|
||||||
height: 425px;
|
height: 425px;
|
||||||
|
|
|
@ -274,7 +274,7 @@
|
||||||
"value": "#ccc"
|
"value": "#ccc"
|
||||||
},
|
},
|
||||||
"strokeWidth": {
|
"strokeWidth": {
|
||||||
"value": 0.5
|
"value": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
(ns cat.db.core
|
(ns cat.db.core
|
||||||
(:require
|
(:require
|
||||||
[cheshire.core :refer [generate-string parse-string]]
|
[clj-time.jdbc]
|
||||||
[clojure.java.jdbc :as jdbc]
|
[clojure.java.jdbc :as jdbc]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[conman.core :as conman]
|
[conman.core :as conman]
|
||||||
[java-time :as jt]
|
[java-time.pre-java8 :as jt]
|
||||||
[cat.config :refer [env]]
|
[cat.config :refer [env]]
|
||||||
[mount.core :refer [defstate]]
|
[mount.core :refer [defstate]]
|
||||||
[clojure.string :as s])
|
[clojure.string :as s])
|
||||||
(:import org.postgresql.util.PGobject
|
(:import [java.sql
|
||||||
java.sql.Array
|
|
||||||
clojure.lang.IPersistentMap
|
|
||||||
clojure.lang.IPersistentVector
|
|
||||||
[java.sql
|
|
||||||
BatchUpdateException
|
BatchUpdateException
|
||||||
PreparedStatement]))
|
PreparedStatement]))
|
||||||
|
|
||||||
(defstate ^:dynamic *db*
|
(defstate ^:dynamic *db*
|
||||||
:start (if-let [jdbc-url (env :database-url)]
|
:start (if-let [jdbc-url (env :database-url)]
|
||||||
(conman/connect! {:jdbc-url jdbc-url})
|
(conman/connect! {:jdbc-url jdbc-url})
|
||||||
|
@ -35,33 +32,7 @@
|
||||||
(.toLocalDate v))
|
(.toLocalDate v))
|
||||||
java.sql.Time
|
java.sql.Time
|
||||||
(result-set-read-column [v _2 _3]
|
(result-set-read-column [v _2 _3]
|
||||||
(.toLocalTime v))
|
(.toLocalTime v)))
|
||||||
Array
|
|
||||||
(result-set-read-column [v _ _] (vec (.getArray v)))
|
|
||||||
PGobject
|
|
||||||
(result-set-read-column [pgobj _metadata _index]
|
|
||||||
(let [type (.getType pgobj)
|
|
||||||
value (.getValue pgobj)]
|
|
||||||
(case type
|
|
||||||
"json" (parse-string value true)
|
|
||||||
"jsonb" (parse-string value true)
|
|
||||||
"citext" (str value)
|
|
||||||
value))))
|
|
||||||
|
|
||||||
(defn to-pg-json [value]
|
|
||||||
(doto (PGobject.)
|
|
||||||
(.setType "jsonb")
|
|
||||||
(.setValue (generate-string value))))
|
|
||||||
|
|
||||||
(extend-type clojure.lang.IPersistentVector
|
|
||||||
jdbc/ISQLParameter
|
|
||||||
(set-parameter [v ^java.sql.PreparedStatement stmt ^long idx]
|
|
||||||
(let [conn (.getConnection stmt)
|
|
||||||
meta (.getParameterMetaData stmt)
|
|
||||||
type-name (.getParameterTypeName meta idx)]
|
|
||||||
(if-let [elem-type (when (= (first type-name) \_) (apply str (rest type-name)))]
|
|
||||||
(.setObject stmt idx (.createArrayOf conn elem-type (to-array v)))
|
|
||||||
(.setObject stmt idx (to-pg-json v))))))
|
|
||||||
|
|
||||||
(extend-protocol jdbc/ISQLValue
|
(extend-protocol jdbc/ISQLValue
|
||||||
java.util.Date
|
java.util.Date
|
||||||
|
@ -78,46 +49,4 @@
|
||||||
(jt/sql-timestamp v))
|
(jt/sql-timestamp v))
|
||||||
java.time.ZonedDateTime
|
java.time.ZonedDateTime
|
||||||
(sql-value [v]
|
(sql-value [v]
|
||||||
(jt/sql-timestamp v))
|
(jt/sql-timestamp v)))
|
||||||
IPersistentMap
|
|
||||||
(sql-value [value] (to-pg-json value))
|
|
||||||
IPersistentVector
|
|
||||||
(sql-value [value] (to-pg-json value)))
|
|
||||||
|
|
||||||
|
|
||||||
; postgres enum type <--> clojure namespaces keywords
|
|
||||||
|
|
||||||
; https://raw.githubusercontent.com/qutebrowser/qutebrowser/master/doc/img/cheatsheet-big.png
|
|
||||||
; Handle Inserting of keywords as enums into the db
|
|
||||||
; Usage: (insert! pg-db :files {:name "my-file.txt", :status :processing-status/pending})
|
|
||||||
(defn kw->pgenum
|
|
||||||
"Convert clj keyword to equivalent PGobject"
|
|
||||||
[kw]
|
|
||||||
(let [type (-> (namespace kw)
|
|
||||||
(s/replace "-" "_"))
|
|
||||||
value (name kw)]
|
|
||||||
(doto (PGobject.)
|
|
||||||
(.setType type)
|
|
||||||
(.setValue value))))
|
|
||||||
|
|
||||||
(extend-type clojure.lang.Keyword
|
|
||||||
jdbc/ISQLValue
|
|
||||||
(sql-value [kw]
|
|
||||||
(kw->pgenum kw)))
|
|
||||||
|
|
||||||
; Handle extracting keywords from the db enum type
|
|
||||||
; Usage:
|
|
||||||
; (query (:db user/system) ["SELECT * FROM files"])
|
|
||||||
; => ({:status :processing-status/pending, :name "my-file.txt"})
|
|
||||||
(def +schema-enums+
|
|
||||||
"A set of all PostgreSQL enums in schema.sql. Used to convert
|
|
||||||
enum-values back into Clojure keywords."
|
|
||||||
#{"status"})
|
|
||||||
|
|
||||||
(extend-type String
|
|
||||||
jdbc/IResultSetReadColumn
|
|
||||||
(result-set-read-column [val rsmeta idx]
|
|
||||||
(let [type (.getColumnTypeName rsmeta idx)]
|
|
||||||
(if (contains? +schema-enums+ type)
|
|
||||||
(keyword (s/replace type "_" "-") val)
|
|
||||||
val))))
|
|
|
@ -35,10 +35,6 @@
|
||||||
:title "Wrong request parameters"
|
:title "Wrong request parameters"
|
||||||
:message "Please contact your system administrator to fix this issue"}))
|
:message "Please contact your system administrator to fix this issue"}))
|
||||||
|
|
||||||
(defn map-status-to-value
|
|
||||||
[relation-requests]
|
|
||||||
(map (fn [rr] (cond-> rr (:status rr) (assoc :status (name (:status rr))))) relation-requests))
|
|
||||||
|
|
||||||
(defroutes home-routes
|
(defroutes home-routes
|
||||||
(GET "/" req
|
(GET "/" req
|
||||||
(let [users (get-users)
|
(let [users (get-users)
|
||||||
|
@ -53,10 +49,10 @@
|
||||||
other_users (when user
|
other_users (when user
|
||||||
(seq (filter (fn [usr] (not (= (:id usr) (:id user))))
|
(seq (filter (fn [usr] (not (= (:id usr) (:id user))))
|
||||||
users)))
|
users)))
|
||||||
rel-requests-out (seq (map-status-to-value (db/get-relation-requests-from-user {:from_id (:id user)})))
|
rel-requests-out (seq (db/get-relation-requests-from-user {:from_id (:id user)}))
|
||||||
rel-requests-in (seq (map-status-to-value (db/get-relation-requests-to-user {:to_id (:id user)})))]
|
rel-requests-in (seq (db/get-relation-requests-to-user {:to_id (:id user)}))]
|
||||||
(log/info (str "Session: " (:session req)))
|
;(log/info (str "Session: " (:session req)))
|
||||||
(log/info (str "Relation requests: \n OUTGOING: " rel-requests-out "\n INCOMING: " rel-requests-in))
|
;(log/info (str "Relation requests: \n OUTGOING: " rel-requests-out "\n INCOMING: " rel-requests-in))
|
||||||
;(log/info (str "User relations: " user-relations))
|
;(log/info (str "User relations: " user-relations))
|
||||||
;(log/info (str "Other Users: " other_users))
|
;(log/info (str "Other Users: " other_users))
|
||||||
(home-page {:relations relations
|
(home-page {:relations relations
|
||||||
|
@ -103,8 +99,8 @@
|
||||||
(contains? body :accept) (do
|
(contains? body :accept) (do
|
||||||
(let [rr (db/get-relation-request rr_id_map)]
|
(let [rr (db/get-relation-request rr_id_map)]
|
||||||
(db/create-relation! {:from_id (:from_id rr) :to_id (:to_id rr)}))
|
(db/create-relation! {:from_id (:from_id rr) :to_id (:to_id rr)}))
|
||||||
(db/update-relation-request-status! (assoc rr_id_map :status :status/accepted)))
|
(db/update-relation-request-status! (assoc rr_id_map :status "accepted")))
|
||||||
(contains? body :decline) (db/update-relation-request-status! (assoc rr_id_map :status :status/declined))
|
(contains? body :decline) (db/update-relation-request-status! (assoc rr_id_map :status "declined"))
|
||||||
:else false)]
|
:else false)]
|
||||||
(if success
|
(if success
|
||||||
(response/found "/")
|
(response/found "/")
|
||||||
|
@ -117,7 +113,7 @@
|
||||||
(do
|
(do
|
||||||
(db/create-relation-request! {:from_id (get-in req [:session :user :id])
|
(db/create-relation-request! {:from_id (get-in req [:session :user :id])
|
||||||
:to_id (:to_id result)
|
:to_id (:to_id result)
|
||||||
:status :status/open})
|
:status "open"})
|
||||||
(response/found "/"))
|
(response/found "/"))
|
||||||
(do
|
(do
|
||||||
(response/bad-request "Incorrect input")))))
|
(response/bad-request "Incorrect input")))))
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
[cat.moauth :as mo]
|
[cat.moauth :as mo]
|
||||||
[cat.db.core :refer [*db*] :as db]))
|
[cat.db.core :refer [*db*] :as db]))
|
||||||
|
|
||||||
(def admins #{31 ;flynn
|
(def admins #{1 ;flynn
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn set-user! [user session redirect-url]
|
(defn set-user! [user session redirect-url]
|
||||||
|
|
Loading…
Reference in a new issue