Partialy add new motion creation
[cacert-boardvoting.git] / actions.go
1 package main
2
3 import (
4 "github.com/Masterminds/sprig"
5 "os"
6 "text/template"
7 )
8
9 func CreateMotion(decision *Decision, voter *Voter) (err error) {
10 decision.ProponentId = voter.Id
11 err = decision.Save()
12 if err != nil {
13 logger.Println("Error saving motion:", err)
14 return
15 }
16
17 // TODO: implement fetching new decision, implement mail
18 return
19 }
20
21 func WithdrawMotion(decision *Decision, voter *Voter) (err error) {
22 // load template, fill name, tag, title, content
23 type mailContext struct {
24 *Decision
25 Name string
26 Sender string
27 Recipient string
28 }
29 context := mailContext{decision, voter.Name, config.NoticeSenderAddress, config.BoardMailAddress}
30
31 // fill withdraw_mail.txt
32 t, err := template.New("withdraw_mail.txt").Funcs(
33 sprig.GenericFuncMap()).ParseFiles("templates/withdraw_mail.txt")
34 if err != nil {
35 logger.Fatal(err)
36 }
37 // TODO: send mail
38 t.Execute(os.Stdout, context)
39
40 // TODO: implement call decision.Close()
41 return
42 }