<commit_before>from django import template

from django.contrib.contenttypes.models import ContentType

from anafero.models import ReferralResponse, ACTION_DISPLAY


register = template.Library()


@register.inclusion_tag("anafero/_create_referral_form.html")
def create_referral(url, obj=None):
    if obj:
        return {"url": url, "obj": obj, "obj_ct": ContentType.objects.get_for_model(obj)}
    else:
        return {"url": url, "obj": "", "obj_ct": ""}


@register.assignment_tag
def referral_responses(user):
    return ReferralResponse.objects.filter(
        referral__user=user
    ).order_by("-created_at")


@register.filter
def action_display(value):
    return ACTION_DISPLAY.get(value, value)
<commit_msg>Add full context to the create_referral tag<commit_after>from django import template

from django.contrib.contenttypes.models import ContentType

from anafero.models import ReferralResponse, ACTION_DISPLAY


register = template.Library()


@register.inclusion_tag("anafero/_create_referral_form.html", takes_context=True)
def create_referral(context, url, obj=None):
    if obj:
        context.update(
            {"url": url, "obj": obj, "obj_ct": ContentType.objects.get_for_model(obj)}
        )
    else:
        context.update(
            {"url": url, "obj": "", "obj_ct": ""}
        )
    return context


@register.assignment_tag
def referral_responses(user):
    return ReferralResponse.objects.filter(
        referral__user=user
    ).order_by("-created_at")


@register.filter
def action_display(value):
    return ACTION_DISPLAY.get(value, value)

{'fraction_non_alphanumeric': 0.11426767676767677, 'fraction_numerical': 0.0, 'mean_word_length': 4.26578073089701, 'pattern_counts': {'":': 12, '<': 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': '6327303', 'n_tokens_mistral': 496, 'n_tokens_neox': 485, 'n_words': 104}