diff --git a/conf/enumerate.go b/conf/enumerate.go index 2fe406a2..507f564a 100644 --- a/conf/enumerate.go +++ b/conf/enumerate.go @@ -47,6 +47,8 @@ const ( BookEditor //观察者 BookObserver + //未指定关系 + BookRoleNoSpecific ) //项目角色 diff --git a/controllers/DocumentController.go b/controllers/DocumentController.go index 7a99a833..6339b5a9 100644 --- a/controllers/DocumentController.go +++ b/controllers/DocumentController.go @@ -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") @@ -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") diff --git a/controllers/ManagerController.go b/controllers/ManagerController.go index 8984031b..dea3e507 100644 --- a/controllers/ManagerController.go +++ b/controllers/ManagerController.go @@ -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 @@ -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")) @@ -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 } diff --git a/models/Member.go b/models/Member.go index 7cd8e7c8..49916e24 100644 --- a/models/Member.go +++ b/models/Member.go @@ -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") } } @@ -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 } diff --git a/models/Relationship.go b/models/Relationship.go index e78b8a8c..7f9fe801 100644 --- a/models/Relationship.go +++ b/models/Relationship.go @@ -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 }