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

Update TinyMCE to v4.7.5

Resolves Codesample inline editing glitch.
This commit is contained in:
sauls8t 2018-01-23 12:34:43 +00:00
parent 4c80b8877d
commit 88b99979a9
90 changed files with 186 additions and 77 deletions

View file

@ -14,6 +14,7 @@ package document
import (
"database/sql"
"encoding/json"
"github.com/documize/community/model/user"
"io/ioutil"
"net/http"
"sort"
@ -33,6 +34,7 @@ import (
pm "github.com/documize/community/model/permission"
"github.com/documize/community/model/search"
"github.com/documize/community/model/space"
"github.com/documize/community/model/workflow"
)
// Handler contains the runtime information such as logging and database.
@ -261,11 +263,6 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
return
}
if !permission.CanDeleteDocument(ctx, *h.Store, documentID) {
response.WriteForbiddenError(w)
return
}
doc, err := h.Store.Document.Get(ctx, documentID)
if err != nil {
response.WriteServerError(w, method, err)
@ -273,6 +270,35 @@ func (h *Handler) Delete(w http.ResponseWriter, r *http.Request) {
return
}
// If locked document then no can do
if doc.Protection == workflow.ProtectionLock {
response.WriteForbiddenError(w)
h.Runtime.Log.Info("attempted action on locked document")
return
}
// If approval workflow then only approvers can delete page
if doc.Protection == workflow.ProtectionReview {
approvers, err := permission.GetDocumentApprovers(ctx, *h.Store, doc.LabelID, doc.RefID)
if err != nil {
response.WriteForbiddenError(w)
h.Runtime.Log.Error(method, err)
return
}
if !user.Exists(approvers, ctx.UserID) {
response.WriteForbiddenError(w)
h.Runtime.Log.Info("attempted action on document when not approver")
return
}
}
// permission check
if !permission.CanDeleteDocument(ctx, *h.Store, documentID) {
response.WriteForbiddenError(w)
return
}
ctx.Transaction, err = h.Runtime.Db.Beginx()
if err != nil {
response.WriteServerError(w, method, err)
@ -427,7 +453,7 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) {
sp = []space.Space{}
}
data := documentData{}
data := BulkDocumentData{}
data.Document = document
data.Permissions = record
data.Roles = rolesRecord
@ -458,9 +484,9 @@ func (h *Handler) FetchDocumentData(w http.ResponseWriter, r *http.Request) {
response.WriteJSON(w, data)
}
// documentData represents all data associated for a single document.
// BulkDocumentData represents all data associated for a single document.
// Used by FetchDocumentData() bulk data load call.
type documentData struct {
type BulkDocumentData struct {
Document doc.Document `json:"document"`
Permissions pm.Record `json:"permissions"`
Roles pm.DocumentRecord `json:"roles"`