rename card inventory views and add list id / user id parameters
This commit is contained in:
parent
1abbcf1302
commit
90a5a26c95
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
(defvc inventory-management
|
(defvc inventory-management
|
||||||
[card-id list-id]
|
[card-id list-id]
|
||||||
(let [inventory (view-cursor :owned-card card-id)
|
(let [inventory (view-cursor :card-inventory card-id list-id (auth/get-username))
|
||||||
inventory (group-by :quality @inventory)
|
inventory (group-by :quality @inventory)
|
||||||
colspan (if (can-modify-inventory?) 2 1)
|
colspan (if (can-modify-inventory?) 2 1)
|
||||||
quantity-class (if (can-modify-inventory?)
|
quantity-class (if (can-modify-inventory?)
|
||||||
|
|
|
@ -34,8 +34,8 @@
|
||||||
(view :simple-sets-list get-db #'sets/simple-sets-list)
|
(view :simple-sets-list get-db #'sets/simple-sets-list)
|
||||||
(view :sets-list get-db #'sets/sets-list)
|
(view :sets-list get-db #'sets/sets-list)
|
||||||
|
|
||||||
(view :owned-card get-db #'collection/owned-card)
|
(view :card-inventory get-db #'collection/card-inventory)
|
||||||
(view :total-owned-of-card get-db #'collection/total-owned-of-card)
|
(view :total-card-inventory get-db #'collection/total-card-inventory)
|
||||||
|
|
||||||
(view :card-pricing get-db #'prices/card-pricing)
|
(view :card-pricing get-db #'prices/card-pricing)
|
||||||
(view :pricing-sources get-db #'prices/pricing-sources)
|
(view :pricing-sources get-db #'prices/pricing-sources)
|
||||||
|
|
|
@ -1,15 +1,25 @@
|
||||||
(ns mtgcoll.views.functions.collection)
|
(ns mtgcoll.views.functions.collection)
|
||||||
|
|
||||||
(defn owned-card
|
(defn card-inventory
|
||||||
[card-id]
|
[card-id list-id user-id]
|
||||||
["select quality, quantity, foil
|
(let [list-id (int list-id)
|
||||||
from collection
|
public-only? (nil? user-id)]
|
||||||
where card_id = ? AND list_id = 0"
|
["select cl.quality, cl.quantity, cl.foil
|
||||||
card-id])
|
from collection cl
|
||||||
|
join lists l on cl.list_id = l.id
|
||||||
|
where cl.card_id = ?
|
||||||
|
and cl.list_id = ?
|
||||||
|
and (l.is_public in (true, ?))"
|
||||||
|
card-id list-id public-only?]))
|
||||||
|
|
||||||
(defn total-owned-of-card
|
(defn total-card-inventory
|
||||||
[card-id]
|
[card-id list-id user-id]
|
||||||
|
(let [list-id (int list-id)
|
||||||
|
public-only? (nil? user-id)]
|
||||||
["select count(*)
|
["select count(*)
|
||||||
from collection
|
from collection cl
|
||||||
where card_id = ? AND list_id = 0"
|
join lists l on cl.list_id = l.id
|
||||||
card-id])
|
where card_id = ?
|
||||||
|
and cl.list_id = ?
|
||||||
|
and (l.is_public in (true, ?))"
|
||||||
|
card-id list-id public-only?]))
|
||||||
|
|
Loading…
Reference in a new issue