Beispiel #1
0
func (this *UserRouter) getUser(user *models.User) bool {
	username := this.Params().Get(":username")
	user.UserName = username

	u, err := models.GetUserByName(username)
	if err != nil {
		this.NotFound()
		return true
	}
	*user = *u

	IsFollowed := false

	if this.IsLogin {
		if this.User.Id != user.Id {
			IsFollowed = models.IsExist(&models.Follow{
				UserId:       this.User.Id,
				FollowUserId: user.Id,
			})
		}
	}

	this.Data["TheUser"] = &user
	this.Data["IsFollowed"] = IsFollowed

	return false
}
Beispiel #2
0
func (form *PageAdminForm) Valid(v *validation.Validation) {
	if models.IsExist(&models.User{Id: int64(form.User)}) {
		v.SetError("User", "admin.not_found_by_id")
	}
}