From da13fa55694eaaaf2a99069815afc0b24bc19c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markku=20Leini=C3=B6?= Date: Thu, 4 Apr 2024 19:17:57 +0300 Subject: [PATCH] Closes #15039: Add Clone button in API token --- netbox/users/models.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/netbox/users/models.py b/netbox/users/models.py index 52ce55e6c..160f49ac4 100644 --- a/netbox/users/models.py +++ b/netbox/users/models.py @@ -17,6 +17,7 @@ from netaddr import IPNetwork from core.models import ContentType from ipam.fields import IPNetworkField from netbox.config import get_config +from netbox.models.features import CloningMixin from utilities.querysets import RestrictedQuerySet from utilities.utils import flatten_dict from .constants import * @@ -234,7 +235,7 @@ def create_userconfig(instance, created, raw=False, **kwargs): # REST API # -class Token(models.Model): +class Token(CloningMixin, models.Model): """ An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens. It also supports setting an expiration time and toggling write ability. @@ -285,6 +286,10 @@ class Token(models.Model): ), ) + clone_fields = ( + 'user', 'expires', 'write_enabled', 'description', 'allowed_ips', + ) + objects = RestrictedQuerySet.as_manager() class Meta: