Skip to content

Commit

Permalink
Merge pull request #172 from philippeowagner/master
Browse files Browse the repository at this point in the history
Jinja support and modified _render_hijack_notification.
  • Loading branch information
philippeowagner committed May 26, 2018
2 parents 01b9c72 + 9549938 commit 2e3ff48
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions hijack/templatetags/hijack_tags.py
Expand Up @@ -3,12 +3,12 @@
from django.utils.safestring import mark_safe
from django.template.loader import render_to_string
from compat import import_string

from hijack import settings as hijack_settings

register = template.Library()



@register.filter
def hijackNotification(request):
"""
Expand All @@ -23,11 +23,12 @@ def hijack_notification(context):
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'
def _render_hijack_notification(request, template_name=None):
if template_name is None:
if hijack_settings.HIJACK_USE_BOOTSTRAP:
template_name = 'hijack/notifications_bootstrap.html'
else:
template_name = 'hijack/notifications.html'
ans = ''
if request is not None and all([
hijack_settings.HIJACK_DISPLAY_WARNING,
Expand All @@ -51,3 +52,11 @@ def can_hijack(hijacker, hijacked):
@register.filter
def is_hijacked(request):
return request.session.get('is_hijacked_user', False)

try:
from django_jinja import library
@library.filter
def jinja_hijack_notification(request, template_name=None):
return _render_hijack_notification(request, template_name)
except ImportError:
pass

0 comments on commit 2e3ff48

Please sign in to comment.