-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_meeting.go
108 lines (84 loc) · 2.97 KB
/
edit_meeting.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
package controllers
import (
"strconv"
"turm/app/models"
"github.com/revel/revel"
)
/*Edit meeting.
- Roles: creator and editors of the course of the meeting */
func (c EditMeeting) Edit(ID int, meeting models.Meeting,
conf models.EditEMailConfig) revel.Result {
c.Log.Debug("change meeting", "ID", ID, "meeting", meeting,
"conf", conf)
c.Session["lastURL"] = c.Request.URL.String()
//NOTE: the interceptor assures that the meeting ID is valid
meeting.Validate(c.Validation)
if c.Validation.HasErrors() {
return flashError(
errValidation, nil, "/course/meetings?ID="+strconv.Itoa(meeting.EventID),
c.Controller, "")
}
conf.ID = meeting.EventID
conf.IsEvent = true
meeting.ID = ID
if err := meeting.Update(&conf); err != nil {
return flashError(
errDB, err, "/course/meetings?ID="+strconv.Itoa(meeting.EventID),
c.Controller, "")
}
//if the course is active, send notification e-mail
conf.Field = "email.edit.meeting"
if err := sendEMailsEdit(c.Controller, &conf); err != nil {
return flashError(errEMail, err, "", c.Controller, "")
}
c.Flash.Success(c.Message("meeting.update.success", meeting.ID))
return c.Redirect(Course.Meetings, meeting.EventID)
}
/*Delete meeting.
- Roles: creator and editors of the course of the meeting */
func (c EditMeeting) Delete(ID, eventID int,
conf models.EditEMailConfig) revel.Result {
c.Log.Debug("delete meeting", "ID", ID, "eventID", eventID,
"conf", conf)
c.Session["lastURL"] = c.Request.URL.String()
//NOTE: the interceptor assures that the event ID is valid
conf.ID = eventID
conf.IsEvent = true
meeting := models.Meeting{ID: ID}
if err := meeting.Delete(&conf); err != nil {
return flashError(
errDB, err, "/course/meetings?ID="+strconv.Itoa(eventID),
c.Controller, "")
}
//if the course is active, send notification e-mail
conf.Field = "email.edit.meeting"
if err := sendEMailsEdit(c.Controller, &conf); err != nil {
return flashError(errEMail, err, "", c.Controller, "")
}
c.Flash.Success(c.Message("meeting.delete.success", ID))
return c.Redirect(Course.Meetings, eventID)
}
/*Duplicate meeting.
- Roles: creator and editors of the course of the meeting */
func (c EditMeeting) Duplicate(ID, eventID int,
conf models.EditEMailConfig) revel.Result {
c.Log.Debug("duplicate meeting", "ID", ID, "eventID", eventID,
"conf", conf)
c.Session["lastURL"] = c.Request.URL.String()
//NOTE: the interceptor assures that the event ID is valid
conf.ID = eventID
conf.IsEvent = true
meeting := models.Meeting{ID: ID, EventID: eventID}
if err := meeting.Duplicate(&conf); err != nil {
return flashError(
errDB, err, "/course/meetings?ID="+strconv.Itoa(eventID),
c.Controller, "")
}
//if the course is active, send notification e-mail
conf.Field = "email.edit.meeting"
if err := sendEMailsEdit(c.Controller, &conf); err != nil {
return flashError(errEMail, err, "", c.Controller, "")
}
c.Flash.Success(c.Message("meeting.duplicate.success", ID))
return c.Redirect(Course.Meetings, eventID)
}