Created
March 18, 2017 15:21
-
-
Save JosXa/8c00eb35b75ea0e2774710718e61e513 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _can_vote_again(user): | |
| """ | |
| :param user: User to check vote_timeout for | |
| :return: Tuple of (state, remaining_time) where state is a boolean | |
| """ | |
| if user.last_vote: | |
| delta = datetime.timedelta(seconds=const.VOTE_TIMEOUT) | |
| now = datetime.datetime.now() | |
| difference = now - user.last_vote | |
| to_wait = max((delta - difference).seconds, 1) | |
| if difference <= delta: | |
| return tuple([False, to_wait]) | |
| return tuple([True, None]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment