mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-22 20:12:00 -06:00
Replace model_name and model_name_verbose filters with meta
This commit is contained in:
parent
16d3cebf3e
commit
15ab30d0c6
@ -53,7 +53,7 @@
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label required">Type</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static">{{ termination_a|model_name|capfirst }}</p>
|
||||
<p class="form-control-static">{{ termination_a|meta:"verbose_name"|capfirst }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@ -11,7 +11,7 @@
|
||||
<tr>
|
||||
<td>Type</td>
|
||||
<td>
|
||||
{{ termination|model_name|capfirst }}
|
||||
{{ termination|meta:"verbose_name"|capfirst }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -17,7 +17,7 @@
|
||||
<div class="panel-body text-center">
|
||||
{% if end.device %}
|
||||
{# Device component #}
|
||||
{% with model=end|model_name %}
|
||||
{% with model=end|meta:"verbose_name" %}
|
||||
<strong>{{ model|bettertitle }} {{ end }}</strong><br />
|
||||
{% if model == 'interface' %}
|
||||
{{ end.get_type_display }}
|
||||
|
@ -35,7 +35,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">{{ obj.interface.parent|model_name|bettertitle }}</label>
|
||||
<label class="col-md-3 control-label">{{ obj.interface.parent|meta:"verbose_name"|bettertitle }}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static">
|
||||
<a href="{{ obj.interface.parent.get_absolute_url }}">{{ obj.interface.parent }}</a>
|
||||
|
@ -15,7 +15,7 @@
|
||||
{% export_button content_type %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<h1>{% block title %}{{ content_type.model_class|model_name_plural|bettertitle }}{% endblock %}</h1>
|
||||
<h1>{% block title %}{{ content_type.model_class|meta:"verbose_name_plural"|bettertitle }}{% endblock %}</h1>
|
||||
<div class="row">
|
||||
<div class="col-md-{% if filter_form %}9{% else %}12{% endif %}">
|
||||
{% with bulk_edit_url=content_type.model_class|url_name:"bulk_edit" bulk_delete_url=content_type.model_class|url_name:"bulk_delete" %}
|
||||
|
@ -62,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()
|
||||
|
Loading…
Reference in New Issue
Block a user