Skip to content

Commit

Permalink
Set effective date also
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jul 30, 2015
1 parent 9ad1a25 commit eb66a9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions transmogrify/wordpress/blueprints/csvsource.py
Expand Up @@ -162,8 +162,12 @@ def __iter__(self):
logger.warn('No taxonomies found for row ID: ' + row['ID'])
continue

date = item['creation_date'] = DateTime(row['post_date_gmt'])
item['modification_date'] = DateTime(row['post_modified_gmt'])
# WordPress stores only publication and modification times
item['effective_date'] = row['post_date_gmt']
item['modification_date'] = row['post_modified_gmt']
# we use publication date as creation date
item['creation_date'] = item['effective_date']
date = DateTime(item['creation_date'])

try:
item['_path'] = _get_path(item_id, post_type, category, date)
Expand Down
12 changes: 6 additions & 6 deletions transmogrify/wordpress/blueprints/datesetter.py
@@ -1,15 +1,12 @@
# -*- coding: utf-8 -*-
from collective.transmogrifier.interfaces import ISection
from collective.transmogrifier.interfaces import ISectionBlueprint
from DateTime import DateTime
from plone.dexterity.interfaces import IDexterityContent
from Products.Archetypes.interfaces import IBaseObject
from zope.interface import classProvides
from zope.interface import implements

import logging

logger = logging.getLogger('transmogrify.wordpress')


class DateSetter(object):

Expand All @@ -35,14 +32,17 @@ def __iter__(self):
obj = self.context.unrestrictedTraverse(
path.encode().lstrip('/'), None)

creation_date = item.get('creation_date', None)
modification_date = item.get('modification_date', None)
creation_date = DateTime(item.get('creation_date', None))
effective_date = DateTime(item.get('effective_date', None))
modification_date = DateTime(item.get('modification_date', None))

if IBaseObject.providedBy(obj): # Archetypes
obj.setCreationDate(creation_date)
obj.setEffectiveDate(effective_date)
obj.setModificationDate(modification_date)
elif IDexterityContent.providedBy(obj): # Dexterity
obj.creation_date = creation_date
obj.effective_date = effective_date
obj.modification_date = modification_date

yield item

0 comments on commit eb66a9d

Please sign in to comment.