mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #9887: Inspect docs_url property to determine link to model documentation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from django.conf import settings
|
||||
from django.core.validators import ValidationError
|
||||
from django.db import models
|
||||
from mptt.models import MPTTModel, TreeForeignKey
|
||||
@@ -26,6 +27,10 @@ class NetBoxFeatureSet(
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@property
|
||||
def docs_url(self):
|
||||
return f'{settings.STATIC_URL}docs/models/{self._meta.app_label}/{self._meta.model_name}/'
|
||||
|
||||
@classmethod
|
||||
def get_prerequisite_models(cls):
|
||||
"""
|
||||
|
||||
@@ -37,9 +37,9 @@ Context:
|
||||
{% endif %}
|
||||
|
||||
{# Link to model documentation #}
|
||||
{% if object and settings.DOCS_ROOT %}
|
||||
{% if settings.DOCS_ROOT and object.docs_url %}
|
||||
<div class="float-end">
|
||||
<a href="{{ object|get_docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="View model documentation">
|
||||
<a href="{{ object.docs_url }}" target="_blank" class="btn btn-sm btn-outline-secondary" title="View model documentation">
|
||||
<i class="mdi mdi-help-circle"></i> Help
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -141,14 +141,6 @@ def percentage(x, y):
|
||||
return round(x / y * 100)
|
||||
|
||||
|
||||
@register.filter()
|
||||
def get_docs_url(model):
|
||||
"""
|
||||
Return the documentation URL for the specified model.
|
||||
"""
|
||||
return f'{settings.STATIC_URL}docs/models/{model._meta.app_label}/{model._meta.model_name}/'
|
||||
|
||||
|
||||
@register.filter()
|
||||
def has_perms(user, permissions_list):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user