editing users uses datomic.
This commit is contained in:
@@ -6,26 +6,18 @@
|
||||
[com.walmartlabs.lacinia.executor :as executor]
|
||||
[com.walmartlabs.lacinia.resolve :as resolve]
|
||||
[buddy.auth :refer [throw-unauthorized]]
|
||||
[auto-ap.db.invoices :as invoices]
|
||||
[auto-ap.utils :refer [by]]
|
||||
[auto-ap.graphql.utils :refer [assert-admin can-see-company? assert-can-see-company]]
|
||||
[auto-ap.db.vendors :as vendors]
|
||||
[auto-ap.db.companies :as companies]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.datomic.checks :as d-checks]
|
||||
[auto-ap.datomic.users :as d-users]
|
||||
[auto-ap.datomic.invoices :as d-invoices]
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.db.users :as users]
|
||||
[auto-ap.db.checks :as checks]
|
||||
[auto-ap.graphql.users :as gq-users]
|
||||
[auto-ap.graphql.checks :as gq-checks]
|
||||
[auto-ap.graphql.expense-accounts :as expense-accounts]
|
||||
[auto-ap.graphql.invoices :as gq-invoices]
|
||||
[auto-ap.graphql.transactions :as gq-transactions]
|
||||
[auto-ap.db.reminders :as reminders]
|
||||
[auto-ap.db.invoices-checks :as invoices-checks]
|
||||
[auto-ap.db.utils :as utils]
|
||||
[clojure.walk :as walk]
|
||||
[clojure.string :as str])
|
||||
(:import
|
||||
@@ -131,8 +123,7 @@
|
||||
:status {:type 'String}
|
||||
:client {:type :client}
|
||||
:payment {:type :payment}
|
||||
:bank_account {:type :bank_account
|
||||
:resolve :bank-account-for-check}
|
||||
:bank_account {:type :bank_account}
|
||||
:date {:type 'String}
|
||||
:post_date {:type 'String}}}
|
||||
:invoice_payment
|
||||
@@ -144,10 +135,10 @@
|
||||
:invoice {:type :invoice}}}
|
||||
|
||||
:user
|
||||
{:fields {:id {:type 'Int}
|
||||
{:fields {:id {:type 'String}
|
||||
:name {:type 'String}
|
||||
:role {:type 'String}
|
||||
:clients {:type '(list :company)}}}
|
||||
:clients {:type '(list :client)}}}
|
||||
|
||||
:expense_account {:fields {:id {:type 'Int}
|
||||
:location {:type 'String}
|
||||
@@ -245,12 +236,7 @@
|
||||
:asc {:type 'Boolean}}
|
||||
|
||||
:resolve :get-payment-page}
|
||||
:reminder_page {:type '(list :reminder_page)
|
||||
:args {:start {:type 'Int}
|
||||
:sort_by {:type 'String}
|
||||
:asc {:type 'Boolean}}
|
||||
|
||||
:resolve :get-reminder-page}
|
||||
|
||||
:company {:type '(list :company)
|
||||
:resolve :get-company}
|
||||
:client {:type '(list :company)
|
||||
@@ -266,10 +252,10 @@
|
||||
:amount {:type 'Float}}}
|
||||
|
||||
:edit_user
|
||||
{:fields {:id {:type 'Int}
|
||||
{:fields {:id {:type 'String}
|
||||
:name {:type 'String}
|
||||
:role {:type 'String}
|
||||
:companies {:type '(list Int)}}}
|
||||
:clients {:type '(list String)}}}
|
||||
|
||||
:edit_expense_account
|
||||
{:fields {:id {:type 'String}
|
||||
@@ -399,22 +385,6 @@
|
||||
(d-checks/get-graphql (assoc (<-graphql args)
|
||||
:limit Integer/MAX_VALUE))))
|
||||
|
||||
(defn get-reminder-page [context args value]
|
||||
(assert-admin (:id context))
|
||||
(let [extra-context
|
||||
(cond-> {}
|
||||
(executor/selects-field? context :reminder/vendor) (assoc :vendor-cache (by :id (vendors/get-all))))
|
||||
|
||||
reminders (map
|
||||
->graphql
|
||||
(reminders/get-graphql (<-graphql args)))
|
||||
reminder-count (reminders/count-graphql (<-graphql args))]
|
||||
(resolve/with-context
|
||||
[{:reminders reminders
|
||||
:total reminder-count
|
||||
:count (count reminders)
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count reminders))}] extra-context)))
|
||||
|
||||
|
||||
|
||||
@@ -425,18 +395,7 @@
|
||||
|
||||
|
||||
|
||||
(defn bank-account-for-check [context args value]
|
||||
(->graphql
|
||||
(let [company (if-let [company-cache (:company-cache context)]
|
||||
(company-cache (:company_id value))
|
||||
(companies/get-by-id (:company_id value)))]
|
||||
(first (filter #(= (:id %) (:bank_account_id value)) (:bank-accounts company))) )))
|
||||
|
||||
(defn get-user-companies [context args value]
|
||||
(->graphql
|
||||
(if-let [company-cache (:company-cache context)]
|
||||
(map company-cache (:companies value))
|
||||
(map companies/get-by-id (:companies value)))))
|
||||
|
||||
|
||||
|
||||
@@ -445,18 +404,12 @@
|
||||
(filter #(can-see-company? (:id context) %)
|
||||
(d-clients/get-all))))
|
||||
|
||||
(defn join-companies [users]
|
||||
(let [companies (by :id (companies/get-all))]
|
||||
(map
|
||||
(fn [u]
|
||||
(update u :companies #(map companies %)))
|
||||
users)))
|
||||
|
||||
(defn get-user [context args value]
|
||||
(assert-admin (:id context))
|
||||
|
||||
(let [users (d-users/get-graphql args)]
|
||||
(->graphql users)))
|
||||
(doto (let [users (d-users/get-graphql args)]
|
||||
(->graphql users))
|
||||
println))
|
||||
|
||||
(defn get-vendor [context args value]
|
||||
(->graphql
|
||||
@@ -480,13 +433,11 @@
|
||||
(attach-resolvers {:get-invoice-page get-invoice-page
|
||||
:get-all-invoices get-all-invoices
|
||||
:get-all-payments get-all-payments
|
||||
:bank-account-for-check bank-account-for-check
|
||||
:get-payment-page gq-checks/get-payment-page
|
||||
:get-transaction-page gq-transactions/get-transaction-page
|
||||
:get-reminder-page get-reminder-page
|
||||
|
||||
:get-company get-company
|
||||
:get-user get-user
|
||||
:get-user-companies get-user-companies
|
||||
:mutation/add-handwritten-check gq-checks/add-handwritten-check
|
||||
:mutation/print-checks print-checks
|
||||
:mutation/edit-user gq-users/edit-user
|
||||
|
||||
Reference in New Issue
Block a user