mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
#10608: Use register_model_view() for token views
This commit is contained in:
@ -1,16 +1,19 @@
|
||||
from django.urls import path
|
||||
from django.urls import include, path
|
||||
|
||||
from utilities.urls import get_model_urls
|
||||
from . import views
|
||||
|
||||
app_name = 'users'
|
||||
urlpatterns = [
|
||||
|
||||
# User
|
||||
path('profile/', views.ProfileView.as_view(), name='profile'),
|
||||
path('preferences/', views.UserConfigView.as_view(), name='preferences'),
|
||||
path('password/', views.ChangePasswordView.as_view(), name='change_password'),
|
||||
|
||||
# API tokens
|
||||
path('api-tokens/', views.TokenListView.as_view(), name='token_list'),
|
||||
path('api-tokens/add/', views.TokenEditView.as_view(), name='token_add'),
|
||||
path('api-tokens/<int:pk>/edit/', views.TokenEditView.as_view(), name='token_edit'),
|
||||
path('api-tokens/<int:pk>/delete/', views.TokenDeleteView.as_view(), name='token_delete'),
|
||||
path('api-tokens/<int:pk>/', include(get_model_urls('users', 'token'))),
|
||||
|
||||
]
|
||||
|
@ -20,6 +20,7 @@ from extras.tables import ObjectChangeTable
|
||||
from netbox.authentication import get_auth_backend_display, get_saml_idps
|
||||
from netbox.config import get_config
|
||||
from utilities.forms import ConfirmationForm
|
||||
from utilities.views import register_model_view
|
||||
from .forms import LoginForm, PasswordChangeForm, TokenForm, UserConfigForm
|
||||
from .models import Token, UserConfig
|
||||
from .tables import TokenTable
|
||||
@ -246,6 +247,7 @@ class TokenListView(LoginRequiredMixin, View):
|
||||
})
|
||||
|
||||
|
||||
@register_model_view(Token, 'edit')
|
||||
class TokenEditView(LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, pk=None):
|
||||
@ -300,6 +302,7 @@ class TokenEditView(LoginRequiredMixin, View):
|
||||
})
|
||||
|
||||
|
||||
@register_model_view(Token, 'delete')
|
||||
class TokenDeleteView(LoginRequiredMixin, View):
|
||||
|
||||
def get(self, request, pk):
|
||||
|
Reference in New Issue
Block a user