diff --git a/controllers/BookController.go b/controllers/BookController.go index 690c859b..092e6e16 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -144,6 +144,7 @@ func (c *BookController) SaveBook() { isDownload := strings.TrimSpace(c.GetString("is_download")) == "on" enableShare := strings.TrimSpace(c.GetString("enable_share")) == "on" isUseFirstDocument := strings.TrimSpace(c.GetString("is_use_first_document")) == "on" + isLock := strings.TrimSpace(c.GetString("is_lock")) == "on" if strings.Count(description, "") > 500 { c.JsonResult(6004, "项目描述不能大于500字") @@ -169,26 +170,25 @@ func (c *BookController) SaveBook() { book.Editor = editor book.HistoryCount = historyCount book.IsDownload = 0 + book.IsLock = 0 + book.IsUseFirstDocument = 0 + book.IsEnableShare = 1 + book.AutoRelease = 0 if autoRelease { book.AutoRelease = 1 - } else { - book.AutoRelease = 0 } - if isDownload { - book.IsDownload = 0 - } else { + if !isDownload { book.IsDownload = 1 } if enableShare { book.IsEnableShare = 0 - } else { - book.IsEnableShare = 1 } if isUseFirstDocument { book.IsUseFirstDocument = 1 - } else { - book.IsUseFirstDocument = 0 + } + if isLock { + book.IsLock = 1 } if err := book.Update(); err != nil { c.JsonResult(6006, "保存失败") diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 338d3b11..3a911451 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -237,6 +237,9 @@ func (c *DocumentController) Edit() { } } + if bookResult.IsLock { + c.ShowErrorPage(403,"已锁定的项目无法编辑") + } // 根据不同编辑器类型加载编辑器 if bookResult.Editor == "markdown" { c.TplName = "document/markdown_edit_template.tpl" diff --git a/views/book/setting.tpl b/views/book/setting.tpl index 162977b2..9933f557 100644 --- a/views/book/setting.tpl +++ b/views/book/setting.tpl @@ -162,6 +162,14 @@ +
+ +
+
+ +
+
+
@@ -325,7 +333,7 @@ }).on("show.bs.modal",function () { window.modalHtml = $("#upload-logo-panel").find(".modal-body").html(); }); - $("#autoRelease,#enableShare,#isDownload,#is_use_first_document").bootstrapSwitch(); + $("#autoRelease,#enableShare,#isDownload,#is_use_first_document,#isLock").bootstrapSwitch(); $('input[name="label"]').tagsinput({ confirmKeys: [13,44],