summaryrefslogtreecommitdiff
path: root/actions.go
diff options
context:
space:
mode:
Diffstat (limited to 'actions.go')
-rw-r--r--actions.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/actions.go b/actions.go
index f41e1ff..0619587 100644
--- a/actions.go
+++ b/actions.go
@@ -1,11 +1,46 @@
package main
import (
+ "fmt"
"github.com/Masterminds/sprig"
"os"
"text/template"
)
+func CreateMotion(decision *Decision, voter *Voter) (err error) {
+ decision.ProponentId = voter.Id
+ err = decision.Save()
+ if err != nil {
+ logger.Println("Error saving motion:", err)
+ return
+ }
+
+ type mailContext struct {
+ Decision
+ Name string
+ Sender string
+ Recipient string
+ VoteURL string
+ UnvotedURL string
+ }
+ voteURL := fmt.Sprintf("%s/vote", config.BaseURL)
+ unvotedURL := fmt.Sprintf("%s/motions/?unvoted=1", config.BaseURL)
+ context := mailContext{
+ *decision, voter.Name, config.NoticeSenderAddress,
+ config.BoardMailAddress, voteURL,
+ unvotedURL}
+
+ t, err := template.New("create_motion_mail.txt").Funcs(
+ sprig.GenericFuncMap()).ParseFiles("templates/create_motion_mail.txt")
+ if err != nil {
+ logger.Fatal(err)
+ }
+ t.Execute(os.Stdout, context)
+
+ // TODO: implement mail sending
+ return
+}
+
func WithdrawMotion(decision *Decision, voter *Voter) (err error) {
// load template, fill name, tag, title, content
type mailContext struct {