Compare commits

...

6 commits

Author SHA1 Message Date
Lance Edgar b2113bcd88 docs: use markdown for readme file 2024-09-13 18:34:46 -05:00
Lance Edgar 860355f8af fix: avoid deprecated base class for config extension 2024-08-16 10:12:47 -05:00
Lance Edgar 3591b7e317 bump: version 0.3.2 → 0.3.3 2024-07-05 10:08:20 -05:00
Lance Edgar ec3fd0b2fb fix: define host_key for MailChimp -> Rattail import 2024-07-05 10:08:00 -05:00
Lance Edgar 4f618e80ca bump: version 0.3.1 → 0.3.2 2024-07-01 15:11:51 -05:00
Lance Edgar 42cddaf6c0 fix: remove legacy command definitions 2024-07-01 12:27:07 -05:00
7 changed files with 36 additions and 48 deletions

View file

@ -5,6 +5,18 @@ All notable changes to rattail-mailchimp will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## v0.3.3 (2024-07-05)
### Fix
- define `host_key` for MailChimp -> Rattail import
## v0.3.2 (2024-07-01)
### Fix
- remove legacy command definitions
## v0.3.1 (2024-06-14)
### Fix

11
README.md Normal file
View file

@ -0,0 +1,11 @@
# rattail_mailchimp
Rattail is a retail software framework, released under the GNU General
Public License.
This package contains software interfaces for the
[MailChimp](https://mailchimp.com/) system.
Please see the [Rattail Project](https://rattailproject.org/) for more
information.

View file

@ -1,14 +0,0 @@
rattail_mailchimp
=================
Rattail is a retail software framework, released under the GNU General
Public License.
This package contains software interfaces for the `MailChimp`_ system.
.. _`MailChimp`: https://mailchimp.com/
Please see the `Rattail Project`_ for more information.
.. _`Rattail Project`: https://rattailproject.org/

View file

@ -6,9 +6,9 @@ build-backend = "hatchling.build"
[project]
name = "rattail-mailchimp"
version = "0.3.1"
version = "0.3.3"
description = "Rattail Software Interfaces for MailChimp"
readme = "README.rst"
readme = "README.md"
authors = [{name = "Lance Edgar", email = "lance@edbob.org"}]
license = {text = "GNU GPL v3+"}
classifiers = [
@ -34,10 +34,6 @@ dependencies = [
rattail_mailchimp = "rattail_mailchimp.config:MailchimpConfigExtension"
[project.entry-points."rattail.subcommands"]
import-mailchimp = "rattail_mailchimp.commands:ImportMailChimp"
[project.entry-points."rattail.typer_imports"]
rattail_mailchimp = "rattail_mailchimp.commands"

View file

@ -26,7 +26,7 @@ Rattail Commands for MailChimp integration
import typer
from rattail.commands import rattail_typer, ImportSubcommand
from rattail.commands import rattail_typer
from rattail.commands.typer import importer_command, typer_get_runas_user
from rattail.commands.importing import ImportCommandHandler
@ -46,21 +46,3 @@ def import_mailchimp(
config, import_handler_key='to_rattail.from_mailchimp.import')
kwargs['user'] = typer_get_runas_user(ctx)
handler.run(kwargs, progress=progress)
class ImportMailChimp(ImportSubcommand):
"""
Import data to Rattail, from MailChimp API
"""
name = 'import-mailchimp'
description = __doc__.strip()
default_handler_spec = 'rattail_mailchimp.importing.mailchimp:FromMailChimpToRattail'
def get_handler_factory(self, **kwargs):
if self.config:
spec = self.config.get('rattail.importing', 'mailchimp.handler',
default=self.default_handler_spec)
else:
# just use default, for sake of cmd line help
spec = self.default_handler_spec
return self.app.load_object(spec)

View file

@ -24,10 +24,10 @@
Config extensions for rattail-mailchimp
"""
from rattail.config import ConfigExtension
from wuttjamaican.conf import WuttaConfigExtension
class MailchimpConfigExtension(ConfigExtension):
class MailchimpConfigExtension(WuttaConfigExtension):
"""
Config extension for rattail-mailchimp
"""

View file

@ -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'],
}