Source

trustlink / trustlink / django / templatetags / trustlink_tags.py

from django import template
from django.conf import settings

from trustlink.client import TrustlinkClient

register = template.Library()

@register.inclusion_tag('trustlink/link_block.html', takes_context=True)
def trustlink_links(context):
    request = context['request']
    url = 'http://%s%s' % (settings.TRUSTLINK_HOST, request.get_full_path())
    tl = TrustlinkClient(
        trustlink_user=settings.TRUSTLINK_USER,
        url=url,
        data_dir=settings.TRUSTLINK_DATA_DIR,
        test=settings.TRUSTLINK_TEST,
        request_headers=request.META,
        request_params=request.GET)
    context['trustlink'] = tl.build_links()
    return context