本文整理汇总了Golang中github.com/andrewcharlton/school-dashboard/env.Env.CurrentWeek方法的典型用法代码示例。如果您正苦于以下问题:Golang Env.CurrentWeek方法的具体用法?Golang Env.CurrentWeek怎么用?Golang Env.CurrentWeek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/andrewcharlton/school-dashboard/env.Env
的用法示例。
在下文中一共展示了Env.CurrentWeek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AttendanceExplorer
// AttendanceExplorer provides a page for exploring the attendance figures
// in more detail, and examine individual students.
func AttendanceExplorer(e env.Env) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if redir := checkRedirect(e, w, r, 2); redir {
return
}
header(e, w, r, 2)
defer footer(e, w, r)
f := getFilter(e, r)
g, err := e.GroupByFilter(f)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
week, _ := e.CurrentWeek()
data := struct {
Query template.URL
Week string
Group group.Group
}{
template.URL(r.URL.RawQuery),
week,
g,
}
err = e.Templates.ExecuteTemplate(w, "attendance.tmpl", data)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
}
}
}
示例2: AttendanceGroups
// AttendanceGroups produces a page with attendance summaries for the
// various student groups.
func AttendanceGroups(e env.Env) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if redir := checkRedirect(e, w, r, 0); redir {
return
}
header(e, w, r, 0)
defer footer(e, w, r)
f := getFilter(e, r)
g, err := e.GroupByFilter(f)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
return
}
type YearGroup struct {
Name string
Query template.URL
Groups []subGroup
Matrix subGroupMatrix
}
// Ignore error - will appear as blank string anyway
week, _ := e.CurrentWeek()
data := struct {
Week string
Query template.URL
YearGroups []YearGroup
}{
week,
template.URL(r.URL.RawQuery),
[]YearGroup{{"All Years", template.URL(""), subGroups(g), groupMatrix(g)}},
}
for year := 7; year < 15; year++ {
y := g.SubGroup(group.Year(year))
if len(y.Students) == 0 {
continue
}
yeargroup := YearGroup{fmt.Sprintf("Year %v", year),
template.URL(fmt.Sprintf("&year=%v", year)),
subGroups(y),
groupMatrix(y)}
data.YearGroups = append(data.YearGroups, yeargroup)
}
err = e.Templates.ExecuteTemplate(w, "attendancegroups.tmpl", data)
if err != nil {
fmt.Fprintf(w, "Error: %v", err)
}
}
}