PEP8 fixes.
This commit is contained in:
parent
427b745f2f
commit
6a038bb24e
7 changed files with 56 additions and 45 deletions
|
@ -102,6 +102,7 @@ def create_repo_api():
|
|||
@app.route('/api/find/repository', methods=['GET'])
|
||||
def match_repos_api():
|
||||
prefix = request.args.get('query', '')
|
||||
|
||||
def repo_view(repo):
|
||||
return {
|
||||
'namespace': repo.namespace,
|
||||
|
@ -109,7 +110,10 @@ def match_repos_api():
|
|||
'description': repo.description
|
||||
}
|
||||
|
||||
username = current_user.db_user.username if current_user.is_authenticated() else None
|
||||
username = None
|
||||
if current_user.is_authenticated():
|
||||
username = current_user.db_user.username
|
||||
|
||||
matching = model.get_matching_repositories(prefix, username)
|
||||
response = {
|
||||
'repositories': [repo_view(repo) for repo in matching]
|
||||
|
@ -126,7 +130,7 @@ def list_repos_api():
|
|||
'name': repo_obj.name,
|
||||
'description': repo_obj.description,
|
||||
}
|
||||
|
||||
|
||||
limit = request.args.get('limit', None)
|
||||
include_public = request.args.get('public', 'true')
|
||||
include_private = request.args.get('private', 'true')
|
||||
|
@ -141,10 +145,14 @@ def list_repos_api():
|
|||
include_private = include_private == 'true'
|
||||
sort = sort == 'true'
|
||||
|
||||
username = current_user.db_user.username if current_user.is_authenticated() and include_private else None
|
||||
repos = [repo_view(repo)
|
||||
for repo in model.get_visible_repositories(
|
||||
username, limit = limit, include_public = include_public, sort = sort)]
|
||||
username = None
|
||||
if current_user.is_authenticated() and include_private:
|
||||
username = current_user.db_user.username
|
||||
|
||||
repo_query = model.get_visible_repositories(username, limit=limit,
|
||||
include_public=include_public,
|
||||
sort=sort)
|
||||
repos = [repo_view(repo) for repo in repo_query]
|
||||
response = {
|
||||
'repositories': repos
|
||||
}
|
||||
|
@ -170,7 +178,8 @@ def update_repo_api(namespace, repository):
|
|||
abort(404)
|
||||
|
||||
|
||||
@app.route('/api/repository/<path:repository>/changevisibility', methods=['POST'])
|
||||
@app.route('/api/repository/<path:repository>/changevisibility',
|
||||
methods=['POST'])
|
||||
@api_login_required
|
||||
@parse_repository_name
|
||||
def change_repo_visibility_api(namespace, repository):
|
||||
|
@ -348,7 +357,7 @@ def delete_permissions(namespace, repository, username):
|
|||
abort(403) # Permission denied
|
||||
|
||||
|
||||
def subscription_view(stripe_subscription, used_repos):
|
||||
def subscription_view(stripe_subscription, used_repos):
|
||||
return {
|
||||
'currentPeriodStart': stripe_subscription.current_period_start,
|
||||
'currentPeriodEnd': stripe_subscription.current_period_end,
|
||||
|
@ -375,7 +384,7 @@ def subscribe():
|
|||
cus = stripe.Customer.create(email=user.email, plan=plan, card=card)
|
||||
user.stripe_id = cus.id
|
||||
user.save()
|
||||
|
||||
|
||||
resp = jsonify(subscription_view(cus.subscription, private_repos))
|
||||
resp.status_code = 201
|
||||
return resp
|
||||
|
@ -422,4 +431,4 @@ def get_subscription():
|
|||
return jsonify({
|
||||
'plan': 'free',
|
||||
'usedPrivateRepos': private_repos,
|
||||
});
|
||||
})
|
||||
|
|
Reference in a new issue