fix: define host_key
for MailChimp -> Rattail import
This commit is contained in:
parent
4f618e80ca
commit
ec3fd0b2fb
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2023 Lance Edgar
|
||||
# Copyright © 2010-2024 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -30,7 +30,6 @@ from collections import OrderedDict
|
|||
from mailchimp3 import MailChimp
|
||||
|
||||
from rattail import importing
|
||||
from rattail.time import localtime, make_utc
|
||||
from rattail_mailchimp import importing as mailchimp_importing
|
||||
|
||||
|
||||
|
@ -38,7 +37,9 @@ class FromMailChimpToRattail(importing.ToRattailHandler):
|
|||
"""
|
||||
Handler for MailChimp -> Rattail cache import
|
||||
"""
|
||||
host_key = 'mailchimp'
|
||||
host_title = "MailChimp"
|
||||
generic_host_title = "MailChimp"
|
||||
|
||||
def get_importers(self):
|
||||
importers = OrderedDict()
|
||||
|
@ -53,7 +54,7 @@ class FromMailChimp(importing.Importer):
|
|||
"""
|
||||
|
||||
def setup(self):
|
||||
super(FromMailChimp, self).setup()
|
||||
super().setup()
|
||||
|
||||
self.api_key = self.config.require('mailchimp', 'api_key')
|
||||
self.mailchimp = MailChimp(self.api_key)
|
||||
|
@ -65,10 +66,10 @@ class FromMailChimp(importing.Importer):
|
|||
# issue..since we clearly have a UTC value
|
||||
value = value[:-6]
|
||||
dt = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S')
|
||||
dt = localtime(self.config, dt, from_utc=True)
|
||||
dt = self.app.localtime(dt, from_utc=True)
|
||||
else:
|
||||
dt = datetime.datetime.strptime(value, '%Y-%m-%dT%H:%M:%S%z')
|
||||
dt = localtime(self.config, dt)
|
||||
dt = self.app.localtime(dt)
|
||||
return dt
|
||||
|
||||
|
||||
|
@ -95,7 +96,7 @@ class MailChimpListImporter(FromMailChimp, mailchimp_importing.model.MailChimpLi
|
|||
return {
|
||||
'id': mclist['id'],
|
||||
'name': mclist['name'],
|
||||
'date_created': make_utc(date_created),
|
||||
'date_created': self.app.make_utc(date_created),
|
||||
}
|
||||
|
||||
|
||||
|
@ -160,6 +161,6 @@ class MailChimpListMemberImporter(FromMailChimp, mailchimp_importing.model.MailC
|
|||
'status': member['status'],
|
||||
# TODO: this API endpoint does not appear to include this field?
|
||||
# 'unsubscribe_reason': member.get('unsubscribe_reason'),
|
||||
'last_changed': make_utc(last_changed),
|
||||
'last_changed': self.app.make_utc(last_changed),
|
||||
'source': member['source'],
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue