From e09641b2124344378b065899494944d7954a6d7a Mon Sep 17 00:00:00 2001 From: Andreas Madsack Date: Sat, 13 Jan 2018 13:22:31 +0100 Subject: [PATCH] fix membership update_or_create in importer --- byro_shackspace/management/commands/import_shackbureau.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/byro_shackspace/management/commands/import_shackbureau.py b/byro_shackspace/management/commands/import_shackbureau.py index f564574..5464a94 100644 --- a/byro_shackspace/management/commands/import_shackbureau.py +++ b/byro_shackspace/management/commands/import_shackbureau.py @@ -155,11 +155,11 @@ def import_member(member_data): for membership in sorted(memberships, key=lambda m: m['membership_start']): obj, _ = Membership.objects.update_or_create( member=member, + start=parse_date(membership['membership_start']), defaults={ - 'start': parse_date(membership['membership_start']), 'amount': Decimal(membership['membership_fee_monthly'])*membership['membership_fee_interval'], 'interval': membership['membership_fee_interval'], - }) + }) if last: last.end = obj.start - timedelta(days=1) last.save(update_fields=['end'])