Skip to content

Is User Allowed Checker

Class used to check if poll is votable by the user.

IsUserAllowedChecker

Bases: abc.ABC

Source code in apps/votes_results/classes/vote/is_user_allowed_checker.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
class IsUserAllowedChecker(abc.ABC): 

    @abc.abstractmethod
    def is_user_allowed(self) -> bool: 
        """Check current user is allowed to access the poll"""
        pass

    @abc.abstractmethod
    def is_user_allowed_for_votemethod(self, votemethod: PollModel.PollType) -> bool: 
        """Check current user is allowed to submit 
        a vote with a certain votemethod"""
        pass

    @abc.abstractmethod
    def is_voted_so_but_not_mj(self) -> bool:
        """Check a poll is voted (by this user) w
        SO but not with MJ. It is used to handle 
        the special double vote case."""
        pass

    @abc.abstractmethod
    def mark_votemethod_as_used(self, votemethod: PollModel.PollType) -> None:
        """Save that a certain votemethod has been used 
        for current user/token."""
        pass 

is_user_allowed() abstractmethod

Check current user is allowed to access the poll

Source code in apps/votes_results/classes/vote/is_user_allowed_checker.py
12
13
14
15
@abc.abstractmethod
def is_user_allowed(self) -> bool: 
    """Check current user is allowed to access the poll"""
    pass

is_user_allowed_for_votemethod(votemethod) abstractmethod

Check current user is allowed to submit a vote with a certain votemethod

Source code in apps/votes_results/classes/vote/is_user_allowed_checker.py
17
18
19
20
21
@abc.abstractmethod
def is_user_allowed_for_votemethod(self, votemethod: PollModel.PollType) -> bool: 
    """Check current user is allowed to submit 
    a vote with a certain votemethod"""
    pass

is_voted_so_but_not_mj() abstractmethod

Check a poll is voted (by this user) w SO but not with MJ. It is used to handle the special double vote case.

Source code in apps/votes_results/classes/vote/is_user_allowed_checker.py
23
24
25
26
27
28
@abc.abstractmethod
def is_voted_so_but_not_mj(self) -> bool:
    """Check a poll is voted (by this user) w
    SO but not with MJ. It is used to handle 
    the special double vote case."""
    pass

mark_votemethod_as_used(votemethod) abstractmethod

Save that a certain votemethod has been used for current user/token.

Source code in apps/votes_results/classes/vote/is_user_allowed_checker.py
30
31
32
33
34
@abc.abstractmethod
def mark_votemethod_as_used(self, votemethod: PollModel.PollType) -> None:
    """Save that a certain votemethod has been used 
    for current user/token."""
    pass