Merge branch 'orgs' of https://bitbucket.org/yackob03/quay into orgs

Conflicts:
	endpoints/api.py
This commit is contained in:
Joseph Schorr 2013-11-05 15:16:20 -05:00
commit d2601c6fe4
2 changed files with 17 additions and 22 deletions

View file

@ -269,7 +269,7 @@ def get_user_organizations(username):
def get_organization(name): def get_organization(name):
try: try:
return User.get(username = name, organization = True) return User.get(username=name, organization=True)
except User.DoesNotExist: except User.DoesNotExist:
raise InvalidOrganizationException('Organization does not exist: %s' % raise InvalidOrganizationException('Organization does not exist: %s' %
name) name)

View file

@ -286,29 +286,24 @@ def get_organization(orgname):
@app.route('/api/organization/<orgname>/private', methods=['GET']) @app.route('/api/organization/<orgname>/private', methods=['GET'])
def get_organization_private_allowed(orgname): def get_organization_private_allowed(orgname):
if current_user.is_anonymous(): permission = CreateRepositoryPermission(orgname)
abort(404) if permission.can():
user = current_user.db_user()
try:
organization = model.get_organization(orgname) organization = model.get_organization(orgname)
except:
abort(404)
private_repos = model.get_private_repo_count(organization.username) private_repos = model.get_private_repo_count(organization.username)
if organization.stripe_id: if organization.stripe_id:
cus = stripe.Customer.retrieve(organization.stripe_id) cus = stripe.Customer.retrieve(organization.stripe_id)
if cus.subscription:
repos_allowed = get_plan(cus.subscription.plan.id)
return jsonify({
'privateAllowed': (private_repos < repos_allowed)
})
if cus.subscription: return jsonify({
repos_allowed = get_plan(cus.subscription.plan.id) 'privateAllowed': False
return jsonify({ })
'privateAllowed': (private_repos < repos_allowed)
})
return jsonify({ abort(403)
'privateAllowed': False
})
def member_view(m): def member_view(m):