1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

document approvals and protection

This commit is contained in:
Harvey Kandola 2017-12-24 15:51:43 +00:00
parent 58c88e2127
commit f4f32bcfcb
20 changed files with 891 additions and 777 deletions

View file

@ -16,22 +16,24 @@ import (
"time"
"github.com/documize/community/model"
"github.com/documize/community/model/workflow"
)
// Document represents the purpose of Documize.
type Document struct {
model.BaseEntity
OrgID string `json:"orgId"`
LabelID string `json:"folderId"`
UserID string `json:"userId"`
Job string `json:"job"`
Location string `json:"location"`
Title string `json:"name"`
Excerpt string `json:"excerpt"`
Slug string `json:"-"`
Tags string `json:"tags"`
Template bool `json:"template"`
Layout string `json:"layout"`
OrgID string `json:"orgId"`
LabelID string `json:"folderId"`
UserID string `json:"userId"`
Job string `json:"job"`
Location string `json:"location"`
Title string `json:"name"`
Excerpt string `json:"excerpt"`
Slug string `json:"-"`
Tags string `json:"tags"`
Template bool `json:"template"`
Protection workflow.Protection `json:"protection"`
Approval workflow.Approval `json:"approval"`
}
// SetDefaults ensures on blanks and cleans.

View file

@ -16,23 +16,26 @@ import (
"time"
"github.com/documize/community/model"
"github.com/documize/community/model/workflow"
)
// Page represents a section within a document.
type Page struct {
model.BaseEntity
OrgID string `json:"orgId"`
DocumentID string `json:"documentId"`
UserID string `json:"userId"`
ContentType string `json:"contentType"`
PageType string `json:"pageType"`
BlockID string `json:"blockId"`
Level uint64 `json:"level"`
Sequence float64 `json:"sequence"`
Numbering string `json:"numbering"`
Title string `json:"title"`
Body string `json:"body"`
Revisions uint64 `json:"revisions"`
OrgID string `json:"orgId"`
DocumentID string `json:"documentId"`
UserID string `json:"userId"`
ContentType string `json:"contentType"`
PageType string `json:"pageType"`
BlockID string `json:"blockId"`
Level uint64 `json:"level"`
Sequence float64 `json:"sequence"`
Numbering string `json:"numbering"`
Title string `json:"title"`
Body string `json:"body"`
Revisions uint64 `json:"revisions"`
Protection workflow.Protection `json:"protection"`
Approval workflow.Approval `json:"approval"`
}
// SetDefaults ensures no blank values.

View file

@ -32,24 +32,34 @@ type Action string
const (
// SpaceView action means you can view a space and documents therein
SpaceView Action = "view"
// SpaceManage action means you can add, remove users, set permissions, but not delete that space
SpaceManage Action = "manage"
// SpaceOwner action means you can delete a space and do all SpaceManage functions
SpaceOwner Action = "own"
// DocumentAdd action means you can create/upload documents to a space
DocumentAdd Action = "doc-add"
// DocumentEdit action means you can edit documents in a space
DocumentEdit Action = "doc-edit"
// DocumentDelete means you can delete documents in a space
DocumentDelete Action = "doc-delete"
// DocumentMove means you can move documents between spaces
DocumentMove Action = "doc-move"
// DocumentCopy means you can copy documents within and between spaces
DocumentCopy Action = "doc-copy"
// DocumentTemplate means you can create, edit and delete document templates and content blocks
DocumentTemplate Action = "doc-template"
// DocumentApprove means you can approve a change to a document
DocumentApprove Action = "doc-approve"
// CategoryView action means you can view a category and documents therein
CategoryView Action = "view"
)
@ -70,6 +80,7 @@ type Record struct {
DocumentMove bool `json:"documentMove"`
DocumentCopy bool `json:"documentCopy"`
DocumentTemplate bool `json:"documentTemplate"`
DocumentApprove bool `json:"documentApprove"`
}
// DecodeUserPermissions returns a flat, usable permission summary record
@ -104,6 +115,8 @@ func DecodeUserPermissions(perm []Permission) (r Record) {
r.DocumentCopy = true
case DocumentTemplate:
r.DocumentTemplate = true
case DocumentApprove:
r.DocumentApprove = true
}
}
@ -158,6 +171,9 @@ func EncodeUserPermissions(r Record) (perm []Permission) {
if r.DocumentTemplate {
perm = append(perm, EncodeRecord(r, DocumentTemplate))
}
if r.DocumentApprove {
perm = append(perm, EncodeRecord(r, DocumentApprove))
}
return
}
@ -165,7 +181,7 @@ func EncodeUserPermissions(r Record) (perm []Permission) {
// HasAnyPermission returns true if user has at least one permission.
func HasAnyPermission(p Record) bool {
return p.SpaceView || p.SpaceManage || p.SpaceOwner || p.DocumentAdd || p.DocumentEdit ||
p.DocumentDelete || p.DocumentMove || p.DocumentCopy || p.DocumentTemplate
p.DocumentDelete || p.DocumentMove || p.DocumentCopy || p.DocumentTemplate || p.DocumentApprove
}
// EncodeRecord creates standard permission record representing user permissions for a space.

View file

@ -0,0 +1,43 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
package workflow
// Protection tell us how to handle data item changes
type Protection int
const (
// NoProtection means no protection so data item changes are permitted
NoProtection Protection = 0
// Lock means no data itme changes
Lock Protection = 1
// Review means changes must be reviewed and approved
Review Protection = 2
)
// Approval tells us how some data item change is to be approved
type Approval int
const (
// NoApproval means no approval necessary
NoApproval Approval = 0
// Anybody can approve data item change
Anybody Approval = 1
// Majority must approve data item change
Majority Approval = 2
// Unanimous approval must be given for data item change
Unanimous Approval = 3
)