diff --git a/netbox/templates/circuits/circuit.html b/netbox/templates/circuits/circuit.html index 07d3c360d..4d7fe9fe2 100644 --- a/netbox/templates/circuits/circuit.html +++ b/netbox/templates/circuits/circuit.html @@ -119,7 +119,7 @@
{% if circuit.comments %} - {{ circuit.comments|gfm }} + {{ circuit.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/circuits/provider.html b/netbox/templates/circuits/provider.html index 7472366c5..faeb516ee 100644 --- a/netbox/templates/circuits/provider.html +++ b/netbox/templates/circuits/provider.html @@ -88,11 +88,11 @@ NOC Contact - {{ provider.noc_contact|gfm|placeholder }} + {{ provider.noc_contact|render_markdown|placeholder }} Admin Contact - {{ provider.admin_contact|gfm|placeholder }} + {{ provider.admin_contact|render_markdown|placeholder }} Circuits @@ -110,7 +110,7 @@
{% if provider.comments %} - {{ provider.comments|gfm }} + {{ provider.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/dcim/cable_connect.html b/netbox/templates/dcim/cable_connect.html index aa4c4bf8c..3d9d06a1f 100644 --- a/netbox/templates/dcim/cable_connect.html +++ b/netbox/templates/dcim/cable_connect.html @@ -53,7 +53,7 @@
-

{{ termination_a|model_name|capfirst }}

+

{{ termination_a|meta:"verbose_name"|capfirst }}

diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 5ab28b409..c657e9fc5 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -325,7 +325,7 @@
{% if device.comments %} - {{ device.comments|gfm }} + {{ device.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/dcim/devicetype.html b/netbox/templates/dcim/devicetype.html index 292a31c89..352141a9a 100644 --- a/netbox/templates/dcim/devicetype.html +++ b/netbox/templates/dcim/devicetype.html @@ -149,7 +149,7 @@
{% if devicetype.comments %} - {{ devicetype.comments|gfm }} + {{ devicetype.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/dcim/inc/cable_termination.html b/netbox/templates/dcim/inc/cable_termination.html index 48af97a0b..0711ff121 100644 --- a/netbox/templates/dcim/inc/cable_termination.html +++ b/netbox/templates/dcim/inc/cable_termination.html @@ -11,7 +11,7 @@ Type - {{ termination|model_name|capfirst }} + {{ termination|meta:"verbose_name"|capfirst }} diff --git a/netbox/templates/dcim/inc/cable_trace_end.html b/netbox/templates/dcim/inc/cable_trace_end.html index 4eab4d1d7..6073c06ee 100644 --- a/netbox/templates/dcim/inc/cable_trace_end.html +++ b/netbox/templates/dcim/inc/cable_trace_end.html @@ -17,7 +17,7 @@
{% if end.device %} {# Device component #} - {% with model=end|model_name %} + {% with model=end|meta:"verbose_name" %} {{ model|bettertitle }} {{ end }}
{% if model == 'interface' %} {{ end.get_type_display }} diff --git a/netbox/templates/dcim/powerfeed.html b/netbox/templates/dcim/powerfeed.html index 316e0e5f0..ca717b5e1 100644 --- a/netbox/templates/dcim/powerfeed.html +++ b/netbox/templates/dcim/powerfeed.html @@ -158,7 +158,7 @@
{% if powerfeed.comments %} - {{ powerfeed.comments|gfm }} + {{ powerfeed.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/dcim/rack.html b/netbox/templates/dcim/rack.html index b43a4bfdf..99d9e4697 100644 --- a/netbox/templates/dcim/rack.html +++ b/netbox/templates/dcim/rack.html @@ -198,7 +198,7 @@
{% if rack.comments %} - {{ rack.comments|gfm }} + {{ rack.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/dcim/site.html b/netbox/templates/dcim/site.html index 5e26b9a22..9f842bf10 100644 --- a/netbox/templates/dcim/site.html +++ b/netbox/templates/dcim/site.html @@ -143,7 +143,7 @@ {% if site.physical_address %} @@ -206,7 +206,7 @@
{% if site.comments %} - {{ site.comments|gfm }} + {{ site.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/extras/script.html b/netbox/templates/extras/script.html index fc10db80f..6d7aca126 100644 --- a/netbox/templates/extras/script.html +++ b/netbox/templates/extras/script.html @@ -47,7 +47,7 @@ {{ forloop.counter }} {% log_level level %} - {{ message|gfm }} + {{ message|render_markdown }} {% empty %} diff --git a/netbox/templates/extras/tag.html b/netbox/templates/extras/tag.html index 2857d6188..64e5bbebd 100644 --- a/netbox/templates/extras/tag.html +++ b/netbox/templates/extras/tag.html @@ -90,7 +90,7 @@
{% if tag.comments %} - {{ tag.comments|gfm }} + {{ tag.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/ipam/ipaddress_edit.html b/netbox/templates/ipam/ipaddress_edit.html index e3f694fe3..d8902595a 100644 --- a/netbox/templates/ipam/ipaddress_edit.html +++ b/netbox/templates/ipam/ipaddress_edit.html @@ -35,7 +35,7 @@
- +

{{ obj.interface.parent }} diff --git a/netbox/templates/tenancy/tenant.html b/netbox/templates/tenancy/tenant.html index 9a1ed1be8..4ef26c451 100644 --- a/netbox/templates/tenancy/tenant.html +++ b/netbox/templates/tenancy/tenant.html @@ -87,7 +87,7 @@

{% if tenant.comments %} - {{ tenant.comments|gfm }} + {{ tenant.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/utilities/obj_list.html b/netbox/templates/utilities/obj_list.html index e917819c6..8f9a0563c 100644 --- a/netbox/templates/utilities/obj_list.html +++ b/netbox/templates/utilities/obj_list.html @@ -15,7 +15,7 @@ {% export_button content_type %} {% endif %}
-

{% block title %}{{ content_type.model_class|model_name_plural|bettertitle }}{% endblock %}

+

{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}

{% with bulk_edit_url=content_type.model_class|url_name:"bulk_edit" bulk_delete_url=content_type.model_class|url_name:"bulk_delete" %} diff --git a/netbox/templates/virtualization/cluster.html b/netbox/templates/virtualization/cluster.html index 92540fd70..4070977bc 100644 --- a/netbox/templates/virtualization/cluster.html +++ b/netbox/templates/virtualization/cluster.html @@ -115,7 +115,7 @@
{% if cluster.comments %} - {{ cluster.comments|gfm }} + {{ cluster.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index 8f3bb61d4..33dd8130a 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -152,7 +152,7 @@
{% if virtualmachine.comments %} - {{ virtualmachine.comments|gfm }} + {{ virtualmachine.comments|render_markdown }} {% else %} None {% endif %} diff --git a/netbox/utilities/templatetags/helpers.py b/netbox/utilities/templatetags/helpers.py index 5cede8a7e..618641a07 100644 --- a/netbox/utilities/templatetags/helpers.py +++ b/netbox/utilities/templatetags/helpers.py @@ -20,15 +20,6 @@ register = template.Library() # Filters # -@register.filter() -def oneline(value): - """ - Replace each line break with a single space - """ - value = value.replace('\r', '') - return value.replace('\n', ' ') - - @register.filter() def placeholder(value): """ @@ -40,25 +31,8 @@ def placeholder(value): return mark_safe(placeholder) -@register.filter() -def getlist(value, arg): - """ - Return all values of a QueryDict key - """ - return value.getlist(arg) - - -@register.filter -def getkey(value, key): - """ - Return a dictionary item specified by key - """ - return value[key] - - -# TODO: Rename this filter as py-gfm is no longer in use @register.filter(is_safe=True) -def gfm(value): +def render_markdown(value): """ Render text as Markdown """ @@ -88,19 +62,12 @@ def render_yaml(value): @register.filter() -def model_name(obj): +def meta(obj, attr): """ - Return the name of the model of the given object + Return the specified Meta attribute of a model. This is needed because Django does not permit templates + to access attributes which begin with an underscore (e.g. _meta). """ - return obj._meta.verbose_name - - -@register.filter() -def model_name_plural(obj): - """ - Return the plural name of the model of the given object - """ - return obj._meta.verbose_name_plural + return getattr(obj._meta, attr, '') @register.filter() @@ -118,14 +85,6 @@ def url_name(model, action): return None -@register.filter() -def contains(value, arg): - """ - Test whether a value contains any of a given set of strings. `arg` should be a comma-separated list of strings. - """ - return any(s in value for s in arg.split(',')) - - @register.filter() def bettertitle(value): """