Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
100e350c
Commit
100e350c
authored
8 years ago
by
Cam Saül
Browse files
Options
Downloads
Patches
Plain Diff
Include :can_write with GET /api/collection
parent
a1cccd1b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
docs/api-documentation.md
+5
-2
5 additions, 2 deletions
docs/api-documentation.md
src/metabase/api/collection.clj
+6
-1
6 additions, 1 deletion
src/metabase/api/collection.clj
src/metabase/models/interface.clj
+1
-1
1 addition, 1 deletion
src/metabase/models/interface.clj
with
12 additions
and
4 deletions
docs/api-documentation.md
+
5
−
2
View file @
100e350c
...
...
@@ -173,11 +173,14 @@ Update a `Card`.
## `GET /api/collection/`
Fetch a list of all Collections that the current user has read permissions for.
By default, this returns non-archived Collections, but you
This includes
`:can_write`
, which means whether the current user is allowed to add or remove Cards to this Collection; keep in mind
that regardless of this status you must be a superuser to modify properties of Collections themselves.
By default, this returns non-archived Collections, but instead you can show archived ones by passing
`?archived=true`
.
##### PARAMS:
*
**`archived`**
value may be nil, or if non-nil, value must be a boolean.
*
**`archived`**
value may be nil, or if non-nil, value must be a
valid
boolean
(true or false)
.
## `GET /api/collection/:id`
...
...
This diff is collapsed.
Click to expand it.
src/metabase/api/collection.clj
+
6
−
1
View file @
100e350c
...
...
@@ -6,16 +6,21 @@
[
metabase.db
:as
db
]
(
metabase.models
[
card
:refer
[
Card
]]
[
collection
:refer
[
Collection
]
,
:as
collection
]
[
hydrate
:refer
[
hydrate
]]
[
interface
:as
models
])
[
metabase.util.schema
:as
su
]))
(
api/defendpoint
GET
"/"
"Fetch a list of all Collections that the current user has read permissions for.
This includes `:can_write`, which means whether the current user is allowed to add or remove Cards to this Collection; keep in mind
that regardless of this status you must be a superuser to modify properties of Collections themselves.
By default, this returns non-archived Collections, but instead you can show archived ones by passing `?archived=true`."
[
archived
]
{
archived
(
s/maybe
su/BooleanString
)}
(
filterv
models/can-read?
(
db/select
Collection
:archived
(
Boolean/parseBoolean
archived
)
{
:order-by
[[
:%lower.name
:asc
]]})))
(
->
(
filterv
models/can-read?
(
db/select
Collection
:archived
(
Boolean/parseBoolean
archived
)
{
:order-by
[[
:%lower.name
:asc
]]}))
(
hydrate
:can_write
)))
(
api/defendpoint
GET
"/:id"
"Fetch a specific (non-archived) Collection, including cards that belong to it."
...
...
This diff is collapsed.
Click to expand it.
src/metabase/models/interface.clj
+
1
−
1
View file @
100e350c
...
...
@@ -60,7 +60,7 @@
* `(partial current-user-has-full-permissions? :read)` (you must also implement `perms-objects-set` to use this)
* `(partial current-user-has-partial-permissions? :read)` (you must also implement `perms-objects-set` to use this)"
)
(
can-write?
^
Boolean
[
instance
]
,
^
Boolean
[
entity,
^
Integer
id
]
(
^
{
:hydrate
:can_write
}
can-write?
^
Boolean
[
instance
]
,
^
Boolean
[
entity,
^
Integer
id
]
"Return whether `*current-user*` has *write* permissions for an object. You should use one of these implmentations:
* `(constantly true)`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment