mirror of
https://github.com/documize/community.git
synced 2025-07-21 22:29:41 +02:00
WIP document versioning
This commit is contained in:
parent
ba52dfa11d
commit
089457f16e
6 changed files with 222 additions and 67 deletions
|
@ -153,45 +153,10 @@ func (h *Handler) BySpace(w http.ResponseWriter, r *http.Request) {
|
|||
// sort by title
|
||||
sort.Sort(doc.ByTitle(documents))
|
||||
|
||||
// remove documents that cannot be seen due to lack of
|
||||
// category view/access permission
|
||||
filtered := []doc.Document{}
|
||||
// remove documents that cannot be seen due to lack of category view/access permission
|
||||
cats, err := h.Store.Category.GetBySpace(ctx, spaceID)
|
||||
members, err := h.Store.Category.GetSpaceCategoryMembership(ctx, spaceID)
|
||||
|
||||
for _, doc := range documents {
|
||||
hasCategory := false
|
||||
canSeeCategory := false
|
||||
skip := false
|
||||
|
||||
// drafts included if user can see them
|
||||
if doc.Lifecycle == workflow.LifecycleDraft && !viewDrafts {
|
||||
skip = true
|
||||
}
|
||||
|
||||
// archived never included
|
||||
if doc.Lifecycle == workflow.LifecycleArchived {
|
||||
skip = true
|
||||
}
|
||||
|
||||
OUTER:
|
||||
|
||||
for _, m := range members {
|
||||
if m.DocumentID == doc.RefID {
|
||||
hasCategory = true
|
||||
for _, cat := range cats {
|
||||
if cat.RefID == m.CategoryID {
|
||||
canSeeCategory = true
|
||||
continue OUTER
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !skip && (!hasCategory || canSeeCategory) {
|
||||
filtered = append(filtered, doc)
|
||||
}
|
||||
}
|
||||
filtered := FilterCategoryProtected(documents, cats, members, viewDrafts)
|
||||
|
||||
response.WriteJSON(w, filtered)
|
||||
}
|
||||
|
@ -259,6 +224,24 @@ func (h *Handler) Update(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
// Record document being marked as archived
|
||||
if d.Lifecycle != oldDoc.Lifecycle && d.Lifecycle == workflow.LifecycleArchived {
|
||||
h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
|
||||
LabelID: d.LabelID,
|
||||
DocumentID: documentID,
|
||||
SourceType: activity.SourceTypeDocument,
|
||||
ActivityType: activity.TypeArchived})
|
||||
}
|
||||
|
||||
// Record document being marked as draft
|
||||
if d.Lifecycle != oldDoc.Lifecycle && d.Lifecycle == workflow.LifecycleDraft {
|
||||
h.Store.Activity.RecordUserActivity(ctx, activity.UserActivity{
|
||||
LabelID: d.LabelID,
|
||||
DocumentID: documentID,
|
||||
SourceType: activity.SourceTypeDocument,
|
||||
ActivityType: activity.TypeDraft})
|
||||
}
|
||||
|
||||
ctx.Transaction.Commit()
|
||||
|
||||
h.Store.Audit.Record(ctx, audit.EventTypeDocumentUpdate)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue