Skip to content

Commit

Permalink
Merge pull request #806 from Go-Go-Farther/bugfix
Browse files Browse the repository at this point in the history
bugfix: 1. 用户管理,用户角色栏文本显示异常;2. 修复非book管理员且非评论作者,但是能删除评论的bug。
  • Loading branch information
gsw945 authored Jul 20, 2022
2 parents 83bca4a + 1b47f0c commit d5c5b62
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 2 additions & 0 deletions conf/enumerate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const (
BookEditor
//观察者
BookObserver
//未指定关系
BookRoleNoSpecific
)

//项目角色
Expand Down
4 changes: 0 additions & 4 deletions controllers/DocumentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ func (c *DocumentController) Index() {
// CheckPassword : Handles password verification for private documents,
// and front-end requests are made through Ajax.
func (c *DocumentController) CheckPassword() {
c.Prepare()

identify := c.Ctx.Input.Param(":key")
password := c.GetString("bPassword")

Expand Down Expand Up @@ -133,8 +131,6 @@ func (c *DocumentController) CheckPassword() {

// 阅读文档
func (c *DocumentController) Read() {
c.Prepare()

identify := c.Ctx.Input.Param(":key")
token := c.GetString("token")
id := c.GetString(":id")
Expand Down
8 changes: 5 additions & 3 deletions controllers/ManagerController.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ func (c *ManagerController) Index() {

// 用户列表.
func (c *ManagerController) Users() {
c.Prepare()
c.TplName = "manager/users.tpl"
c.Data["Action"] = "users"
pageIndex, _ := c.GetInt("page", 0)

members, totalCount, err := models.NewMember().FindToPager(pageIndex, conf.PageSize)
tempMember := models.NewMember()
tempMember.Lang = c.Lang
members, totalCount, err := tempMember.FindToPager(pageIndex, conf.PageSize)
if err != nil {
c.Data["ErrorMessage"] = err.Error()
return
Expand All @@ -78,7 +79,6 @@ func (c *ManagerController) Users() {

// 添加用户.
func (c *ManagerController) CreateMember() {
c.Prepare()

account := strings.TrimSpace(c.GetString("account"))
password1 := strings.TrimSpace(c.GetString("password1"))
Expand Down Expand Up @@ -120,6 +120,8 @@ func (c *ManagerController) CreateMember() {
member.CreateAt = c.Member.MemberId
member.Email = email
member.RealName = strings.TrimSpace(c.GetString("real_name", ""))
member.Lang = c.Lang

if phone != "" {
member.Phone = phone
}
Expand Down
11 changes: 6 additions & 5 deletions models/Member.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,11 @@ func (m *Member) Find(id int, cols ...string) (*Member, error) {

func (m *Member) ResolveRoleName() {
if m.Role == conf.MemberSuperRole {
m.RoleName = i18n.Tr(m.Lang, "common.administrator")
m.RoleName = i18n.Tr(m.Lang, "uc.super_admin")
} else if m.Role == conf.MemberAdminRole {
m.RoleName = i18n.Tr(m.Lang, "common.editor")
m.RoleName = i18n.Tr(m.Lang, "uc.admin")
} else if m.Role == conf.MemberGeneralRole {
m.RoleName = i18n.Tr(m.Lang, "common.obverser")
m.RoleName = i18n.Tr(m.Lang, "uc.user")
}
}

Expand Down Expand Up @@ -385,8 +385,9 @@ func (m *Member) FindToPager(pageIndex, pageSize int) ([]*Member, int, error) {
return members, 0, err
}

for _, m := range members {
m.ResolveRoleName()
for _, tm := range members {
tm.Lang = m.Lang
tm.ResolveRoleName()
}
return members, int(totalCount), nil
}
Expand Down
3 changes: 1 addition & 2 deletions models/Relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ func (m *Relationship) FindForRoleId(bookId, memberId int) (conf.BookRole, error
err := o.QueryTable(m.TableNameWithPrefix()).Filter("book_id", bookId).Filter("member_id", memberId).One(relationship)

if err != nil {

return 0, err
return conf.BookRoleNoSpecific, err
}
return relationship.RoleId, nil
}
Expand Down

0 comments on commit d5c5b62

Please sign in to comment.