-
Notifications
You must be signed in to change notification settings - Fork 1
/
premis_events_controller.go
51 lines (46 loc) · 1.4 KB
/
premis_events_controller.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
package webui
import (
"net/http"
"github.com/APTrust/registry/forms"
"github.com/APTrust/registry/pgmodels"
"github.com/gin-gonic/gin"
)
// PremisEventShowXHR returns the PREMIS event with the specified ID
// as an HTML fragment suitable for loading into a modal dialog or
// other existing HTML element. This does not return a full page with
// header and footer.
//
// GET /events/show_xhr/:id
func PremisEventShowXHR(c *gin.Context) {
req := NewRequest(c)
event, err := pgmodels.PremisEventViewByID(req.Auth.ResourceID)
if AbortIfError(c, err) {
return
}
req.TemplateData["event"] = event
req.TemplateData["showAsModal"] = true
c.HTML(http.StatusOK, "events/show.html", req.TemplateData)
}
// PremisEventIndex shows list of objects.
// GET /events
func PremisEventIndex(c *gin.Context) {
req := NewRequest(c)
template := "events/index.html"
var events []*pgmodels.PremisEventView
err := req.LoadResourceList(&events, "date_time", "desc", forms.NewPremisEventFilterForm)
if AbortIfError(c, err) {
return
}
c.HTML(http.StatusOK, template, req.TemplateData)
}
// PremisEventShow returns the object with the specified id.
// GET /events/show/:id
func PremisEventShow(c *gin.Context) {
req := NewRequest(c)
event, err := pgmodels.PremisEventViewByID(req.Auth.ResourceID)
req.TemplateData["event"] = event
if AbortIfError(c, err) {
return
}
c.HTML(http.StatusOK, "events/show.html", req.TemplateData)
}