mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +02:00
Reduce cloned space permissions copy
Removed unnecessary results from SQL.
This commit is contained in:
parent
9ee9526a47
commit
0847a82fc9
3 changed files with 682 additions and 677 deletions
|
@ -117,13 +117,18 @@ func (s Scope) GetSpacePermissions(ctx domain.RequestContext, spaceID string) (r
|
||||||
|
|
||||||
err = s.Runtime.Db.Select(&r, `
|
err = s.Runtime.Db.Select(&r, `
|
||||||
SELECT id, orgid, who, whoid, action, scope, location, refid
|
SELECT id, orgid, who, whoid, action, scope, location, refid
|
||||||
FROM permission WHERE orgid=? AND location='space' AND refid=? AND who='user'
|
FROM permission WHERE orgid=? AND location='space' AND refid=?`,
|
||||||
UNION ALL
|
ctx.OrgID, spaceID)
|
||||||
SELECT p.id, p.orgid, p.who, p.whoid, p.action, p.scope, p.location, p.refid
|
|
||||||
FROM permission p
|
// err = s.Runtime.Db.Select(&r, `
|
||||||
LEFT JOIN rolemember r ON p.whoid=r.roleid
|
// SELECT id, orgid, who, whoid, action, scope, location, refid
|
||||||
WHERE p.orgid=? AND p.location='space' AND p.refid=? AND p.who='role'`,
|
// FROM permission WHERE orgid=? AND location='space' AND refid=? AND who='user'
|
||||||
ctx.OrgID, spaceID, ctx.OrgID, spaceID)
|
// UNION ALL
|
||||||
|
// SELECT p.id, p.orgid, p.who, p.whoid, p.action, p.scope, p.location, p.refid
|
||||||
|
// FROM permission p
|
||||||
|
// LEFT JOIN rolemember r ON p.whoid=r.roleid
|
||||||
|
// WHERE p.orgid=? AND p.location='space' AND p.refid=? AND p.who='role'`,
|
||||||
|
// ctx.OrgID, spaceID, ctx.OrgID, spaceID)
|
||||||
|
|
||||||
if err == sql.ErrNoRows {
|
if err == sql.ErrNoRows {
|
||||||
err = nil
|
err = nil
|
||||||
|
|
|
@ -155,15 +155,15 @@ func (h *Handler) Add(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
spCloneRoles, err := h.Store.Permission.GetSpacePermissions(ctx, model.CloneID)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Transaction.Rollback()
|
|
||||||
response.WriteServerError(w, method, err)
|
|
||||||
h.Runtime.Log.Error(method, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if model.CopyPermission {
|
if model.CopyPermission {
|
||||||
|
spCloneRoles, err := h.Store.Permission.GetSpacePermissions(ctx, model.CloneID)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Transaction.Rollback()
|
||||||
|
response.WriteServerError(w, method, err)
|
||||||
|
h.Runtime.Log.Error(method, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for _, r := range spCloneRoles {
|
for _, r := range spCloneRoles {
|
||||||
r.RefID = sp.RefID
|
r.RefID = sp.RefID
|
||||||
|
|
||||||
|
|
1324
embed/bindata.go
1324
embed/bindata.go
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue