mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Code improvements
This commit is contained in:
@@ -297,7 +297,7 @@ SILENCED_SYSTEM_CHECKS = [
|
||||
"security.W019", # modoboa uses iframes to display e-mails
|
||||
]
|
||||
|
||||
DISABLE_RSS = False
|
||||
DISABLE_DASHBOARD_EXTERNAL_QUERIES = False
|
||||
|
||||
# Load settings from extensions
|
||||
{% for extension in extra_settings %}
|
||||
|
||||
@@ -160,16 +160,16 @@ class DashboardTestCase(ModoTestCase):
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, "Features looking for sponsoring")
|
||||
|
||||
@override_settings(DISABLE_RSS=False)
|
||||
def test_enable_rss(self):
|
||||
"""Load dashboard with DISABLE_RSS = False"""
|
||||
@override_settings(DISABLE_DASHBOARD_EXTERNAL_QUERIES=False)
|
||||
def test_enable_dashboard_external_queries(self):
|
||||
"""Load dashboard with DISABLE_DASHBOARD_EXTERNAL_QUERIES = False"""
|
||||
url = reverse("core:dashboard")
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, 'href="https://modoboa.org/en/weblog/')
|
||||
|
||||
@override_settings(DISABLE_RSS=True)
|
||||
def test_disable_rss(self):
|
||||
"""Load dashboard with DISABLE_RSS = True"""
|
||||
@override_settings(DISABLE_DASHBOARD_EXTERNAL_QUERIES=True)
|
||||
def test_disable_dashboard_external_queries(self):
|
||||
"""Load dashboard with DISABLE_DASHBOARD_EXTERNAL_QUERIES = True"""
|
||||
url = reverse("core:dashboard")
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'https://modoboa.org/en/weblog/')
|
||||
|
||||
@@ -45,10 +45,9 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
self.request.localconfig.parameters.get_value("rss_feed_url"))
|
||||
if custom_feed_url:
|
||||
feed_url = custom_feed_url
|
||||
if not settings.DISABLE_RSS:
|
||||
posts = feedparser.parse(feed_url)
|
||||
entries = []
|
||||
if not settings.DISABLE_RSS:
|
||||
if not settings.DISABLE_DASHBOARD_EXTERNAL_QUERIES:
|
||||
posts = feedparser.parse(feed_url)
|
||||
for entry in posts["entries"][:5]:
|
||||
entry["published"] = parser.parse(entry["published"])
|
||||
entries.append(entry)
|
||||
@@ -61,7 +60,7 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
url = "{}{}/api/projects/?featured=true".format(
|
||||
MODOBOA_WEBSITE_URL, lang)
|
||||
features = []
|
||||
if not settings.DISABLE_RSS:
|
||||
if not settings.DISABLE_DASHBOARD_EXTERNAL_QUERIES:
|
||||
try:
|
||||
response = requests.get(url)
|
||||
except RequestException:
|
||||
|
||||
@@ -292,5 +292,5 @@ SILENCED_SYSTEM_CHECKS = [
|
||||
"security.W019", # modoboa uses iframes to display e-mails
|
||||
]
|
||||
|
||||
DISABLE_RSS = False
|
||||
DISABLE_DASHBOARD_EXTERNAL_QUERIES = False
|
||||
# Load settings from extensions
|
||||
|
||||
Reference in New Issue
Block a user