Implement proper model, actions and template structure
[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 WithdrawMotion(decision *Decision, voter *Voter) (err error) {
10 // load template, fill name, tag, title, content
11 type mailContext struct {
12 *Decision
13 Name string
14 Sender string
15 Recipient string
16 }
17 context := mailContext{decision, voter.Name, config.NoticeSenderAddress, config.BoardMailAddress}
18
19 // fill withdraw_mail.txt
20 t, err := template.New("withdraw_mail.txt").Funcs(
21 sprig.GenericFuncMap()).ParseFiles("templates/withdraw_mail.txt")
22 if err != nil {
23 logger.Fatal(err)
24 }
25 // TODO: send mail
26 t.Execute(os.Stdout, context)
27
28 // TODO: implement call decision.Close()
29 return
30 }