Make the mail-setting warning message show up in the discussion control panel.

svn path=/plone.app.discussion/trunk/; revision=46211
This commit is contained in:
Timo Stollenwerk 2010-12-09 08:07:15 +00:00
parent 797ed40852
commit c8e78449a2
3 changed files with 40 additions and 1 deletions

View File

@ -4,6 +4,9 @@ Changelog
1.0RC1 (unreleased)
-------------------
- Make the mail-setting warning message show up in the discussion control panel.
[timo]
- Link directly to the "Discussion Item" types control panel in the moderation
view.
[timo]

View File

@ -25,6 +25,24 @@
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
</script>
<dl class="portalMessage warning"
tal:condition="view/mailhost_warning">
<dt i18n:translate="">
Warning
</dt>
<dd i18n:translate="text_no_mailhost_configured">
You have not configured a mail host or a site 'From'
address, various features including contact forms, email
notification and password reset will not work. Go to the
<tal:link i18n:name="label_mail_control_panel_link">
<a href=""
i18n:translate="text_no_mailhost_configured_control_panel_link"
tal:attributes="href string:${portal_url}/@@mail-controlpanel"
>Mail control panel</a>
</tal:link>
to fix this.
</dd>
</dl>
<div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message
</div>

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from Acquisition import aq_base, aq_inner
from Products.CMFCore.utils import getToolByName
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
@ -19,7 +21,8 @@ from plone.app.discussion.interfaces import IDiscussionSettings, _
class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
"""Discussion settings form.
"""
schema = IDiscussionSettings
label = _(u"Discussion settings")
description = _(u"help_discussion_settings_editform",
@ -76,6 +79,8 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
"""Discussion settings control panel.
"""
form = DiscussionSettingsEditForm
index = ViewPageTemplateFile('controlpanel.pt')
@ -110,3 +115,16 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
# Merge all settings into one string
return ' '.join(output)
def mailhost_warning(self):
"""Returns true if mailhost is not configured properly.
"""
# Copied from plone.app.controlpanel/plone/app/controlpanel/overview.py
mailhost = getToolByName(aq_inner(self.context), 'MailHost', None)
if mailhost is None:
return True
mailhost = getattr(aq_base(mailhost), 'smtp_host', None)
email = getattr(aq_inner(self.context), 'email_from_address', None)
if mailhost and email:
return False
return True