实现项目和文档锁定功能

This commit is contained in:
Minho
2018-04-09 17:30:38 +08:00
parent de5f7301f0
commit 92d9bc202a
3 changed files with 21 additions and 10 deletions

View File

@@ -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, "保存失败")

View File

@@ -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"

View File

@@ -162,6 +162,14 @@
</div>
</div>
</div>
<div class="form-group">
<label for="autoRelease">锁定项目</label>
<div class="controls">
<div class="switch switch-small" data-on="primary" data-off="info">
<input type="checkbox" id="isLock" name="is_lock"{{if .Model.IsLock }} checked{{end}} data-size="small" placeholder="锁定项目">
</div>
</div>
</div>
<div class="form-group">
<button type="submit" id="btnSaveBookInfo" class="btn btn-success" data-loading-text="保存中...">保存修改</button>
<span id="form-error-message" class="error-message"></span>
@@ -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],