✨ Display votes in non-anonymous voting results
This commit is contained in:
parent
58cb8645a4
commit
f2f8265499
6 changed files with 42 additions and 5 deletions
|
|
@ -128,6 +128,10 @@ func (v Voting) Electors() []string {
|
|||
return electors
|
||||
}
|
||||
|
||||
func (v Voting) Anonymous() bool {
|
||||
return v.annonymous
|
||||
}
|
||||
|
||||
func (v Voting) IsOpen() bool {
|
||||
return v.deadline.After(time.Now().UTC())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,21 +6,24 @@ import (
|
|||
)
|
||||
|
||||
type Vote struct {
|
||||
Id string
|
||||
Elector string
|
||||
Choice Choice
|
||||
timestamp time.Time
|
||||
}
|
||||
|
||||
func NewVote(elector string, choice Choice) Vote {
|
||||
func NewVote(id, elector string, choice Choice) Vote {
|
||||
return Vote{
|
||||
Id: id,
|
||||
Elector: elector,
|
||||
Choice: choice,
|
||||
timestamp: time.Now().UTC(),
|
||||
}
|
||||
}
|
||||
|
||||
func NewVoteWithTimestamp(elector string, choice Choice, timestamp time.Time) Vote {
|
||||
func NewVoteWithTimestamp(id, elector string, choice Choice, timestamp time.Time) Vote {
|
||||
return Vote{
|
||||
Id: id,
|
||||
Elector: elector,
|
||||
Choice: choice,
|
||||
timestamp: timestamp,
|
||||
|
|
@ -28,5 +31,5 @@ func NewVoteWithTimestamp(elector string, choice Choice, timestamp time.Time) Vo
|
|||
}
|
||||
|
||||
func (vote Vote) String() string {
|
||||
return fmt.Sprintf("%s %s %s", vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector)
|
||||
return fmt.Sprintf("%s %s %s %s", vote.Id, vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue