Skip to content

Commit

Permalink
Merge pull request #271 from smk4664/next-2.0
Browse files Browse the repository at this point in the history
Add NotesView to URLs.
  • Loading branch information
smk4664 authored Sep 28, 2023
2 parents 9949928 + 52bafc2 commit b92cf7f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
1 change: 1 addition & 0 deletions changes/272.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ObjectNotesView for ChatOps models.
8 changes: 4 additions & 4 deletions nautobot_chatops/api/views/generic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""API Views for Nautobot Chatops."""
from rest_framework.routers import APIRootView
from nautobot.core.api.views import ModelViewSet
from nautobot.apps.api import NautobotModelViewSet

from nautobot_chatops.api.serializers import AccessGrantSerializer, CommandLogSerializer, CommandTokenSerializer
from nautobot_chatops.models import AccessGrant, CommandToken, CommandLog
Expand All @@ -15,23 +15,23 @@ def get_view_name(self):
return "Nautobot Chatops"


class CommandTokenViewSet(ModelViewSet): # pylint: disable=too-many-ancestors
class CommandTokenViewSet(NautobotModelViewSet): # pylint: disable=too-many-ancestors
"""API viewset for interacting with CommandToken objects."""

queryset = CommandToken.objects.all()
serializer_class = CommandTokenSerializer
filterset_class = CommandTokenFilterSet


class CommandLogViewSet(ModelViewSet):
class CommandLogViewSet(NautobotModelViewSet):
"""API viewset for interacting with CommandLog objects."""

queryset = CommandLog.objects.all()
serializer_class = CommandLogSerializer
filterset_class = CommandLogFilterSet


class AccessGrantViewSet(ModelViewSet): # pylint: disable=too-many-ancestors
class AccessGrantViewSet(NautobotModelViewSet): # pylint: disable=too-many-ancestors
"""API viewset for interacting with AccessGrant objects."""

queryset = AccessGrant.objects.all()
Expand Down
34 changes: 32 additions & 2 deletions nautobot_chatops/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from django.conf import settings
from django.urls import path

from nautobot.extras.views import ObjectChangeLogView
from nautobot.extras.views import ObjectChangeLogView, ObjectNotesView

from nautobot_chatops.models import AccessGrant, ChatOpsAccountLink, CommandToken
from nautobot_chatops.models import AccessGrant, ChatOpsAccountLink, CommandLog, CommandToken
from nautobot_chatops.views import (
CommandTokenBulkDeleteView,
CommandTokenCreateView,
Expand Down Expand Up @@ -38,13 +38,31 @@

urlpatterns = [
path("", CommandLogListView.as_view(), name="commandlog_list"),
path(
"commandlog/<uuid:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="commandlog_changelog",
kwargs={"model": CommandLog},
),
path(
"commandlog/<uuid:pk>/notes/",
ObjectNotesView.as_view(),
name="commandlog_notes",
kwargs={"model": CommandLog},
),
path("access/", AccessGrantListView.as_view(), name="accessgrant_list"),
path(
"access/<uuid:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="accessgrant_changelog",
kwargs={"model": AccessGrant},
),
path(
"access/<uuid:pk>/notes/",
ObjectNotesView.as_view(),
name="accessgrant_notes",
kwargs={"model": AccessGrant},
),
path("access/<uuid:pk>/edit/", AccessGrantView.as_view(), name="accessgrant_edit"),
path("access/add/", AccessGrantCreateView.as_view(), name="accessgrant_add"),
path("access/delete/", AccessGrantBulkDeleteView.as_view(), name="accessgrant_bulk_delete"),
Expand All @@ -55,6 +73,12 @@
name="commandtoken_changelog",
kwargs={"model": CommandToken},
),
path(
"tokens/<uuid:pk>/notes/",
ObjectNotesView.as_view(),
name="commandtoken_notes",
kwargs={"model": CommandToken},
),
path("tokens/<uuid:pk>/edit/", CommandTokenView.as_view(), name="commandtoken_edit"),
path("tokens/add/", CommandTokenCreateView.as_view(), name="commandtoken_add"),
path("tokens/delete/", CommandTokenBulkDeleteView.as_view(), name="commandtoken_bulk_delete"),
Expand All @@ -69,5 +93,11 @@
name="chatopsaccountlink_changelog",
kwargs={"model": ChatOpsAccountLink},
),
path(
"account-link/<uuid:pk>/notes/",
ObjectNotesView.as_view(),
name="chatopsaccountlink_notes",
kwargs={"model": ChatOpsAccountLink},
),
*grafana_urlpatterns,
]
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ipfabric = { version = "~6.0.9", optional = true }
ipfabric-diagrams = { version = "~6.0.2", optional = true }
isodate = { version = "^0.6.1", optional = true }
meraki = { version = "^1.7.2", optional = true }
nautobot = "2.0.0rc3"
nautobot = "2.0.0rc4"
nautobot-capacity-metrics = "^3.0.0rc3"
netmiko = { version = "^3.4.0", optional = true }
netutils = { version = "^1.1.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def is_truthy(arg):
namespace.configure(
{
"nautobot_chatops": {
"nautobot_ver": "2.0.0-rc.3",
"nautobot_ver": "2.0.0-rc.4",
"project_name": "nautobot-chatops",
"python_ver": "3.10",
"local": False,
Expand Down

0 comments on commit b92cf7f

Please sign in to comment.