-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Corrected index problem when plone.app.contentypes is installed.
Used a different datewidget in plone 5. Indexed dates in plone 4 are timezoned.
- Loading branch information
Showing
5 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
import logging | ||
from plone import api | ||
from plone.app.event.base import default_timezone | ||
|
||
logger = logging.getLogger('collective.messagesviewlet: upgrade. ') | ||
|
||
|
||
def upgrade_to_2000(context): | ||
""" | ||
Add timezone to start and end | ||
""" | ||
tzinfo = default_timezone(as_tzinfo=True) | ||
catalog = api.portal.get_tool('portal_catalog') | ||
brains = catalog(portal_type='Message') | ||
logger.info("Found %d messages" % len(brains)) | ||
count = 0 | ||
import ipdb; ipdb.set_trace() | ||
for brain in brains: | ||
obj = brain.getObject() | ||
correction = False | ||
for attr in ('start', 'end'): | ||
if getattr(obj, attr, False): | ||
setattr(obj, attr, tzinfo.localize(getattr(obj, attr))) | ||
correction = True | ||
if correction: | ||
count += 1 | ||
obj.reindexObject(['start', 'end']) | ||
logger.info("Corrected %d messages" % count) |