summaryrefslogtreecommitdiff
path: root/models.go
diff options
context:
space:
mode:
authorJan Dittberner <jan@dittberner.info>2017-04-17 22:56:20 +0200
committerJan Dittberner <jan@dittberner.info>2017-04-22 00:12:24 +0200
commite0be1a6aa5fe580794e1f967f1417e3878d17321 (patch)
treedef1487e2e4adc2d369e2b19932e6eacee278fdd /models.go
parent6fe515ea52493ea79a07efe9e1fc652dea272e32 (diff)
downloadcacert-boardvoting-e0be1a6aa5fe580794e1f967f1417e3878d17321.tar.gz
cacert-boardvoting-e0be1a6aa5fe580794e1f967f1417e3878d17321.tar.xz
cacert-boardvoting-e0be1a6aa5fe580794e1f967f1417e3878d17321.zip
Switch to context API
Diffstat (limited to 'models.go')
-rw-r--r--models.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/models.go b/models.go
index fe6cd23..46d669e 100644
--- a/models.go
+++ b/models.go
@@ -25,7 +25,7 @@ FROM decisions
JOIN voters ON decisions.proponent=voters.id
WHERE decisions.tag=$1;`
sqlGetVoter = `
-SELECT voters.id, voters.name
+SELECT voters.id, voters.name, voters.enabled, voters.reminder
FROM voters
JOIN emails ON voters.id=emails.voter
WHERE emails.address=$1 AND voters.enabled=1`
@@ -139,15 +139,22 @@ func (v VoteChoice) String() string {
}
}
+const (
+ voteStatusDeclined = -1
+ voteStatusPending = 0
+ voteStatusApproved = 1
+ voteStatusWithdrawn = -2
+)
+
func (v VoteStatus) String() string {
switch v {
- case -1:
+ case voteStatusDeclined:
return "declined"
- case 0:
+ case voteStatusPending:
return "pending"
- case 1:
+ case voteStatusApproved:
return "approved"
- case -2:
+ case voteStatusWithdrawn:
return "withdrawn"
default:
return "unknown"
@@ -240,7 +247,7 @@ func FindVotersUnvotedDecisionsForDisplayOnPage(page int64, voter *Voter) (decis
}
defer decisionsStmt.Close()
- rows, err := decisionsStmt.Queryx(page - 1, voter.Id)
+ rows, err := decisionsStmt.Queryx(page-1, voter.Id)
if err != nil {
logger.Printf("Error loading motions for page %d: %v\n", page, err)
return