<commit_before>from django import template
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from django.template import RequestContext
from compat import import_string

from hijack import settings as hijack_settings

register = template.Library()


# Deprecated. Use the template tag below
@register.filter
def hijackNotification(request):
    return _render_hijack_notification(request)


@register.simple_tag(takes_context=True)
def hijack_notification(context):
    request = context['request']
    return _render_hijack_notification(request)


def _render_hijack_notification(request):
    if hijack_settings.HIJACK_USE_BOOTSTRAP:
        template_name = 'hijack/notifications_bootstrap.html'
    else:
        template_name = 'hijack/notifications.html'
    ans = ''
    if (hijack_settings.HIJACK_DISPLAY_WARNING and
            request and
            request.session.get('is_hijacked_user', False) and
            request.session.get('display_hijack_warning', False)
        ):
        ans = render_to_string(template_name, {},
                               context_instance=RequestContext(request))
    return mark_safe(ans)


@register.filter
def can_hijack(hijacker, hijacked):<commit_msg>Prevent RemovedInDjango110Warning when using render_to_string<commit_after>from django import template
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from django.template import RequestContext
from compat import import_string

from hijack import settings as hijack_settings

register = template.Library()


# Deprecated. Use the template tag below
@register.filter
def hijackNotification(request):
    return _render_hijack_notification(request)


@register.simple_tag(takes_context=True)
def hijack_notification(context):
    request = context['request']
    return _render_hijack_notification(request)


def _render_hijack_notification(request):
    if hijack_settings.HIJACK_USE_BOOTSTRAP:
        template_name = 'hijack/notifications_bootstrap.html'
    else:
        template_name = 'hijack/notifications.html'
    ans = ''
    if all([
        hijack_settings.HIJACK_DISPLAY_WARNING,
        request,
        request.session.get('is_hijacked_user', False),
        request.session.get('display_hijack_warning', False),
    ]):
        ans = render_to_string(template_name, {request: request})
    return mark_safe(ans)


@register.filter
def can_hijack(hijacker, hijacked):
{'fraction_non_alphanumeric': 0.07456670697299476, 'fraction_numerical': 0.0012091898428053204, 'mean_word_length': 4.466960352422907, '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': '3726858', 'n_tokens_mistral': 730, 'n_tokens_neox': 719, 'n_words': 152}