Skip to content
Snippets Groups Projects
Commit 4ad25fc1 authored by Cam Saul's avatar Cam Saul
Browse files

tweak annotation names to be a little more consistent

parent 5a76a104
Branches
Tags
No related merge requests found
......@@ -22,7 +22,7 @@
object-models))
(defannotation AnnotationType [symb value :nillable]
(annotation:IsInteger symb value)
(annotation:Integer symb value)
(checkp-contains? (set [annotation-description annotation-general]) symb value))
......@@ -40,14 +40,14 @@
(defendpoint POST "/" [:as {{:keys [organization start end title body annotation_type object_model object_id]
:or {annotation_type annotation-general}
:as request-body} :body}]
{organization [Required IsInteger]
{organization [Required Integer]
start [Required Date]
end [Required Date]
body [Required NonEmptyString]
title NonEmptyString
annotation_type [Required AnnotationType]
object_model [Required AnnotationObjectModel->ID]
object_id [Required IsInteger]}
object_id [Required Integer]}
;; user only needs to be member of an organization (read perms) to be able to post annotations
(read-check Org organization)
(-> (ins Annotation
......
......@@ -269,7 +269,7 @@
You can also use it inside the body of another annotation:
(defannotation PublicPerm [symb value :nillable]
(annotation:IsInteger symb value]
(annotation:Integer symb value]
(checkp-contains? #{0 1 2} symb value))"
{:arglists '([annotation-name docstr? [symbol-binding value-binding nillable?] & body])}
[annotation-name & args]
......@@ -312,17 +312,17 @@
(catch java.lang.NumberFormatException _
(format "Invalid value '%s' for '%s': cannot parse as an integer." value symb))))
(defannotation IsInteger
(defannotation Integer
"Check that a param is an integer (this does *not* cast the param!)"
[symb value :nillable]
(checkp-with integer? symb value "value must be an integer."))
(defannotation IsBool
(defannotation Boolean
"Check that param is a boolean (this does *not* cast the param!)"
[symb value :nillable]
(checkp-with boolean? symb value "value must be a boolean."))
(defannotation IsDict
(defannotation Dict
"Check that param is a dictionary (this does *not* cast the param!)"
[symb value :nillable]
(checkp-with map? symb value "value must be a dictionary."))
......@@ -335,7 +335,7 @@
(defannotation PublicPerms
"check that perms is `int` in `#{0 1 2}`"
[symb value :nillable]
(annotation:IsInteger symb value)
(annotation:Integer symb value)
(checkp-contains? #{0 1 2} symb value))
(defannotation Email
......
......@@ -53,7 +53,7 @@
(del Dashboard :id id))
(defendpoint POST "/:id/cards" [id :as {{:keys [cardId]} :body}]
{cardId [Required IsInteger]}
{cardId [Required Integer]}
(write-check Dashboard id)
(check-400 (exists? Card :id cardId))
(ins DashboardCard :card_id cardId :dashboard_id id))
......
......@@ -20,7 +20,7 @@
(defannotation EmailReportMode
"Check that param is a value int ID for an email report mode."
[symb value :nillable]
(annotation:IsInteger symb value)
(annotation:Integer symb value)
(checkp-contains? (set (map :id (vals model/modes))) symb value))
(defendpoint GET "/form_input" [org]
......
......@@ -28,7 +28,7 @@
{org Required
name [Required NonEmptyString]
engine [Required DBEngine]
details [Required IsDict]}
details [Required Dict]}
(write-check Org org)
(let-500 [new-db (ins Database :organization_id org :name name :engine engine :details details)]
;; kick off background job to gather schema metadata about our new db
......@@ -55,7 +55,7 @@
(hydrate :organization)))
(defendpoint PUT "/:id" [id :as {{:keys [name engine details]} :body}]
{name NonEmptyString, details IsDict} ; TODO - check that engine is a valid choice
{name NonEmptyString, details Dict} ; TODO - check that engine is a valid choice
(write-check Database id)
(check-500 (upd-non-nil-keys Database id
:name name
......
......@@ -55,7 +55,7 @@
(defendpoint POST "/:id/members" [id :as {{:keys [first_name last_name email admin]
:or {admin false}} :body}]
{admin IsBool
{admin Boolean
first_name [Required NonEmptyString]
last_name [Required NonEmptyString]
email [Required Email]}
......@@ -72,7 +72,7 @@
(defendpoint POST "/:id/members/:user-id" [id user-id :as {{:keys [admin]} :body}]
{admin IsBool}
{admin Boolean}
(write-check Org id)
(check-exists? User user-id)
(grant-org-perm id user-id admin)
......@@ -81,7 +81,7 @@
;; TODO `POST` and `PUT` endpoints are exactly the same. Do we need both?
(defendpoint PUT "/:id/members/:user-id" [id user-id :as {{:keys [admin]} :body}]
{admin IsBool}
{admin Boolean}
(write-check Org id)
(check-exists? User user-id)
(grant-org-perm id user-id admin)
......
......@@ -13,7 +13,7 @@
(declare execute-query)
(defendpoint POST "/" [:as {{:keys [timezone database sql] :as body} :body}]
{database [Required IsInteger]
{database [Required Integer]
sql [Required NonEmptyString]} ; TODO - check timezone
(read-check Database database)
(let [dataset-query {:type "native"
......
......@@ -72,7 +72,7 @@
(defendpoint POST "/" [:as {{:keys [clone] :as body} :body}]
{clone IsInteger}
{clone Integer}
(if clone
(query-clone clone)
(query-create body)))
......@@ -85,7 +85,7 @@
(defendpoint PUT "/:id" [id :as {{:keys [name public_perms details timezone database] :as body} :body}]
{database [Required IsDict]
{database [Required Dict]
name NonEmptyString
public_perms PublicPerms}
(read-check Database (:id database))
......
......@@ -59,8 +59,8 @@
(defendpoint POST "/" [:as {{:keys [page results_per_page q models]
:or {page 1
results_per_page 10}} :body}]
{page IsInteger
results_per_page IsInteger
{page Integer
results_per_page Integer
q [Required NonEmptyString]}
(let [models (if (empty? models) (vals search-choices) ; if `models` is unspecified default to all search choices
(->> models ; otherwise get the corresponding search choice maps
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment