<commit_before>from django import template

from invitations.forms import InviteForm


register = template.Library()


class RemainingInvitesNode(template.Node):
    
    @classmethod
    def handle_token(cls, parser, token):
        bits = token.split_contents()
        if len(bits) != 2:
            raise template.TemplateSyntaxError
        
        return cls(
            user = parser.compile_filter(bits[1])
        )
    
    def __init__(self, user):
        self.user = user
    
    def render(self, context):
        user = self.user.resolve(context)
        return user.invitationstat.invites_remaining()


@register.tag
def remaining_invites(parser, token):
    """
    Usage::
        {% remaining_invites user %}
    
    Returns an integer that is the # of remaining invites the user has.
    """
    return RemainingInvitesNode.handle_token(parser, token)


@register.inclusion_tag("invitations/_invite_form.html")
def invite_form(user):
    return {"form": InviteForm(), "user": user}


@register.inclusion_tag("invitations/_invited.html")
def invites_sent(user):
    return {"invited_list": user.invites_sent.all()}


@register.filter
def status_class(invite):
    if invite.status == invite.STATUS_SENT:
        return "sent"
    elif invite.status == invite.STATUS_ACCEPTED:
        return "accepted"
    elif invite.status == invite.STATUS_JOINED:
        return "joined"
    return ""<commit_msg>fixed bug<commit_after>from django import template

from invitations.forms import InviteForm


register = template.Library()


class RemainingInvitesNode(template.Node):
    
    @classmethod
    def handle_token(cls, parser, token):
        bits = token.split_contents()
        if len(bits) != 2:
            raise template.TemplateSyntaxError
        
        return cls(
            user = parser.compile_filter(bits[1])
        )
    
    def __init__(self, user):
        self.user = user
    
    def render(self, context):
        user = self.user.resolve(context)
        return user.invitationstat.invites_remaining()


@register.tag
def remaining_invites(parser, token):
    """
    Usage::
        {% remaining_invites user %}
    
    Returns an integer that is the # of remaining invites the user has.
    """
    return RemainingInvitesNode.handle_token(parser, token)


@register.inclusion_tag("invitations/_invite_form.html")
def invite_form(user):
    return {"form": InviteForm(), "user": user}


@register.inclusion_tag("invitations/_invited.html")
def invites_sent(user):
    return {"invited_list": user.invites_sent.all()}


@register.filter
def status_class(invite):
    if invite.status == invite.STATUS_SENT:
        return "sent"
    elif invite.status == invite.STATUS_ACCEPTED:
        return "accepted"
    elif invite.status == invite.STATUS_JOINED_INDEPENDENTLY:
        return "joined"
    return ""
{'fraction_non_alphanumeric': 0.10441485634197617, 'fraction_numerical': 0.001401541695865452, 'mean_word_length': 3.0324858757062145, 'pattern_counts': {'":': 6, '<': 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': '518246', 'n_tokens_mistral': 860, 'n_tokens_neox': 839, 'n_words': 191}