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
802da8f7
Commit
802da8f7
authored
10 years ago
by
Allen Gilliland
Browse files
Options
Downloads
Patches
Plain Diff
when we create a new org via api lets automatically add the creator as an admin member.
parent
ab633c8e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/org.clj
+8
-2
8 additions, 2 deletions
src/metabase/api/org.clj
test/metabase/api/org_test.clj
+8
-2
8 additions, 2 deletions
test/metabase/api/org_test.clj
with
16 additions
and
4 deletions
src/metabase/api/org.clj
+
8
−
2
View file @
802da8f7
...
...
@@ -23,8 +23,14 @@
(
require-params
name
slug
)
;; user must be a superuser to proceed
(
check-403
(
:is_superuser
@
*current-user*
))
(
->>
(
util/select-non-nil-keys
body
:slug
:name
:description
:logo_url
)
(
mapply
ins
Org
)))
;; create the new org
(
let-500
[{
:keys
[
id
]
:as
new-org
}
(
->>
(
util/select-non-nil-keys
body
:slug
:name
:description
:logo_url
)
(
mapply
ins
Org
))]
;; now that the Org exists, add the creator as the first admin member
(
grant-org-perm
id
*current-user-id*
true
)
;; make sure the api response is still the newly created org
new-org
))
(
defendpoint
GET
"/:id"
[
id
]
(
->404
(
sel
:one
Org
:id
id
)
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/org_test.clj
+
8
−
2
View file @
802da8f7
...
...
@@ -95,7 +95,13 @@
:description
nil
:logo_url
nil
:inherits
false
})
(
create-org
org-name
)))
(
let
[
new-org
(
create-org
org-name
)
org-perm
(
sel
:one
OrgPerm
:organization_id
(
:id
new-org
))]
;; do a quick validation that the creator is now an admin of the new org
(
assert
(
=
(
:user_id
org-perm
)
(
user->id
:crowberto
)))
(
assert
(
:admin
org-perm
))
;; return the original api response, which should be the newly created org
new-org
)))
;; Test input validations on org create
(
expect
"'name' is a required param."
...
...
@@ -296,7 +302,7 @@
(
let
[
test-org-name
(
random-name
)]
(
expect-eval-actual-first
(
let
[{
my-org-id
:id
}
(
sel
:one
Org
:name
test-org-name
)]
(
match-$
(
first
(
sel
:
many
OrgPerm
:organization_id
my-org-id
)
)
(
match-$
(
sel
:
one
OrgPerm
:organization_id
my-org-id
:user_id
[
not=
(
user->id
:crowberto
)]
)
{
:id
$
:admin
true
:user_id
$
...
...
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