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
b796027b
Commit
b796027b
authored
Mar 14, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: refactor.
parent
13ed1049
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
15 deletions
+3
-15
pkg/services/sqlstore/team.go
+3
-15
No files found.
pkg/services/sqlstore/team.go
View file @
b796027b
...
@@ -259,28 +259,21 @@ func AddTeamMember(cmd *m.AddTeamMemberCommand) error {
...
@@ -259,28 +259,21 @@ func AddTeamMember(cmd *m.AddTeamMemberCommand) error {
func
UpdateTeamMember
(
cmd
*
m
.
UpdateTeamMemberCommand
)
error
{
func
UpdateTeamMember
(
cmd
*
m
.
UpdateTeamMemberCommand
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
return
inTransaction
(
func
(
sess
*
DBSession
)
error
{
rawSql
:=
`SELECT * FROM team_member WHERE org_id=? and team_id=? and user_id=?`
rawSql
:=
`SELECT * FROM team_member WHERE org_id=? and team_id=? and user_id=?`
var
member
m
.
TeamMember
var
member
m
.
TeamMember
exists
,
err
:=
sess
.
SQL
(
rawSql
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
.
Get
(
&
member
)
exists
,
err
:=
sess
.
SQL
(
rawSql
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
.
Get
(
&
member
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
!
exists
{
if
!
exists
{
return
m
.
ErrTeamMemberNotFound
return
m
.
ErrTeamMemberNotFound
}
}
if
cmd
.
ProtectLastAdmin
{
if
cmd
.
ProtectLastAdmin
{
lastAdmin
,
err
:=
isLastAdmin
(
sess
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
_
,
err
:=
isLastAdmin
(
sess
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
lastAdmin
{
return
m
.
ErrLastTeamAdmin
}
}
}
if
cmd
.
Permission
!=
m
.
PERMISSION_ADMIN
{
// make sure we don't get invalid permission levels in store
if
cmd
.
Permission
!=
m
.
PERMISSION_ADMIN
{
// make sure we don't get invalid permission levels in store
...
@@ -302,15 +295,10 @@ func RemoveTeamMember(cmd *m.RemoveTeamMemberCommand) error {
...
@@ -302,15 +295,10 @@ func RemoveTeamMember(cmd *m.RemoveTeamMemberCommand) error {
}
}
if
cmd
.
ProtectLastAdmin
{
if
cmd
.
ProtectLastAdmin
{
lastAdmin
,
err
:=
isLastAdmin
(
sess
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
_
,
err
:=
isLastAdmin
(
sess
,
cmd
.
OrgId
,
cmd
.
TeamId
,
cmd
.
UserId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
lastAdmin
{
return
m
.
ErrLastTeamAdmin
}
}
}
var
rawSql
=
"DELETE FROM team_member WHERE org_id=? and team_id=? and user_id=?"
var
rawSql
=
"DELETE FROM team_member WHERE org_id=? and team_id=? and user_id=?"
...
@@ -344,7 +332,7 @@ func isLastAdmin(sess *DBSession, orgId int64, teamId int64, userId int64) (bool
...
@@ -344,7 +332,7 @@ func isLastAdmin(sess *DBSession, orgId int64, teamId int64, userId int64) (bool
}
}
if
isAdmin
&&
len
(
userIds
)
==
1
{
if
isAdmin
&&
len
(
userIds
)
==
1
{
return
true
,
nil
return
true
,
m
.
ErrLastTeamAdmin
}
}
return
false
,
err
return
false
,
err
...
...
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