<commit_before>import adhocracy.model as model

from decision import Decision
from delegation_node import DelegationNode
from state import State

from ..cache import memoize

# RFACT: try to move all functionality out of here
def is_comment_mutable(comment):
    """
    Find out whether a comment is a canonical contribution to a proposal 
    that is currently polling.
    """
    if not comment.canonical:
        return True
    if isinstance(comment.topic, model.Proposal):
        return State(comment.topic).proposal_mutable
    return True

def is_proposal_mutable(proposal):
    return State(proposal).proposal_mutable

@memoize('number_of_votes')
def number_of_votes(user, topic):
    return DelegationNode(user, topic).number_of_votes()<commit_msg>[svn r553] using the number_of_votes api on user instead of the delegation node directly<commit_after>import adhocracy.model as model

from decision import Decision
from delegation_node import DelegationNode
from state import State

from ..cache import memoize

# RFACT: try to move all functionality out of here
def is_comment_mutable(comment):
    """
    Find out whether a comment is a canonical contribution to a proposal 
    that is currently polling.
    """
    if not comment.canonical:
        return True
    if isinstance(comment.topic, model.Proposal):
        return State(comment.topic).proposal_mutable
    return True

def is_proposal_mutable(proposal):
    return State(proposal).proposal_mutable

@memoize('number_of_votes')
def number_of_votes(user, topic):
    return user.number_of_votes_in_scope(topic)
{'fraction_non_alphanumeric': 0.06368221941992434, 'fraction_numerical': 0.0018915510718789407, 'mean_word_length': 4.379661016949153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '802152', 'n_tokens_mistral': 459, 'n_tokens_neox': 450, 'n_words': 151}