changed "subscription" to "membership"

pull/56/head
Chris Veilleux 2019-02-24 23:54:34 -06:00
parent 5d16ede767
commit 8d73d18e09
1 changed files with 7 additions and 7 deletions

View File

@ -12,7 +12,7 @@ from selene.data.account import (
Account, Account,
AccountAgreement, AccountAgreement,
AccountRepository, AccountRepository,
AccountSubscription, AccountMembership,
PRIVACY_POLICY, PRIVACY_POLICY,
TERMS_OF_USE TERMS_OF_USE
) )
@ -92,8 +92,8 @@ class AccountEndpoint(SeleneEndpoint):
agreement_date = self._format_agreement_date(agreement) agreement_date = self._format_agreement_date(agreement)
agreement['accept_date'] = agreement_date agreement['accept_date'] = agreement_date
membership_duration = self._format_membership_duration(response_data) membership_duration = self._format_membership_duration(response_data)
response_data['subscription']['duration'] = membership_duration response_data['membership']['duration'] = membership_duration
del (response_data['subscription']['start_date']) del (response_data['membership']['start_date'])
del (response_data['refresh_tokens']) del (response_data['refresh_tokens'])
return response_data return response_data
@ -108,7 +108,7 @@ class AccountEndpoint(SeleneEndpoint):
@staticmethod @staticmethod
def _format_membership_duration(response_data): def _format_membership_duration(response_data):
membership_start = datetime.strptime( membership_start = datetime.strptime(
response_data['subscription']['start_date'], response_data['membership']['start_date'],
'%Y-%m-%d' '%Y-%m-%d'
) )
one_year = timedelta(days=365) one_year = timedelta(days=365)
@ -179,10 +179,10 @@ class AccountEndpoint(SeleneEndpoint):
def _add_account(self, email_address, password): def _add_account(self, email_address, password):
membership_type = self.request_data['support']['membership'] membership_type = self.request_data['support']['membership']
subscription = None membership = None
if membership_type != NO_MEMBERSHIP: if membership_type != NO_MEMBERSHIP:
stripe_id = self.request_data['support']['stripeCustomerId'] stripe_id = self.request_data['support']['stripeCustomerId']
subscription = AccountSubscription( membership = AccountMembership(
type=membership_type, type=membership_type,
start_date=date.today(), start_date=date.today(),
stripe_customer_id=stripe_id stripe_customer_id=stripe_id
@ -194,7 +194,7 @@ class AccountEndpoint(SeleneEndpoint):
AccountAgreement(type=PRIVACY_POLICY, accept_date=date.today()), AccountAgreement(type=PRIVACY_POLICY, accept_date=date.today()),
AccountAgreement(type=TERMS_OF_USE, accept_date=date.today()) AccountAgreement(type=TERMS_OF_USE, accept_date=date.today())
], ],
subscription=subscription membership=membership
) )
with get_db_connection(self.config['DB_CONNECTION_POOL']) as db: with get_db_connection(self.config['DB_CONNECTION_POOL']) as db:
acct_repository = AccountRepository(db) acct_repository = AccountRepository(db)