-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
50 lines (40 loc) · 1.38 KB
/
init.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
42
43
44
45
46
47
48
49
50
package controllers
import (
"time"
"turm/app"
"turm/app/models"
"github.com/revel/revel"
)
//init initializes all interceptors.
func init() {
//initialize general interceptor
revel.InterceptFunc(general, revel.BEFORE, &revel.Controller{})
//prevent unauthorized actions
revel.InterceptMethod(Admin.auth, revel.BEFORE)
revel.InterceptMethod(App.auth, revel.BEFORE)
revel.InterceptMethod(Course.auth, revel.BEFORE)
revel.InterceptMethod(Creator.auth, revel.BEFORE)
revel.InterceptMethod(Edit.auth, revel.BEFORE)
revel.InterceptMethod(EditEvent.auth, revel.BEFORE)
revel.InterceptMethod(EditCalendarEvent.auth, revel.BEFORE)
revel.InterceptMethod(EditMeeting.auth, revel.BEFORE)
revel.InterceptMethod(Enrollment.auth, revel.BEFORE)
revel.InterceptMethod(Manage.auth, revel.BEFORE)
revel.InterceptMethod(Participants.auth, revel.BEFORE)
revel.InterceptMethod(User.auth, revel.BEFORE)
}
func getTimestamp(str string, c *revel.Controller, valid bool, fieldID string) (t time.Time, err error) {
if valid || fieldID != models.ColUnsubscribeEnd {
loc, err := time.LoadLocation(app.TimeZone)
if err != nil {
c.Log.Error("failed to load location", "appTimeZone", app.TimeZone,
"error", err.Error())
return t, err
}
t, err = time.ParseInLocation("2006-01-02 15:04", str, loc)
if err != nil {
c.Log.Error("invalid timestamp", "str", str, "error", err.Error())
}
}
return
}