1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Initial work on #969: Custom links

This commit is contained in:
Jeremy Stretch
2019-04-15 17:12:41 -04:00
parent 20670c546d
commit 4536754b20
7 changed files with 179 additions and 1 deletions

View File

@@ -300,6 +300,53 @@ class CustomFieldChoice(models.Model):
CustomFieldValue.objects.filter(field__type=CF_TYPE_SELECT, serialized_value=str(pk)).delete()
#
# Custom links
#
class CustomLink(models.Model):
"""
A custom link to an external representation of a NetBox object. The link text and URL fields accept Jinja2 template
code to be rendered with an object as context.
"""
content_type = models.ForeignKey(
to=ContentType,
on_delete=models.CASCADE
)
name = models.CharField(
max_length=100,
unique=True
)
text = models.CharField(
max_length=200,
help_text="Template code for link text"
)
url = models.CharField(
max_length=200,
help_text="Template code for link URL"
)
weight = models.PositiveSmallIntegerField(
default=100
)
group_name = models.CharField(
max_length=50,
blank=True
)
button_class = models.CharField(
max_length=30,
choices=BUTTON_CLASS_CHOICES
)
new_window = models.BooleanField(
help_text="Force link to open in a new window"
)
class Meta:
ordering = ['group_name', 'weight', 'name']
def __str__(self):
return self.name
#
# Graphs
#