Skip to content

Commit 13c26cc

Browse files
authored
Fixes: #18184 - Gracefully handle unavailable internet connection on RSS feed dashboard widget if ISOLATED_DEPLOYMENT is set (#18186)
* Suppress adding the RSS feed widget to the dashboard if ISOLATED_DEPLOYMENT is set * Add config option on RSSFeedWidget to specify requires_internet and to display a more appropriate error if ISOLATED_DEPLOYMENT is set * Remove skipping behavior from utils.py * Add required=False
1 parent aa56b99 commit 13c26cc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

netbox/extras/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
'feed_url': 'http://netbox.dev/rss/',
8080
'max_entries': 10,
8181
'cache_timeout': 14400,
82+
'requires_internet': True,
8283
}
8384
},
8485
{

netbox/extras/dashboard/widgets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ class RSSFeedWidget(DashboardWidget):
275275
default_config = {
276276
'max_entries': 10,
277277
'cache_timeout': 3600, # seconds
278+
'requires_internet': True,
278279
}
279280
description = _('Embed an RSS feed from an external website.')
280281
template_name = 'extras/dashboard/widgets/rssfeed.html'
@@ -285,6 +286,10 @@ class ConfigForm(WidgetConfigForm):
285286
feed_url = forms.URLField(
286287
label=_('Feed URL')
287288
)
289+
requires_internet = forms.BooleanField(
290+
label=_('Requires external connection'),
291+
required=False,
292+
)
288293
max_entries = forms.IntegerField(
289294
min_value=1,
290295
max_value=1000,
@@ -309,6 +314,11 @@ def cache_key(self):
309314
return f'dashboard_rss_{url_checksum}'
310315

311316
def get_feed(self):
317+
if self.config['requires_internet'] and settings.ISOLATED_DEPLOYMENT:
318+
return {
319+
'isolated_deployment': True,
320+
}
321+
312322
# Fetch RSS content from cache if available
313323
if feed_content := cache.get(self.cache_key):
314324
return {

netbox/templates/extras/dashboard/widgets/rssfeed.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
<div class="list-group-item text-muted">{% trans "No content found" %}</div>
1313
{% endfor %}
1414
</div>
15+
{% elif isolated_deployment %}
16+
<span class="text-danger">
17+
<i class="mdi mdi-alert"></i> {% trans "This RSS feed requires an external connection. Check the ISOLATED_DEPLOYMENT setting." %}
18+
</span>
1519
{% else %}
1620
{# There was an error retrieving/parsing the feed #}
1721
<span class="text-danger">

0 commit comments

Comments
 (0)