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
af4994ba
Commit
af4994ba
authored
Mar 06, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: editor added as admin for created teams.
parent
22e098b8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
17 deletions
+37
-17
pkg/api/api.go
+1
-1
pkg/api/team.go
+12
-1
pkg/models/team_member.go
+11
-9
pkg/services/sqlstore/migrations/team_mig.go
+6
-0
pkg/services/sqlstore/team.go
+7
-6
No files found.
pkg/api/api.go
View file @
af4994ba
...
...
@@ -154,7 +154,7 @@ func (hs *HTTPServer) registerRoutes() {
// team (admin permission required)
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
teamsRoute
.
Post
(
"/"
,
bind
(
m
.
CreateTeamCommand
{}),
Wrap
(
CreateTeam
))
teamsRoute
.
Post
(
"/"
,
bind
(
m
.
CreateTeamCommand
{}),
Wrap
(
hs
.
CreateTeam
))
teamsRoute
.
Put
(
"/:teamId"
,
bind
(
m
.
UpdateTeamCommand
{}),
Wrap
(
UpdateTeam
))
teamsRoute
.
Delete
(
"/:teamId"
,
Wrap
(
DeleteTeamByID
))
teamsRoute
.
Get
(
"/:teamId/members"
,
Wrap
(
GetTeamMembers
))
...
...
pkg/api/team.go
View file @
af4994ba
...
...
@@ -8,7 +8,7 @@ import (
)
// POST /api/teams
func
CreateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
CreateTeamCommand
)
Response
{
func
(
hs
*
HTTPServer
)
CreateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
CreateTeamCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
if
err
==
m
.
ErrTeamNameTaken
{
...
...
@@ -17,6 +17,17 @@ func CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Response {
return
Error
(
500
,
"Failed to create Team"
,
err
)
}
if
c
.
OrgRole
==
m
.
ROLE_EDITOR
&&
hs
.
Cfg
.
EditorsCanOwn
{
addMemberCmd
:=
m
.
AddTeamMemberCommand
{
UserId
:
c
.
SignedInUser
.
UserId
,
OrgId
:
cmd
.
OrgId
,
TeamId
:
cmd
.
Result
.
Id
,
Permission
:
int64
(
m
.
PERMISSION_ADMIN
),
}
err
:=
bus
.
Dispatch
(
&
addMemberCmd
)
c
.
Logger
.
Error
(
"Could not add creator to team."
,
"error"
,
err
)
}
return
JSON
(
200
,
&
util
.
DynMap
{
"teamId"
:
cmd
.
Result
.
Id
,
"message"
:
"Team created"
,
...
...
pkg/models/team_member.go
View file @
af4994ba
...
...
@@ -12,11 +12,12 @@ var (
// TeamMember model
type
TeamMember
struct
{
Id
int64
OrgId
int64
TeamId
int64
UserId
int64
External
bool
Id
int64
OrgId
int64
TeamId
int64
UserId
int64
External
bool
Permission
int64
Created
time
.
Time
Updated
time
.
Time
...
...
@@ -26,10 +27,11 @@ type TeamMember struct {
// COMMANDS
type
AddTeamMemberCommand
struct
{
UserId
int64
`json:"userId" binding:"Required"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
External
bool
`json:"-"`
UserId
int64
`json:"userId" binding:"Required"`
OrgId
int64
`json:"-"`
TeamId
int64
`json:"-"`
External
bool
`json:"-"`
Permission
int64
`json:"-"`
}
type
RemoveTeamMemberCommand
struct
{
...
...
pkg/services/sqlstore/migrations/team_mig.go
View file @
af4994ba
...
...
@@ -54,4 +54,10 @@ func addTeamMigrations(mg *Migrator) {
mg
.
AddMigration
(
"Add column external to team_member table"
,
NewAddColumnMigration
(
teamMemberV1
,
&
Column
{
Name
:
"external"
,
Type
:
DB_Bool
,
Nullable
:
true
,
}))
mg
.
AddMigration
(
"Add column permission to team_member table"
,
NewAddColumnMigration
(
teamMemberV1
,
&
Column
{
Name
:
"permission"
,
Type
:
DB_BigInt
,
Nullable
:
true
,
}))
}
pkg/services/sqlstore/team.go
View file @
af4994ba
...
...
@@ -240,12 +240,13 @@ func AddTeamMember(cmd *m.AddTeamMemberCommand) error {
}
entity
:=
m
.
TeamMember
{
OrgId
:
cmd
.
OrgId
,
TeamId
:
cmd
.
TeamId
,
UserId
:
cmd
.
UserId
,
External
:
cmd
.
External
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
OrgId
:
cmd
.
OrgId
,
TeamId
:
cmd
.
TeamId
,
UserId
:
cmd
.
UserId
,
External
:
cmd
.
External
,
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
Permission
:
cmd
.
Permission
,
}
_
,
err
:=
sess
.
Insert
(
&
entity
)
...
...
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