Skip to content

Commit

Permalink
#9887: Add missing model documentation links
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Nov 15, 2022
1 parent 4230162 commit 640fd80
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
5 changes: 5 additions & 0 deletions netbox/extras/models/configcontexts.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.core.validators import ValidationError
from django.db import models
from django.urls import reverse
Expand Down Expand Up @@ -116,6 +117,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:configcontext', kwargs={'pk': self.pk})

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/configcontext/'

def clean(self):
super().clean()

Expand Down
5 changes: 5 additions & 0 deletions netbox/extras/models/customfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import django_filters
from django import forms
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import ArrayField
from django.core.validators import RegexValidator, ValidationError
Expand Down Expand Up @@ -179,6 +180,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:customfield', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/customfield/'

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Expand Down
17 changes: 17 additions & 0 deletions netbox/extras/models/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import uuid

from django.conf import settings
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey
Expand Down Expand Up @@ -146,6 +147,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:webhook', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/webhook/'

def clean(self):
super().clean()

Expand Down Expand Up @@ -250,6 +255,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:customlink', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/customlink/'

def render(self, context):
"""
Render the CustomLink given the provided context, and return the text, link, and link_target.
Expand Down Expand Up @@ -311,6 +320,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:exporttemplate', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/exporttemplate/'

def clean(self):
super().clean()

Expand Down Expand Up @@ -403,6 +416,10 @@ def __str__(self):
def get_absolute_url(self):
return reverse('extras:savedfilter', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/savedfilter/'

def clean(self):
super().clean()

Expand Down
5 changes: 5 additions & 0 deletions netbox/extras/models/tags.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.db import models
from django.urls import reverse
from django.utils.text import slugify
Expand Down Expand Up @@ -31,6 +32,10 @@ class Meta:
def get_absolute_url(self):
return reverse('extras:tag', args=[self.pk])

@property
def docs_url(self):
return f'{settings.STATIC_URL}docs/models/extras/tag/'

def slugify(self, tag, i=None):
# Allow Unicode in Tag slugs (avoids empty slugs for Tags with all-Unicode names)
slug = slugify(tag, allow_unicode=True)
Expand Down

0 comments on commit 640fd80

Please sign in to comment.