mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-20 22:06:28 +00:00
template tag for translatable alerts with links
This commit is contained in:
@ -14,7 +14,8 @@
|
||||
|
||||
{% if part.variant_of %}
|
||||
<div class='alert alert-info alert-block'>
|
||||
{% trans "This part is a variant of" %} <strong><a href="{% url 'part-variants' part.variant_of.id %}">{{ part.variant_of.full_name }}</a></strong>
|
||||
{% object_link 'part-variants' part.variant_of.id part.variant_of.full_name as link %}
|
||||
{% blocktrans %}This part is a variant of {{ link }}{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
@ -4,6 +4,8 @@ over and above the built-in Django tags.
|
||||
import os
|
||||
|
||||
from django import template
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from InvenTree import version, settings
|
||||
|
||||
import InvenTree.helpers
|
||||
@ -164,3 +166,11 @@ def authorized_owners(group):
|
||||
pass
|
||||
|
||||
return owners
|
||||
|
||||
|
||||
@register.simple_tag()
|
||||
def object_link(url_name, pk, ref):
|
||||
""" Return highlighted link to object """
|
||||
|
||||
ref_url = reverse(url_name, kwargs={'pk': pk})
|
||||
return mark_safe('<b><a href="{}">{}</a></b>'.format(ref_url, ref))
|
||||
|
Reference in New Issue
Block a user