Do not allow to change the mail settings in the discussion control panel, if there is no valid mail setup.
svn path=/plone.app.discussion/trunk/; revision=46089
This commit is contained in:
parent
1b36f99a7a
commit
fbd7eb2bbc
@ -17,7 +17,9 @@
|
|||||||
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="content" metal:fill-slot="prefs_configlet_content">
|
<div id="content"
|
||||||
|
tal:attributes="class python: view.invalid_mail_setup and 'invalid_mail_setup'"
|
||||||
|
metal:fill-slot="prefs_configlet_content">
|
||||||
|
|
||||||
<script type="text/javascript"
|
<script type="text/javascript"
|
||||||
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
|
tal:attributes="src string:${context/portal_url}/++resource++plone.app.discussion.javascripts/controlpanel.js">
|
||||||
|
@ -8,6 +8,8 @@ from plone.app.registry.browser import controlpanel
|
|||||||
|
|
||||||
from plone.registry.interfaces import IRegistry
|
from plone.registry.interfaces import IRegistry
|
||||||
|
|
||||||
|
from zope.component import getMultiAdapter
|
||||||
|
|
||||||
from z3c.form import button
|
from z3c.form import button
|
||||||
from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
|
from z3c.form.browser.checkbox import SingleCheckBoxFieldWidget
|
||||||
|
|
||||||
@ -69,12 +71,23 @@ class DiscussionSettingsEditForm(controlpanel.RegistryEditForm):
|
|||||||
"info")
|
"info")
|
||||||
self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
|
self.request.response.redirect("%s/%s" % (self.context.absolute_url(),
|
||||||
self.control_panel_view))
|
self.control_panel_view))
|
||||||
|
|
||||||
|
|
||||||
|
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
|
||||||
|
form = DiscussionSettingsEditForm
|
||||||
|
index = ViewPageTemplateFile('controlpanel.pt')
|
||||||
|
|
||||||
def anonymous_discussion_allowed(self):
|
def anonymous_discussion_allowed(self):
|
||||||
# Check if anonymous comments are allowed in the registry
|
"""Return true if anonymous comments are allowed in the registry.
|
||||||
|
"""
|
||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
settings = registry.forInterface(IDiscussionSettings, check=False)
|
settings = registry.forInterface(IDiscussionSettings, check=False)
|
||||||
return settings.anonymous_comments
|
return settings.anonymous_comments
|
||||||
|
|
||||||
class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
|
def invalid_mail_setup(self):
|
||||||
form = DiscussionSettingsEditForm
|
"""Return true if the Plone site has a valid mail setup.
|
||||||
index = ViewPageTemplateFile('controlpanel.pt')
|
"""
|
||||||
|
ctrlOverview = getMultiAdapter((self.context, self.request),
|
||||||
|
name='overview-controlpanel')
|
||||||
|
return ctrlOverview.mailhost_warning()
|
||||||
|
|
@ -36,6 +36,21 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
$(window).load(function () {
|
$(window).load(function () {
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Do not allow to change the mail settings if there is no valid mail
|
||||||
|
* setup.
|
||||||
|
**********************************************************************/
|
||||||
|
var invalid_mail_setup = $("#content").hasClass("invalid_mail_setup");
|
||||||
|
if (invalid_mail_setup === true) {
|
||||||
|
$.disableSettings([
|
||||||
|
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||||
|
$('#formfield-form-widgets-user_notification_enabled')
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* If commenting is disabled globally, disable all commenting options.
|
||||||
|
**********************************************************************/
|
||||||
var commenting_enabled_globally = $("#form-widgets-globally_enabled-0").attr("checked");
|
var commenting_enabled_globally = $("#form-widgets-globally_enabled-0").attr("checked");
|
||||||
if (commenting_enabled_globally === false) {
|
if (commenting_enabled_globally === false) {
|
||||||
$.disableSettings([
|
$.disableSettings([
|
||||||
@ -46,11 +61,7 @@
|
|||||||
$('#formfield-form-widgets-moderator_notification_enabled'),
|
$('#formfield-form-widgets-moderator_notification_enabled'),
|
||||||
$('#formfield-form-widgets-user_notification_enabled')
|
$('#formfield-form-widgets-user_notification_enabled')
|
||||||
]);
|
]);
|
||||||
}
|
};
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* If commenting is disabled globally, disable all commenting options.
|
|
||||||
**********************************************************************/
|
|
||||||
$("input[name='form.widgets.globally_enabled:list']").live("click", function (e) {
|
$("input[name='form.widgets.globally_enabled:list']").live("click", function (e) {
|
||||||
if ($(this).attr("checked")) {
|
if ($(this).attr("checked")) {
|
||||||
// commenting globally enabled
|
// commenting globally enabled
|
||||||
@ -75,11 +86,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/**********************************************************************
|
||||||
* Remove the disabled attribute from all form elements before
|
* Remove the disabled attribute from all form elements before
|
||||||
* submitting the form. Otherwise the z3c.form will raise errors on
|
* submitting the form. Otherwise the z3c.form will raise errors on
|
||||||
* the required attributes.
|
* the required attributes.
|
||||||
*/
|
**********************************************************************/
|
||||||
$("input[name='form.buttons.save']").live("click", function (e) {
|
$("input[name='form.buttons.save']").live("click", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#formfield-form-widgets-anonymous_comments').removeAttr('disabled');
|
$('#formfield-form-widgets-anonymous_comments').removeAttr('disabled');
|
||||||
|
Loading…
Reference in New Issue
Block a user