mirror of
https://github.com/documize/community.git
synced 2025-07-23 23:29:42 +02:00
Draft documents always visible to editors when space lifecycle set to Draft mode
This commit is contained in:
parent
9724f85653
commit
f5b196c334
6 changed files with 688 additions and 744 deletions
|
@ -52,9 +52,9 @@ Space view.
|
||||||
|
|
||||||
## Latest version
|
## Latest version
|
||||||
|
|
||||||
[Community edition: v1.64.3](https://github.com/documize/community/releases)
|
[Community edition: v1.64.4](https://github.com/documize/community/releases)
|
||||||
|
|
||||||
[Enterprise edition: v1.66.3](https://documize.com/downloads)
|
[Enterprise edition: v1.66.4](https://documize.com/downloads)
|
||||||
|
|
||||||
## OS support
|
## OS support
|
||||||
|
|
||||||
|
|
|
@ -143,9 +143,19 @@ func (h *Handler) BySpace(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get user permissions
|
// Get the space as we need to check settings.
|
||||||
|
space, err := h.Store.Space.Get(ctx, spaceID)
|
||||||
|
|
||||||
|
// Can user view drafts?
|
||||||
viewDrafts := permission.CanViewDrafts(ctx, *h.Store, spaceID)
|
viewDrafts := permission.CanViewDrafts(ctx, *h.Store, spaceID)
|
||||||
|
|
||||||
|
// If space defaults to drfat documents, then this means
|
||||||
|
// user can view drafts as long as they have edit rights.
|
||||||
|
canEdit := permission.HasPermission(ctx, *h.Store, spaceID, pm.DocumentEdit)
|
||||||
|
if space.Lifecycle == workflow.LifecycleDraft && canEdit {
|
||||||
|
viewDrafts = true
|
||||||
|
}
|
||||||
|
|
||||||
// Get complete list of documents regardless of category permission
|
// Get complete list of documents regardless of category permission
|
||||||
// and versioning.
|
// and versioning.
|
||||||
documents, err := h.Store.Document.GetBySpace(ctx, spaceID)
|
documents, err := h.Store.Document.GetBySpace(ctx, spaceID)
|
||||||
|
|
|
@ -227,72 +227,6 @@ func HasPermission(ctx domain.RequestContext, s domain.Store, spaceID string, ac
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// // GetDocumentApprovers returns list of users who can approve given document in given space
|
|
||||||
// func GetDocumentApprovers(ctx domain.RequestContext, s domain.Store, spaceID, documentID string) (users []u.User, err error) {
|
|
||||||
// users = []u.User{}
|
|
||||||
// prev := make(map[string]bool) // used to ensure we only process user once
|
|
||||||
|
|
||||||
// // Permissions can be assigned to both groups and individual users.
|
|
||||||
// // Pre-fetch users with group membership to help us work out
|
|
||||||
// // if user belongs to a group with permissions.
|
|
||||||
// groupMembers, err := s.Group.GetMembers(ctx)
|
|
||||||
// if err != nil {
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // space permissions
|
|
||||||
// sp, err := s.Permission.GetSpacePermissions(ctx, spaceID)
|
|
||||||
// if err != nil {
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
// // document permissions
|
|
||||||
// dp, err := s.Permission.GetDocumentPermissions(ctx, documentID)
|
|
||||||
// if err != nil {
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // all permissions
|
|
||||||
// all := sp
|
|
||||||
// all = append(all, dp...)
|
|
||||||
|
|
||||||
// for _, p := range all {
|
|
||||||
// // only approvers
|
|
||||||
// if p.Action != pm.DocumentApprove {
|
|
||||||
// continue
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if p.Who == pm.GroupPermission {
|
|
||||||
// // get group records for just this group
|
|
||||||
// groupRecords := group.FilterGroupRecords(groupMembers, p.WhoID)
|
|
||||||
|
|
||||||
// for i := range groupRecords {
|
|
||||||
// user, err := s.User.Get(ctx, groupRecords[i].UserID)
|
|
||||||
// if err != nil {
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
// if _, isExisting := prev[user.RefID]; !isExisting {
|
|
||||||
// users = append(users, user)
|
|
||||||
// prev[user.RefID] = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if p.Who == pm.UserPermission {
|
|
||||||
// user, err := s.User.Get(ctx, p.WhoID)
|
|
||||||
// if err != nil {
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if _, isExisting := prev[user.RefID]; !isExisting {
|
|
||||||
// users = append(users, user)
|
|
||||||
// prev[user.RefID] = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return users, err
|
|
||||||
// }
|
|
||||||
|
|
||||||
// GetUsersWithDocumentPermission returns list of users who have specified document permission in given space
|
// GetUsersWithDocumentPermission returns list of users who have specified document permission in given space
|
||||||
func GetUsersWithDocumentPermission(ctx domain.RequestContext, s domain.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error) {
|
func GetUsersWithDocumentPermission(ctx domain.RequestContext, s domain.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error) {
|
||||||
users = []u.User{}
|
users = []u.User{}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func main() {
|
||||||
rt.Product = env.ProdInfo{}
|
rt.Product = env.ProdInfo{}
|
||||||
rt.Product.Major = "1"
|
rt.Product.Major = "1"
|
||||||
rt.Product.Minor = "64"
|
rt.Product.Minor = "64"
|
||||||
rt.Product.Patch = "3"
|
rt.Product.Patch = "4"
|
||||||
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
|
||||||
rt.Product.Edition = "Community"
|
rt.Product.Edition = "Community"
|
||||||
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,7 +10,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th colspan="3">Spaces</th>
|
<th colspan="3">Spaces</th>
|
||||||
<th colspan="7" class="text-info">Documents</th>
|
<th colspan="9" class="text-info">Documents</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue