1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 07:09:43 +02:00

Draft documents always visible to editors when space lifecycle set to Draft mode

This commit is contained in:
Harvey Kandola 2018-05-14 11:52:51 +01:00
parent 9724f85653
commit f5b196c334
6 changed files with 688 additions and 744 deletions

View file

@ -143,9 +143,19 @@ func (h *Handler) BySpace(w http.ResponseWriter, r *http.Request) {
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)
// 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
// and versioning.
documents, err := h.Store.Document.GetBySpace(ctx, spaceID)