-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.go
94 lines (71 loc) · 2.39 KB
/
manage.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
package controllers
import (
"turm/app/models"
"github.com/revel/revel"
)
/*Active renders the active courses page.
- Roles: creator, editors and instructors */
func (c Manage) Active() revel.Result {
c.Log.Debug("render active courses", "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("creator.tab")
//get the user
userID, err := getIntFromSession(c.Controller, "userID")
if err != nil {
renderQuietError(errTypeConv, err, c.Controller)
return c.Render()
}
creator := models.CourseList{}
editor, instructor, err := creator.Get(true, false, userID, c.Session["role"].(string))
if err != nil {
renderQuietError(errDB, err, c.Controller)
return c.Render()
}
return c.Render(creator, editor, instructor)
}
/*Drafts renders the drafts page.
- Roles: creator and editors */
func (c Manage) Drafts() revel.Result {
c.Log.Debug("render drafts 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("creator.tab")
//get the user
userID, err := getIntFromSession(c.Controller, "userID")
if err != nil {
renderQuietError(errTypeConv, err, c.Controller)
return c.Render()
}
creator := models.CourseList{}
editor, _, err := creator.Get(false, false, userID, c.Session["role"].(string))
if err != nil {
renderQuietError(errDB, err, c.Controller)
return c.Render()
}
return c.Render(creator, editor)
}
/*Expired renders the expired courses page.
- Roles: creator, editors and instructors */
func (c Manage) Expired() revel.Result {
c.Log.Debug("render expired courses", "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("creator.tab")
//get the user
userID, err := getIntFromSession(c.Controller, "userID")
if err != nil {
renderQuietError(errTypeConv, err, c.Controller)
return c.Render()
}
creator := models.CourseList{}
editor, instructor, err := creator.Get(true, true, userID, c.Session["role"].(string))
if err != nil {
renderQuietError(errDB, err, c.Controller)
return c.Render()
}
return c.Render(creator, editor, instructor)
}