Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion extras/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from core.events import *
from extras.choices import LogLevelChoices

Expand Down Expand Up @@ -85,7 +86,7 @@
'height': 4,
'title': 'NetBox News',
'config': {
'feed_url': 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/',
'feed_url': settings.NEWSFEED_URL,
'max_entries': 10,
'cache_timeout': 14400,
'requires_internet': True,
Expand Down
8 changes: 7 additions & 1 deletion netbox/config/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,14 @@ def __init__(self, name, label, default, description='', field=None, field_kwarg
ConfigParam(
name='MAPS_URL',
label=_('Maps URL'),
default='https://maps.google.com/?q=',
default='https://www.google.com/maps/search/?api=1&query=',
description=_("Base URL for mapping geographic locations")
),
ConfigParam(
name='NEWSFEED_API_VERSION',
label=_('Newsfeed API Version'),
default='v1',
description=_("Version of the Newsfeed API to use (v1 or v2)")
),

)
16 changes: 16 additions & 0 deletions netbox/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,22 @@ def _setting(name, default=None):

PLUGIN_CATALOG_URL = 'https://api.netbox.oss.netboxlabs.com/v1/plugins'

#
# Newsfeed API Configuration
#

# Configurable Newsfeed API version (default: "v1")
NEWSFEED_API_VERSION = 'v1'
Comment on lines +751 to +752
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NEWSFEED_API_VERSION надо предварительно пытаться получить из configuration


# Construct the final newsfeed URL based on version
if NEWSFEED_API_VERSION == 'v1':
NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/v1/newsfeed/'
elif NEWSFEED_API_VERSION == 'v2':
NEWSFEED_URL = f'https://api.netbox.oss.netboxlabs.com/newsfeed/?version=2'
else:
# Fallback to base URL for any other version
NEWSFEED_URL = 'https://api.netbox.oss.netboxlabs.com/newsfeed/'
Comment on lines +755 to +761
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Базовый путь https://api.netbox.oss.netboxlabs.com/ надо вынести в отдельную переменную


EVENTS_PIPELINE = list(EVENTS_PIPELINE)
if 'extras.events.process_event_queue' not in EVENTS_PIPELINE:
EVENTS_PIPELINE.insert(0, 'extras.events.process_event_queue')
Expand Down