Skip to content

Commit

Permalink
Use Ruff formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kani999 committed Jul 17, 2024
1 parent 16a8956 commit 5635e08
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
4 changes: 2 additions & 2 deletions netbox_attachments/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from netbox_attachments.api import views

app_name = 'netbox_attachments'
app_name = "netbox_attachments"
router = NetBoxRouter()
router.register('netbox-attachments', views.NetBoxAttachmentViewSet)
router.register("netbox-attachments", views.NetBoxAttachmentViewSet)

urlpatterns = router.urls
2 changes: 1 addition & 1 deletion netbox_attachments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def save(self, *args, **kwargs):
return super().save(*args, **kwargs)

if not self.name:
if self._state.adding == True:
if self._state.adding:
self.name = self.file.name.rsplit("/", 1)[-1]
else:
self.name = self.filename.split("_", 2)[2]
Expand Down
17 changes: 10 additions & 7 deletions netbox_attachments/navigation.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
from netbox.plugins import PluginMenu, PluginMenuItem

menu = PluginMenu(
label='Attachments',
label="Attachments",
icon_class="mdi mdi-paperclip",
groups=(
("", (
PluginMenuItem(
link="plugins:netbox_attachments:netboxattachment_list",
link_text="NetBox Attachments",
permissions=['netbox_attachments.view_netboxattachment']
(
"",
(
PluginMenuItem(
link="plugins:netbox_attachments:netboxattachment_list",
link_text="NetBox Attachments",
permissions=["netbox_attachments.view_netboxattachment"],
),
),
)),
),
),
)
7 changes: 4 additions & 3 deletions netbox_attachments/search.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from netbox.search import SearchIndex, register_search

from netbox_attachments.models import NetBoxAttachment


@register_search
class NetBoxAttachmentIndex(SearchIndex):
model = NetBoxAttachment
fields = (
('name', 100),
('description', 200),
('comments', 5000),
("name", 100),
("description", 200),
("comments", 5000),
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ <h5 class="card-header">Attachments</h5>
<td class="text-end noprint">
<a href="{{ attachment.file.url }}"
target="_blank"
class="btn btn-sm btn-primary download-attachment"
class="btn btn-sm btn-primary download-attachment lh-1"
title="Download">
<i class="mdi mdi-download"></i>
</a>
Expand Down
44 changes: 31 additions & 13 deletions netbox_attachments/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,35 @@

urlpatterns = (
# Files
path('netbox-attachments/add/', views.NetBoxAttachmentEditView.as_view(),
name='netboxattachment_add'),
path('netbox-attachments/<int:pk>/edit/',
views.NetBoxAttachmentEditView.as_view(), name='netboxattachment_edit'),
path('netbox-attachments/<int:pk>/delete/',
views.NetBoxAttachmentDeleteView.as_view(), name='netboxattachment_delete'),
path('netbox-attachments/', views.NetBoxAttachmentListView.as_view(),
name='netboxattachment_list'),
path('netbox-attachments/<int:pk>/',
views.NetBoxAttachmentView.as_view(), name='netboxattachment'),
path('netbox-attachments/<int:pk>/changelog/', ObjectChangeLogView.as_view(),
name='netboxattachment_changelog', kwargs={'model': models.NetBoxAttachment}),

path(
"netbox-attachments/add/",
views.NetBoxAttachmentEditView.as_view(),
name="netboxattachment_add",
),
path(
"netbox-attachments/<int:pk>/edit/",
views.NetBoxAttachmentEditView.as_view(),
name="netboxattachment_edit",
),
path(
"netbox-attachments/<int:pk>/delete/",
views.NetBoxAttachmentDeleteView.as_view(),
name="netboxattachment_delete",
),
path(
"netbox-attachments/",
views.NetBoxAttachmentListView.as_view(),
name="netboxattachment_list",
),
path(
"netbox-attachments/<int:pk>/",
views.NetBoxAttachmentView.as_view(),
name="netboxattachment",
),
path(
"netbox-attachments/<int:pk>/changelog/",
ObjectChangeLogView.as_view(),
name="netboxattachment_changelog",
kwargs={"model": models.NetBoxAttachment},
),
)

0 comments on commit 5635e08

Please sign in to comment.