from likes.signals import likes_enabled_test, can_vote_test
from likes.exceptions import LikesNotEnabledException, CannotVoteException

def _votes_enabled(obj):
    """See if voting is enabled on the class. Made complicated because
    secretballot.enable_voting_on takes parameters to set attribute names, so
    we can't safely check for eg. "add_vote" presence on obj. The safest bet is
    to check for the 'votes' attribute. 
    
    The correct approach is to contact the secretballot developers and ask them
    to set some unique marker on a class that can be voted on."""
    return hasattr(obj.__class__, 'votes')

def likes_enabled(obj, request):
    if not _votes_enabled(obj):
        return False, None
    try:
        likes_enabled_test.send(obj, request=request)
    except LikesNotEnabledException:
        return False
    return True

def can_vote(obj, user, request):
    if not _votes_enabled(obj):
        return False
    try:
        can_vote_test.send(obj, user=user, request=request)
    except CannotVoteException:
        return False
    return True

@@ -1,16 +1,54 @@
+from secretballot.models import Vote%0A%0A
 from likes.signa
@@ -970,24 +970,196 @@
 eturn False%0A
+%0A    # Common predicate%0A    if Vote.objects.filter(%0A        object_id=modelbase_obj.id, %0A        token=request.secretballot_token%0A    ).count() != 0:%0A        return False%0A%0A
     try:%0A   

Add common predicate for can_vote