Skip to content

Commit f5b196c

Browse files
committed
Draft documents always visible to editors when space lifecycle set to Draft mode
1 parent 9724f85 commit f5b196c

File tree

6 files changed

+681
-737
lines changed

6 files changed

+681
-737
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ Space view.
5252

5353
## Latest version
5454

55-
[Community edition: v1.64.3](https://github.com/documize/community/releases)
55+
[Community edition: v1.64.4](https://github.com/documize/community/releases)
5656

57-
[Enterprise edition: v1.66.3](https://documize.com/downloads)
57+
[Enterprise edition: v1.66.4](https://documize.com/downloads)
5858

5959
## OS support
6060

domain/document/endpoint.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,19 @@ func (h *Handler) BySpace(w http.ResponseWriter, r *http.Request) {
143143
return
144144
}
145145

146-
// get user permissions
146+
// Get the space as we need to check settings.
147+
space, err := h.Store.Space.Get(ctx, spaceID)
148+
149+
// Can user view drafts?
147150
viewDrafts := permission.CanViewDrafts(ctx, *h.Store, spaceID)
148151

152+
// If space defaults to drfat documents, then this means
153+
// user can view drafts as long as they have edit rights.
154+
canEdit := permission.HasPermission(ctx, *h.Store, spaceID, pm.DocumentEdit)
155+
if space.Lifecycle == workflow.LifecycleDraft && canEdit {
156+
viewDrafts = true
157+
}
158+
149159
// Get complete list of documents regardless of category permission
150160
// and versioning.
151161
documents, err := h.Store.Document.GetBySpace(ctx, spaceID)

domain/permission/permission.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -227,72 +227,6 @@ func HasPermission(ctx domain.RequestContext, s domain.Store, spaceID string, ac
227227
return false
228228
}
229229

230-
// // GetDocumentApprovers returns list of users who can approve given document in given space
231-
// func GetDocumentApprovers(ctx domain.RequestContext, s domain.Store, spaceID, documentID string) (users []u.User, err error) {
232-
// users = []u.User{}
233-
// prev := make(map[string]bool) // used to ensure we only process user once
234-
235-
// // Permissions can be assigned to both groups and individual users.
236-
// // Pre-fetch users with group membership to help us work out
237-
// // if user belongs to a group with permissions.
238-
// groupMembers, err := s.Group.GetMembers(ctx)
239-
// if err != nil {
240-
// return users, err
241-
// }
242-
243-
// // space permissions
244-
// sp, err := s.Permission.GetSpacePermissions(ctx, spaceID)
245-
// if err != nil {
246-
// return users, err
247-
// }
248-
// // document permissions
249-
// dp, err := s.Permission.GetDocumentPermissions(ctx, documentID)
250-
// if err != nil {
251-
// return users, err
252-
// }
253-
254-
// // all permissions
255-
// all := sp
256-
// all = append(all, dp...)
257-
258-
// for _, p := range all {
259-
// // only approvers
260-
// if p.Action != pm.DocumentApprove {
261-
// continue
262-
// }
263-
264-
// if p.Who == pm.GroupPermission {
265-
// // get group records for just this group
266-
// groupRecords := group.FilterGroupRecords(groupMembers, p.WhoID)
267-
268-
// for i := range groupRecords {
269-
// user, err := s.User.Get(ctx, groupRecords[i].UserID)
270-
// if err != nil {
271-
// return users, err
272-
// }
273-
// if _, isExisting := prev[user.RefID]; !isExisting {
274-
// users = append(users, user)
275-
// prev[user.RefID] = true
276-
// }
277-
// }
278-
// }
279-
280-
// if p.Who == pm.UserPermission {
281-
// user, err := s.User.Get(ctx, p.WhoID)
282-
// if err != nil {
283-
// return users, err
284-
// }
285-
286-
// if _, isExisting := prev[user.RefID]; !isExisting {
287-
// users = append(users, user)
288-
// prev[user.RefID] = true
289-
// }
290-
// }
291-
// }
292-
293-
// return users, err
294-
// }
295-
296230
// GetUsersWithDocumentPermission returns list of users who have specified document permission in given space
297231
func GetUsersWithDocumentPermission(ctx domain.RequestContext, s domain.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error) {
298232
users = []u.User{}

edition/community.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
rt.Product = env.ProdInfo{}
4343
rt.Product.Major = "1"
4444
rt.Product.Minor = "64"
45-
rt.Product.Patch = "3"
45+
rt.Product.Patch = "4"
4646
rt.Product.Version = fmt.Sprintf("%s.%s.%s", rt.Product.Major, rt.Product.Minor, rt.Product.Patch)
4747
rt.Product.Edition = "Community"
4848
rt.Product.Title = fmt.Sprintf("%s Edition", rt.Product.Edition)

0 commit comments

Comments
 (0)