mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Merge branch 'master' of github.com:modoboa/modoboa
This commit is contained in:
@@ -297,6 +297,8 @@ SILENCED_SYSTEM_CHECKS = [
|
||||
"security.W019", # modoboa uses iframes to display e-mails
|
||||
]
|
||||
|
||||
DISABLE_DASHBOARD_EXTERNAL_QUERIES = False
|
||||
|
||||
# Load settings from extensions
|
||||
{% for extension in extra_settings %}
|
||||
try:
|
||||
|
||||
@@ -4,6 +4,7 @@ from testfixtures import compare
|
||||
|
||||
from django import forms
|
||||
from django.urls import reverse
|
||||
from django.test import override_settings
|
||||
|
||||
from modoboa.lib.tests import ModoTestCase
|
||||
from modoboa.parameters import forms as param_forms, tools as param_tools
|
||||
@@ -159,6 +160,20 @@ class DashboardTestCase(ModoTestCase):
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, "Features looking for sponsoring")
|
||||
|
||||
@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_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/')
|
||||
|
||||
def test_root_dispatch(self):
|
||||
"""Check root dispatching."""
|
||||
url = reverse("core:root")
|
||||
|
||||
@@ -8,6 +8,8 @@ from requests.exceptions import RequestException
|
||||
from django.contrib.auth import mixins as auth_mixins
|
||||
from django.views import generic
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from .. import signals
|
||||
|
||||
MODOBOA_WEBSITE_URL = "https://modoboa.org/"
|
||||
@@ -43,11 +45,12 @@ 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
|
||||
posts = feedparser.parse(feed_url)
|
||||
entries = []
|
||||
for entry in posts["entries"][:5]:
|
||||
entry["published"] = parser.parse(entry["published"])
|
||||
entries.append(entry)
|
||||
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)
|
||||
context["widgets"]["left"].append("core/_latest_news_widget.html")
|
||||
context.update({"news": entries})
|
||||
|
||||
@@ -57,13 +60,14 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
url = "{}{}/api/projects/?featured=true".format(
|
||||
MODOBOA_WEBSITE_URL, lang)
|
||||
features = []
|
||||
try:
|
||||
response = requests.get(url)
|
||||
except RequestException:
|
||||
pass
|
||||
else:
|
||||
if response.status_code == 200:
|
||||
features = response.json()
|
||||
if not settings.DISABLE_DASHBOARD_EXTERNAL_QUERIES:
|
||||
try:
|
||||
response = requests.get(url)
|
||||
except RequestException:
|
||||
pass
|
||||
else:
|
||||
if response.status_code == 200:
|
||||
features = response.json()
|
||||
context["widgets"]["right"].append("core/_current_features.html")
|
||||
context.update({"features": features})
|
||||
|
||||
|
||||
@@ -292,4 +292,5 @@ SILENCED_SYSTEM_CHECKS = [
|
||||
"security.W019", # modoboa uses iframes to display e-mails
|
||||
]
|
||||
|
||||
DISABLE_DASHBOARD_EXTERNAL_QUERIES = False
|
||||
# Load settings from extensions
|
||||
|
||||
Reference in New Issue
Block a user