Skip to content

Commit

Permalink
Merge branch 'develop' into 17460-module-bay-buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
arthanson committed Sep 17, 2024
2 parents b944e84 + 7167f20 commit 8720fb7
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/stale@v9
with:
# General parameters
operations-per-run: 100
operations-per-run: 200
remove-stale-when-updated: false

# Issue parameters
Expand All @@ -43,7 +43,7 @@ jobs:
# Pull request parameters
close-pr-message: >
This PR has been automatically closed due to lack of activity.
days-before-pr-stale: 15
days-before-pr-stale: 30
days-before-pr-close: 15
exempt-pr-labels: 'status: blocked'
stale-pr-label: 'pending closure'
Expand Down
14 changes: 11 additions & 3 deletions netbox/core/management/commands/nbshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from users.models import User

APPS = ('circuits', 'core', 'dcim', 'extras', 'ipam', 'tenancy', 'users', 'virtualization', 'vpn', 'wireless')
EXCLUDE_MODELS = (
'extras.branch',
'extras.stagedchange',
)

BANNER_TEXT = """### NetBox interactive shell ({node})
### Python {python} | Django {django} | NetBox {netbox}
Expand Down Expand Up @@ -44,12 +48,16 @@ def get_namespace(self):

# Gather Django models and constants from each app
for app in APPS:
self.django_models[app] = []
models = []

# Load models from each app
for model in apps.get_app_config(app).get_models():
namespace[model.__name__] = model
self.django_models[app].append(model.__name__)
app_label = model._meta.app_label
model_name = model._meta.model_name
if f'{app_label}.{model_name}' not in EXCLUDE_MODELS:
namespace[model.__name__] = model
models.append(model.__name__)
self.django_models[app] = sorted(models)

# Constants
try:
Expand Down
2 changes: 2 additions & 0 deletions netbox/dcim/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ class PowerOutletTypeChoices(ChoiceSet):
# Direct current (DC)
TYPE_DC = 'dc-terminal'
# Proprietary
TYPE_EATON_C39 = 'eaton-c39'
TYPE_HDOT_CX = 'hdot-cx'
TYPE_SAF_D_GRID = 'saf-d-grid'
TYPE_NEUTRIK_POWERCON_20A = 'neutrik-powercon-20a'
Expand Down Expand Up @@ -805,6 +806,7 @@ class PowerOutletTypeChoices(ChoiceSet):
(TYPE_DC, 'DC Terminal'),
)),
(_('Proprietary'), (
(TYPE_EATON_C39, 'Eaton C39'),
(TYPE_HDOT_CX, 'HDOT Cx'),
(TYPE_SAF_D_GRID, 'Saf-D-Grid'),
(TYPE_NEUTRIK_POWERCON_20A, 'Neutrik powerCON (20A)'),
Expand Down
10 changes: 5 additions & 5 deletions netbox/extras/models/customfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,11 @@ def remove_stale_data(self, content_types):
no longer assigned to a model, or because it has been deleted).
"""
for ct in content_types:
model = ct.model_class()
instances = model.objects.filter(custom_field_data__has_key=self.name)
for instance in instances:
del instance.custom_field_data[self.name]
model.objects.bulk_update(instances, ['custom_field_data'], batch_size=100)
if model := ct.model_class():
instances = model.objects.filter(custom_field_data__has_key=self.name)
for instance in instances:
del instance.custom_field_data[self.name]
model.objects.bulk_update(instances, ['custom_field_data'], batch_size=100)

