overhaul voting to support smart single voting protections and enforcing, new exceptions, vote clearing functions inside models, persistence updating

This commit is contained in:
Xevion
2021-02-16 07:27:02 -06:00
parent 0b8aaec332
commit 33ac0d7792
3 changed files with 137 additions and 30 deletions

View File

@@ -1,3 +1,32 @@
class FinishedPeriod(Exception):
"""A inactive period, or a period in it's final state cannot be advanced or further modified."""
class ContestException(Exception):
"""A exception directly related to the Contest Assistant bot."""
pass
class FinishedPeriodException(ContestException):
"""A inactive period, or a period in it's final state cannot be advanced or further modified."""
def __repr__(self) -> str:
return 'Period is inactive.'
class DatabaseDoubleVoteException(ContestException):
"""
The database was asked to increment a vote for a submission with a user ID that was already added.
Companion to `DatabaseNoVoteException`
"""
def __repr__(self) -> str:
return 'You can\'t vote for a submission twice.'
class DatabaseNoVoteException(ContestException):
"""
The database was asked to decrement a vote for a submission with a user ID that did not or no longer exists for the given submission.
Companion to `DatabaseDoubleVoteException`
"""
def __repr__(self) -> str:
return 'You can\'t remove a vote that never or no longer exists'