-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
141 lines (100 loc) · 3.69 KB
/
app.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package controllers
import (
"turm/app/models"
"github.com/revel/revel"
)
/*Index renders the landing page of the application.
- Roles: all (except not activated users) */
func (c App) Index() revel.Result {
c.Log.Debug("render app index page", "url", c.Request.URL)
c.Session["callPath"] = c.Request.URL.String()
c.Session["currPath"] = c.Request.URL.String()
c.Session["lastURL"] = c.Request.URL.String()
c.ViewArgs["tab"] = c.Message("index.tab")
return c.Render()
}
/*Groups renders all groups and their children recursively.
- Roles: all (except not activated users) */
func (c App) Groups(prefix string) revel.Result {
c.Log.Debug("render groups", "prefix", prefix)
c.Session["lastURL"] = c.Request.URL.String()
//NOTE: no prefix validation, if this controller is called with an
//invalid prefix, then something else is going wrong
//TODO: why is Groups in upper case?
var Groups models.Groups
if err := Groups.Select(&prefix); err != nil {
return renderError(err, c.Controller)
}
return c.Render(Groups)
}
/*ChangeLanguage changes the language, then redirects to the page currently set as currPath.
- Roles: all */
func (c App) ChangeLanguage(language string) revel.Result {
c.Log.Debug("change language", "old language", c.Session["currentLocale"],
"language", language)
c.Session["lastURL"] = c.Request.URL.String()
c.Validation.Check(language,
models.LanguageValidator{},
).MessageKey("validation.invalid.language")
if c.Validation.HasErrors() {
return flashError(
errValidation, nil, "", c.Controller, "")
}
c.Session["currentLocale"] = language
c.ViewArgs["currentLocale"] = c.Session["currentLocale"]
c.Request.Locale = c.Session["currentLocale"].(string)
c.Flash.Success(c.Message("language.change.success",
language,
))
return c.Redirect(c.Session["currPath"])
}
/*DataPrivacy renders the data privacy page.
- Roles: all (except not activated users) */
func (c App) DataPrivacy() revel.Result {
c.Log.Debug("render data privacy page", "url", c.Request.URL)
c.Session["callPath"] = c.Request.URL.String()
c.Session["currPath"] = c.Request.URL.String()
c.Session["lastURL"] = c.Request.URL.String()
c.ViewArgs["tab"] = c.Message("data.privacy.tab")
return c.Render()
}
/*Imprint renders the imprint page.
- Roles: all (except not activated users) */
func (c App) Imprint() revel.Result {
c.Log.Debug("render imprint page", "url", c.Request.URL)
c.Session["callPath"] = c.Request.URL.String()
c.Session["currPath"] = c.Request.URL.String()
c.Session["lastURL"] = c.Request.URL.String()
c.ViewArgs["tab"] = c.Message("imprint.tab")
return c.Render()
}
/*News renders the news feed page.
- Roles: all (except not activated users) */
func (c App) News() revel.Result {
c.Log.Debug("render news feed page", "url", c.Request.URL)
c.Session["callPath"] = c.Request.URL.String()
c.Session["currPath"] = c.Request.URL.String()
c.Session["lastURL"] = c.Request.URL.String()
c.ViewArgs["tab"] = c.Message("news.feed.tab")
var categories models.Categories
if err := categories.Select(models.TableNewsFeedCategory); err != nil {
renderQuietError(errDB, err, c.Controller)
return c.Render()
}
return c.Render(categories)
}
/*FAQs renders the FAQs page.
- Roles: all (except not activated users) */
func (c App) FAQs() revel.Result {
c.Log.Debug("render FAQs page", "url", c.Request.URL)
c.Session["callPath"] = c.Request.URL.String()
c.Session["currPath"] = c.Request.URL.String()
c.Session["lastURL"] = c.Request.URL.String()
c.ViewArgs["tab"] = c.Message("faq.tab")
var categories models.Categories
if err := categories.Select(models.TableFAQCategory); err != nil {
renderQuietError(errDB, err, c.Controller)
return c.Render()
}
return c.Render(categories)
}