def rename_object_data(self, old_name, new_name):
"""
Expand Down
17 changes: 9 additions & 8 deletions netbox/netbox/api/serializers/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers

from utilities.views import get_viewname

__all__ = (
'NetBoxAPIHyperlinkedIdentityField',
'NetBoxURLHyperlinkedIdentityField',
Expand Down Expand Up @@ -30,24 +33,22 @@ def get_url(self, obj, view_name, request, format):
lookup_value = getattr(obj, self.lookup_field)
kwargs = {self.lookup_url_kwarg: lookup_value}

model_name = self.parent.Meta.model._meta.model_name
app_name = self.parent.Meta.model._meta.app_label
view_name = self.get_view_name(app_name, model_name)
view_name = self.get_view_name(obj)
return self.reverse(view_name, kwargs=kwargs, request=request, format=format)

def get_view_name(self, app_name, model_name):
def get_view_name(self, model):
raise NotImplementedError(_('{class_name} must implement get_view_name()').format(
class_name=self.__class__.__name__
))


class NetBoxAPIHyperlinkedIdentityField(BaseNetBoxHyperlinkedIdentityField):

def get_view_name(self, app_name, model_name):
return f'{app_name}-api:{model_name}-detail'
def get_view_name(self, model):
return get_viewname(model=model, action='detail', rest_api=True)


class NetBoxURLHyperlinkedIdentityField(BaseNetBoxHyperlinkedIdentityField):

def get_view_name(self, app_name, model_name):
return f'{app_name}:{model_name}'
def get_view_name(self, model):
return get_viewname(model=model)
2 changes: 1 addition & 1 deletion netbox/project-static/dist/netbox.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion netbox/project-static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@fontsource-variable/plus-jakarta-sans": "^5.1.0",
"@mdi/font": "7.4.47",
"@tabler/core": "1.0.0-beta20",
"@tabler/core": "1.0.0-beta21",
"bootstrap": "5.3.3",
"clipboard": "2.0.11",
"flatpickr": "4.6.13",
Expand Down
25 changes: 10 additions & 15 deletions netbox/project-static/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -675,19 +675,19 @@
resolved "https://registry.yarnpkg.com/@rtsao/scc/-/scc-1.1.0.tgz#927dd2fae9bc3361403ac2c7a00c32ddce9ad7e8"
integrity sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==

"@tabler/[email protected]beta20":
version "1.0.0-beta20"
resolved "https://registry.yarnpkg.com/@tabler/core/-/core-1.0.0-beta20.tgz#3fcc3b5634ca89a413ba9c077df7bdfc531ab93c"
integrity sha512-OzKpur+Ug7e+HMbNJrMcSuWZGUsJTvu7HYboBNRE8qyo1RKIWqvwL5YewKBJ+odW5pDOqBPzbsS4je3EBQQxHw==
"@tabler/[email protected]beta21":
version "1.0.0-beta21"
resolved "https://registry.yarnpkg.com/@tabler/core/-/core-1.0.0-beta21.tgz#cd10d7648b3b7b31927a430fd776d3304e796403"
integrity sha512-9ZKu38BScc0eHruhX/SlVDSiXenBFSgBp2WDq6orkuC8J/1yutKDt7CdXuJpBwkiADEk5yqYV31Ku+CnhwOc3Q==
dependencies:
"@popperjs/core" "^2.11.8"
"@tabler/icons" "^2.32.0"
bootstrap "5.3.1"
"@tabler/icons" "^3.14.0"
bootstrap "5.3.3"

"@tabler/icons@^2.32.0":
version "2.47.0"
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-2.47.0.tgz#c41c680d1947e3ab2d60af3febc4132287c60596"
integrity sha512-4w5evLh+7FUUiA1GucvGj2ReX2TvOjEr4ejXdwL/bsjoSkof6r1gQmzqI+VHrE2CpJpB3al7bCTulOkFa/RcyA==
"@tabler/icons@^3.14.0":
version "3.16.0"
resolved "https://registry.yarnpkg.com/@tabler/icons/-/icons-3.16.0.tgz#d618670b80163925a31a6c2290e8775f6058d81a"
integrity sha512-GU7MSx4uQEr55BmyON6hD/QYTl6k1v0YlRhM91gBWDoKAbyCt6QIYw7rpJ/ecdh5zrHaTOJKPenZ4+luoutwFA==

"@tanstack/react-virtual@^3.0.0-beta.60":
version "3.5.0"
Expand Down Expand Up @@ -977,11 +977,6 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==

[email protected]:
version "5.3.1"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.1.tgz#8ca07040ad15d7f75891d1504cf14c5dedfb1cfe"
integrity sha512-jzwza3Yagduci2x0rr9MeFSORjcHpt0lRZukZPZQJT1Dth5qzV7XcgGqYzi39KGAVYR8QEDVoO0ubFKOxzMG+g==

[email protected]:
version "5.3.3"
resolved "https://registry.yarnpkg.com/bootstrap/-/bootstrap-5.3.3.tgz#de35e1a765c897ac940021900fcbb831602bac38"
Expand Down

0 comments on commit 8720fb7

Please sign in to comment.