mirror of
https://github.com/Xevion/contest-assistant.git
synced 2025-12-06 03:14:41 -06:00
Add new exception SelfVoteException for Submission.increment Implement new string representation built-in functions for all models
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
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'
|
|
|
|
|
|
class SelfVoteException(ContestException):
|
|
"""A user tried to vote on his own submission."""
|
|
|
|
def __repr__(self) -> str:
|
|
return 'You can\'t vote on your own submission. Please choose another post.'
|