Skip to content

Commit

Permalink
Fix MembershipService.get_current_membership_for_org() bug
Browse files Browse the repository at this point in the history
So MembershipService.get_current_membership_for_org() doesn't crash
when Subscription.expiration_date is None.
  • Loading branch information
rerb committed Feb 25, 2019
1 parent dd7b8bf commit 221f5ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
## [Unreleased]
### Changed

## [1.1.5]
### Fixed `MembershipService.get_current_membership_for_org()` so it
doesn't crash when `Subscription.expiration_date` is `None`.

## [3.3.4] - 2018-02-05
### Breaking Changes

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ To authenticate and receive a session ID:

To take advantage of a service, for example `subscriptions`:

ORG_ID = #####
service = SubscriptionService(self.client)
subscription_list = service.get_subscriptions(org_id=ORG_ID)
subscription_list = service.get_subscriptions(org_id=1)

## Running tests

Expand Down
7 changes: 4 additions & 3 deletions membersuite_api_client/memberships/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MembershipService(ChunkQueryMixin, object):

def __init__(self, client):
"""
Accepts a ConciergeClient to connect with MemberSuite
Requires a ConciergeClient to connect with MemberSuite
"""
self.client = client

Expand All @@ -28,8 +28,9 @@ def get_current_membership_for_org(self, account_num, verbose=False):
verbose=verbose)
# Look for first membership that hasn't expired yet.
for membership in all_memberships:
if membership.expiration_date > datetime.datetime.now():
return membership
if (membership.expiration_date and
membership.expiration_date > datetime.datetime.now()): # noqa
return membership # noqa
return None

def get_memberships_for_org(self, account_num, verbose=False):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(fname):


setup(name='membersuite_api_client',
version="1.1.4",
version="1.1.5",
description='MemberSuite API Client',
author='AASHE',
author_email='[email protected]',
Expand Down

0 comments on commit 221f5ed

Please sign in to comment.