Chore: Remove org model duplicates (#61025)

Remove org model duplicates
This commit is contained in:
idafurjes
2023-01-09 14:39:53 +01:00
committed by GitHub
parent 68b43a24e2
commit 7dcb502b33
15 changed files with 49 additions and 155 deletions
@@ -82,7 +82,7 @@ func (p *teamPermissionMigrator) mapPermissionToRBAC(permission models.Permissio
}
func (p *teamPermissionMigrator) getUserRoleByOrgMapping() (map[int64]map[int64]string, error) {
var orgUsers []*models.OrgUserDTO
var orgUsers []*org.OrgUserDTO
if err := p.sess.SQL(`SELECT * FROM org_user`).Cols("org_user.org_id", "org_user.user_id", "org_user.role").Find(&orgUsers); err != nil {
return nil, err
}
@@ -91,13 +91,13 @@ func (p *teamPermissionMigrator) getUserRoleByOrgMapping() (map[int64]map[int64]
// Loop through users and organise them by organization ID
for _, orgUser := range orgUsers {
orgRoles, initialized := userRolesByOrg[orgUser.OrgId]
orgRoles, initialized := userRolesByOrg[orgUser.OrgID]
if !initialized {
orgRoles = map[int64]string{}
}
orgRoles[orgUser.UserId] = orgUser.Role
userRolesByOrg[orgUser.OrgId] = orgRoles
orgRoles[orgUser.UserID] = orgUser.Role
userRolesByOrg[orgUser.OrgID] = orgRoles
}
return userRolesByOrg, nil
@@ -273,38 +273,38 @@ func setupTeams(t *testing.T, x *xorm.Engine) {
require.NoError(t, errInsertUsers)
require.Equal(t, int64(5), usersCount, "needed 5 users for this test to run")
orgUsers := []models.OrgUser{
orgUsers := []org.OrgUser{
{
OrgId: 1,
UserId: 1,
OrgID: 1,
UserID: 1,
Role: org.RoleViewer,
Created: now,
Updated: now,
},
{
OrgId: 1,
UserId: 2,
OrgID: 1,
UserID: 2,
Role: org.RoleViewer,
Created: now,
Updated: now,
},
{
OrgId: 1,
UserId: 3,
OrgID: 1,
UserID: 3,
Role: org.RoleEditor,
Created: now,
Updated: now,
},
{
OrgId: 1,
UserId: 4,
OrgID: 1,
UserID: 4,
Role: org.RoleAdmin,
Created: now,
Updated: now,
},
{
OrgId: 2,
UserId: 5,
OrgID: 2,
UserID: 5,
Role: org.RoleEditor,
Created: now,
Updated: now,
+3 -4
View File
@@ -8,7 +8,6 @@ import (
"time"
"github.com/grafana/grafana/pkg/events"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/org"
"github.com/grafana/grafana/pkg/services/user"
"github.com/grafana/grafana/pkg/util"
@@ -110,9 +109,9 @@ func (ss *SQLStore) createUser(ctx context.Context, sess *DBSession, args user.C
Email: usr.Email,
})
orgUser := models.OrgUser{
OrgId: orgID,
UserId: usr.ID,
orgUser := org.OrgUser{
OrgID: orgID,
UserID: usr.ID,
Role: org.RoleAdmin,
Created: time.Now(),
Updated: time.Now(),