blob: fddbd864d7d6386f94b70817ed1367e226e3b01b (
plain)
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
|
// Used to show the landing page of the application
package requests
import (
"glsamaker/pkg/app/handler/authentication"
"glsamaker/pkg/app/handler/authentication/utils"
"glsamaker/pkg/database/connection"
"glsamaker/pkg/logger"
"glsamaker/pkg/models"
"net/http"
)
// Show renders a template to show the landing page of the application
func Show(w http.ResponseWriter, r *http.Request) {
user := utils.GetAuthenticatedUser(r)
if !user.Permissions.Glsa.View {
authentication.AccessDenied(w, r)
return
}
var requests []*models.Glsa
err := user.CanAccess(connection.DB.Model(&requests).
Where("type = ?", "request").
Relation("Bugs").
Relation("Creator").
Relation("Comments")).
Select()
if err != nil {
logger.Info.Println("Error during request selection")
logger.Info.Println(err)
http.NotFound(w, r)
return
}
for _, request := range requests {
request.ComputeStatus(user)
}
renderRequestsTemplate(w, user, requests)
}
|