Skip to content

Commit da13fa5

Browse files
markkuleiniojeremystretch
authored andcommitted
Closes #15039: Add Clone button in API token
1 parent 5b50920 commit da13fa5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

netbox/users/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from core.models import ContentType
1818
from ipam.fields import IPNetworkField
1919
from netbox.config import get_config
20+
from netbox.models.features import CloningMixin
2021
from utilities.querysets import RestrictedQuerySet
2122
from utilities.utils import flatten_dict
2223
from .constants import *
@@ -234,7 +235,7 @@ def create_userconfig(instance, created, raw=False, **kwargs):
234235
# REST API
235236
#
236237

237-
class Token(models.Model):
238+
class Token(CloningMixin, models.Model):
238239
"""
239240
An API token used for user authentication. This extends the stock model to allow each user to have multiple tokens.
240241
It also supports setting an expiration time and toggling write ability.
@@ -285,6 +286,10 @@ class Token(models.Model):
285286
),
286287
)
287288

289+
clone_fields = (
290+
'user', 'expires', 'write_enabled', 'description', 'allowed_ips',
291+
)
292+
288293
objects = RestrictedQuerySet.as_manager()
289294

290295
class Meta:

0 commit comments

Comments
 (0)