Use the customer information, not an existing subscription, to determine whether the button should say "Start Free Trial" or "Subscribe"

This commit is contained in:
Joseph Schorr 2014-04-23 01:17:34 -04:00
parent a5c2fc7185
commit 8f66c39ff5
4 changed files with 13 additions and 10 deletions

View file

@ -221,6 +221,7 @@ class UserPlan(ApiResource):
@nickname('getUserSubscription')
def get(self):
""" Fetch any existing subscription for the user. """
cus = None
user = get_authenticated_user()
private_repos = model.get_private_repo_count(user.username)
@ -231,6 +232,8 @@ class UserPlan(ApiResource):
return subscription_view(cus.subscription, private_repos)
return {
'hasSubscription': False,
'isExistingCustomer': cus is not None,
'plan': 'free',
'usedPrivateRepos': private_repos,
}
@ -280,6 +283,7 @@ class OrganizationPlan(ApiResource):
@nickname('getOrgSubscription')
def get(self, orgname):
""" Fetch any existing subscription for the org. """
cus = None
permission = AdministerOrganizationPermission(orgname)
if permission.can():
private_repos = model.get_private_repo_count(orgname)
@ -291,6 +295,8 @@ class OrganizationPlan(ApiResource):
return subscription_view(cus.subscription, private_repos)
return {
'hasSubscription': False,
'isExistingCustomer': cus is not None,
'plan': 'free',
'usedPrivateRepos': private_repos,
}