mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
@@ -215,6 +215,16 @@ class GeneralParametersForm(param_forms.AdminParametersForm):
|
||||
required=False
|
||||
)
|
||||
|
||||
dash_sep = SeparatorField(label=ugettext_lazy("Dashboard"))
|
||||
|
||||
news_url = forms.URLField(
|
||||
label=ugettext_lazy("Custom news url"),
|
||||
required=False,
|
||||
help_text=ugettext_lazy(
|
||||
"Display custom news for resellers and domain administrators"
|
||||
)
|
||||
)
|
||||
|
||||
notif_sep = SeparatorField(label=ugettext_lazy("Notifications"))
|
||||
|
||||
sender_address = lib_fields.UTF8EmailField(
|
||||
|
||||
@@ -62,6 +62,18 @@ class DashboardTestCase(ModoTestCase):
|
||||
response = self.client.get(url)
|
||||
self.assertEqual(response.status_code, 302)
|
||||
|
||||
def test_custom_news(self):
|
||||
"""Check that custom news are displayed."""
|
||||
url = reverse("core:dashboard")
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, "https://modoboa.org")
|
||||
|
||||
self.set_global_parameter(
|
||||
"news_url", "https://www.djangoproject.com/rss/weblog/")
|
||||
self.client.force_login(self.dadmin)
|
||||
response = self.client.get(url)
|
||||
self.assertContains(response, "djangoproject")
|
||||
|
||||
def test_root_dispatch(self):
|
||||
"""Check root dispatching."""
|
||||
url = reverse("core:root")
|
||||
|
||||
@@ -37,8 +37,13 @@ class DashboardView(auth_mixins.AccessMixin, generic.TemplateView):
|
||||
lang = "en"
|
||||
context.update({"selection": "dashboard"})
|
||||
|
||||
posts = feedparser.parse(
|
||||
"{}{}/weblog/feeds/".format(MODOBOA_WEBSITE_URL, lang))
|
||||
feed_url = "{}{}/weblog/feeds/".format(MODOBOA_WEBSITE_URL, lang)
|
||||
if self.request.user.role != "SuperAdmins":
|
||||
custom_feed_url = (
|
||||
self.request.localconfig.parameters.get_value("news_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"])
|
||||
|
||||
Reference in New Issue
Block a user