♻️ Refactor output text to de_DE
This commit is contained in:
parent
e209036d1f
commit
4eeff41537
1 changed files with 20 additions and 8 deletions
|
@ -16,9 +16,9 @@ import json.tool
|
|||
|
||||
class Vote(Enum):
|
||||
"""Vote represents a vote by a voter."""
|
||||
YES = 0
|
||||
NO = 1
|
||||
ABSTENTION = 2
|
||||
JA = 0
|
||||
NEIN = 1
|
||||
ENTHALTUNG = 2
|
||||
|
||||
|
||||
class Voting(object):
|
||||
|
@ -51,6 +51,9 @@ class Voting(object):
|
|||
for voter in votes:
|
||||
self.votes[voter] = self.votes[voter] if isinstance(votes[voter], Vote) else Vote[votes[voter]]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return self.title
|
||||
|
||||
def is_over(self) -> bool:
|
||||
return Arrow.utcnow() >= arrow_get(self.start).shift(days=self.days)
|
||||
|
||||
|
@ -78,7 +81,7 @@ class Voting(object):
|
|||
f.write(self.dumps())
|
||||
|
||||
@classmethod
|
||||
def loads(cls, data: Dict) -> None:
|
||||
def loads(cls, data: str) -> None:
|
||||
return cls(**json.loads(data))
|
||||
|
||||
@classmethod
|
||||
|
@ -90,6 +93,15 @@ class Voting(object):
|
|||
class Result:
|
||||
voting: Voting
|
||||
|
||||
def __repr__(self):
|
||||
votes = self.votes()
|
||||
out = []
|
||||
if self.voting.quorum.kind != QuorumKind.NONE:
|
||||
out.append(f"QUORUM: {self.voting.quorum.value}{'%' if self.voting.quorum.kind == QuorumKind.PERCENT else ''}")
|
||||
out.append(f"GESAMT: {len(self.voting.votes)} => DAFUER: {votes[Vote.JA.name]} DAGEGEN: {votes[Vote.NEIN.name]} ENTHALTUNGEN: {votes[Vote.ENTHALTUNG.name]}")
|
||||
out.append(f"ERGEBNIS: {self.outcome()}")
|
||||
return '\n'.join(out)
|
||||
|
||||
@abc.abstractmethod
|
||||
def result(self) -> Dict:
|
||||
return {
|
||||
|
@ -104,7 +116,7 @@ class Result:
|
|||
if not self.has_ended():
|
||||
return "LAUFEND"
|
||||
else:
|
||||
return "ANGENOMMEN" if self.votes()[Vote.YES.name] > self.votes()[Vote.NO.name] and self.quorum_reached() else "ABGELEHNT"
|
||||
return "ANGENOMMEN" if self.votes()[Vote.JA.name] > self.votes()[Vote.NEIN.name] and self.quorum_reached() else "ABGELEHNT"
|
||||
|
||||
def has_ended(self) -> bool:
|
||||
end_at = arrow_get(self.voting.start).shift(days=self.voting.days)
|
||||
|
@ -112,9 +124,9 @@ class Result:
|
|||
|
||||
def votes(self) -> Dict:
|
||||
return {
|
||||
Vote.YES.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.YES]),
|
||||
Vote.NO.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.NO]),
|
||||
Vote.ABSTENTION.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.ABSTENTION]),
|
||||
Vote.JA.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.JA]),
|
||||
Vote.NEIN.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.NEIN]),
|
||||
Vote.ENTHALTUNG.name: len([vote for vote in self.voting.votes if self.voting.votes[vote] == Vote.ENTHALTUNG]),
|
||||
}
|
||||
|
||||
def quorum_reached(self) -> bool:
|
||||
|
|
Loading…
Reference in a new issue