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

Closes #15039: Add Clone button in API token

This commit is contained in:
Markku Leiniö
2024-04-04 19:17:57 +03:00
committed by Jeremy Stretch
parent 5b50920c61
commit da13fa5569

View File

@ -17,6 +17,7 @@ from netaddr import IPNetwork
from core.models import ContentType from core.models import ContentType
from ipam.fields import IPNetworkField from ipam.fields import IPNetworkField
from netbox.config import get_config from netbox.config import get_config
from netbox.models.features import CloningMixin
from utilities.querysets import RestrictedQuerySet from utilities.querysets import RestrictedQuerySet
from utilities.utils import flatten_dict from utilities.utils import flatten_dict
from .constants import * from .constants import *
@ -234,7 +235,7 @@ def create_userconfig(instance, created, raw=False, **kwargs):
# REST API # 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. 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. 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() objects = RestrictedQuerySet.as_manager()
class Meta: class Meta: