Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5a0fc434
Commit
5a0fc434
authored
Nov 29, 2016
by
Carl Bergquist
Committed by
GitHub
Nov 29, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6722 from dpavlos/fix_6679
[6679] Check if org exists before delete it
parents
b00e9390
0064331b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
pkg/api/org.go
+3
-0
pkg/services/sqlstore/org.go
+6
-0
No files found.
pkg/api/org.go
View file @
5a0fc434
...
...
@@ -152,6 +152,9 @@ func updateOrgAddressHelper(form dtos.UpdateOrgAddressForm, orgId int64) Respons
// GET /api/orgs/:orgId
func
DeleteOrgById
(
c
*
middleware
.
Context
)
Response
{
if
err
:=
bus
.
Dispatch
(
&
m
.
DeleteOrgCommand
{
Id
:
c
.
ParamsInt64
(
":orgId"
)});
err
!=
nil
{
if
err
==
m
.
ErrOrgNotFound
{
return
ApiError
(
404
,
"Failed to delete organization. ID not found"
,
nil
)
}
return
ApiError
(
500
,
"Failed to update organization"
,
err
)
}
return
ApiSuccess
(
"Organization deleted"
)
...
...
pkg/services/sqlstore/org.go
View file @
5a0fc434
...
...
@@ -176,6 +176,12 @@ func UpdateOrgAddress(cmd *m.UpdateOrgAddressCommand) error {
func
DeleteOrg
(
cmd
*
m
.
DeleteOrgCommand
)
error
{
return
inTransaction2
(
func
(
sess
*
session
)
error
{
//Check if organization exists
if
res
,
err
:=
sess
.
Query
(
"SELECT 1 from org WHERE id=?"
,
cmd
.
Id
);
err
!=
nil
{
return
err
}
else
if
len
(
res
)
!=
1
{
return
m
.
ErrOrgNotFound
}
deletes
:=
[]
string
{
"DELETE FROM star WHERE EXISTS (SELECT 1 FROM dashboard WHERE org_id = ? AND star.dashboard_id = dashboard.id)"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment