forked from ZJGSU-Open-Source/GoOnlineJudge
/
contest.go
41 lines (35 loc) · 891 Bytes
/
contest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package controller
import (
"GoOnlineJudge/class"
"GoOnlineJudge/model"
"net/http"
"strings"
)
type ContestController struct {
class.Controller
Type string
}
func (this *ContestController) List(w http.ResponseWriter, r *http.Request) {
class.Logger.Debug("Contest List")
this.Init(w, r)
args := this.ParseURL(r.URL.String())
Type := args["type"]
CModel := model.ContestModel{}
conetestList, err := CModel.List(args)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
this.Data["Contest"] = conetestList
this.Data["Time"] = this.GetTime()
this.Data["Type"] = Type
this.Data["Title"] = strings.Title(Type) + " List"
this.Data["Is"+strings.Title(Type)] = true
this.Data["Privilege"] = this.Privilege
err = this.Execute(w, "view/layout.tpl", "view/contest_list.tpl")
if err != nil {
class.Logger.Debug(err)
http.Error(w, "tpl error", 500)
return
}
}