Warning message added to discussion control panel that shows up if there are unmigrated comments.

This commit is contained in:
Timo Stollenwerk 2012-03-15 20:00:08 +01:00
parent c76ef0523e
commit 58663fb492
3 changed files with 44 additions and 11 deletions

View File

@ -8,11 +8,14 @@ Changelog
a view in the url to properly display comments. a view in the url to properly display comments.
[eleddy] [eleddy]
- Make comments and controlpanel views more robust, so they don't break if no - Make comments and controlpanel views more robust, so they don't break if no
workflow is assigned to the 'Discussion Item' content type. workflow is assigned to the 'Discussion Item' content type.
[timo] [timo]
- Warning message added to discussion control panel that shows up if there are
unmigrated comments.
[timo]
2.1.4 (2012-02-29) 2.1.4 (2012-02-29)
------------------ ------------------

View File

@ -61,6 +61,25 @@
</dd> </dd>
</dl> </dl>
<dl class="portalMessage warning"
tal:condition="view/unmigrated_comments_warning">
<dt i18n:translate="">
Warning
</dt>
<dd i18n:translate="text_unmigrated_comments">
You have comments that have not been migrated to the new
commenting system that has been introduced in Plone 4.1.
Please
<tal:link i18n:name="label_comments_migration_link">
<a href=""
i18n:translate="text_comments_migration_link"
tal:attributes="href string:${portal_url}/@@comment-migration"
>migrate your comments</a>
</tal:link>
to fix this.
</dd>
</dl>
<div metal:use-macro="context/global_statusmessage/macros/portal_message"> <div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message Portal status message
</div> </div>

View File

@ -4,6 +4,8 @@ from Acquisition import aq_base, aq_inner
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFCore.interfaces._content import IDiscussionResponse
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.statusmessages.interfaces import IStatusMessage from Products.statusmessages.interfaces import IStatusMessage
@ -155,6 +157,15 @@ class DiscussionSettingsControlPanel(controlpanel.ControlPanelFormWrapper):
return return
return True return True
def unmigrated_comments_warning(self):
"""Returns true if site contains unmigrated comments.
"""
catalog = getToolByName(aq_inner(self.context), 'portal_catalog', None)
count_comments_old = catalog.searchResults(
object_provides=IDiscussionResponse.__identifier__)
if count_comments_old:
return True
def notify_configuration_changed(event): def notify_configuration_changed(event):
"""Event subscriber that is called every time the configuration changed. """Event subscriber that is called every time the configuration changed.