Example #1
0
// To-do: Show programs solved by the user
func (this *UserController) Show() {
	if this.Ctx.Input.Param("0") == "" {
		this.Abort("404")
	}
	user := models.User{Username: this.Ctx.Input.Param("0")}
	if user.GetByUsername() {
		this.Data["title"] = user.Username
		this.Data["userDetails"] = user

		log := models.Problemlogs{Uid: user.Uid}
		logs, count := log.GetByUid()
		problems := make(map[int]models.Problem)
		if count == 0 {
			this.Data["solvedProblemsExist"] = false
		} else {
			this.Data["solvedProblemsExist"] = true
			for index, element := range logs {
				p := models.Problem{Pid: element.Pid}
				p.GetByPid()
				problems[index] = p
			}
		}

		this.Data["solvedProblems"] = problems

		this.Layout = "layout.tpl"
		this.TplNames = "user/show.tpl"
		this.LayoutSections = make(map[string]string)
		this.LayoutSections["HtmlHead"] = ""
		this.LayoutSections["Sidebar"] = ""
	} else {
		this.Abort("404")
	}
}