Strip whitespace from ALL the things.
This commit is contained in:
parent
f6dd8b0a4d
commit
716d7a737b
171 changed files with 807 additions and 807 deletions
|
@ -289,7 +289,7 @@ def require_fresh_login(func):
|
|||
|
||||
if not user.password_hash or last_login >= valid_span:
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
raise FreshLoginRequired()
|
||||
return wrapped
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ def get_invoices(customer_id):
|
|||
'total': i.total,
|
||||
'plan': i.lines.data[0].plan.id if i.lines.data[0].plan else None
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
invoices = billing.Invoice.all(customer=customer_id, count=12)
|
||||
except stripe.APIConnectionError as e:
|
||||
|
@ -247,7 +247,7 @@ class UserPlan(ApiResource):
|
|||
except stripe.APIConnectionError as e:
|
||||
abort(503, message='Cannot contact Stripe')
|
||||
|
||||
if cus.subscription:
|
||||
if cus.subscription:
|
||||
return subscription_view(cus.subscription, private_repos)
|
||||
|
||||
return {
|
||||
|
@ -313,7 +313,7 @@ class OrganizationPlan(ApiResource):
|
|||
except stripe.APIConnectionError as e:
|
||||
abort(503, message='Cannot contact Stripe')
|
||||
|
||||
if cus.subscription:
|
||||
if cus.subscription:
|
||||
return subscription_view(cus.subscription, private_repos)
|
||||
|
||||
return {
|
||||
|
@ -338,7 +338,7 @@ class UserInvoiceList(ApiResource):
|
|||
user = get_authenticated_user()
|
||||
if not user.stripe_id:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
return get_invoices(user.stripe_id)
|
||||
|
||||
|
||||
|
@ -356,7 +356,7 @@ class OrgnaizationInvoiceList(ApiResource):
|
|||
organization = model.get_organization(orgname)
|
||||
if not organization.stripe_id:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
return get_invoices(organization.stripe_id)
|
||||
|
||||
raise Unauthorized()
|
||||
|
|
|
@ -42,7 +42,7 @@ def user_view(user):
|
|||
|
||||
def trigger_view(trigger):
|
||||
|
||||
if trigger and trigger.uuid:
|
||||
if trigger and trigger.uuid:
|
||||
config_dict = get_trigger_config(trigger)
|
||||
build_trigger = BuildTrigger.get_trigger_for_service(trigger.service.name)
|
||||
return {
|
||||
|
@ -200,7 +200,7 @@ class RepositoryBuildStatus(RepositoryParamResource):
|
|||
if (not build or build.repository.name != repository or
|
||||
build.repository.namespace_user.username != namespace):
|
||||
raise NotFound()
|
||||
|
||||
|
||||
can_write = ModifyRepositoryPermission(namespace, repository).can()
|
||||
return build_status_view(build, can_write)
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
|
||||
if 'view_class' in dir(endpoint_method):
|
||||
view_class = endpoint_method.view_class
|
||||
|
||||
|
||||
param_data_map = {}
|
||||
if '__api_path_params' in dir(view_class):
|
||||
param_data_map = view_class.__api_path_params
|
||||
|
@ -126,7 +126,7 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
|
||||
if not internal or (internal and include_internal):
|
||||
# Swagger requires valid nicknames on all operations.
|
||||
if new_operation.get('nickname'):
|
||||
if new_operation.get('nickname'):
|
||||
operations.append(new_operation)
|
||||
else:
|
||||
logger.debug('Operation missing nickname: %s' % method)
|
||||
|
@ -149,7 +149,7 @@ def swagger_route_data(include_internal=False, compact=False):
|
|||
|
||||
if not internal or (internal and include_internal):
|
||||
apis.append(new_resource)
|
||||
|
||||
|
||||
# If compact form was requested, simply return the APIs.
|
||||
if compact:
|
||||
return {'apis': apis}
|
||||
|
|
|
@ -15,7 +15,7 @@ def log_view(log):
|
|||
view = {
|
||||
'kind': log.kind.name,
|
||||
'metadata': json.loads(log.metadata_json),
|
||||
'ip': log.ip,
|
||||
'ip': log.ip,
|
||||
'datetime': format_date(log.datetime),
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ def get_logs(start_time, end_time, performer_name=None, repository=None, namespa
|
|||
except ValueError:
|
||||
start_time = None
|
||||
|
||||
if not start_time:
|
||||
if not start_time:
|
||||
start_time = datetime.today() - timedelta(7) # One week
|
||||
|
||||
if end_time:
|
||||
|
@ -49,8 +49,8 @@ def get_logs(start_time, end_time, performer_name=None, repository=None, namespa
|
|||
end_time = end_time + timedelta(days=1)
|
||||
except ValueError:
|
||||
end_time = None
|
||||
|
||||
if not end_time:
|
||||
|
||||
if not end_time:
|
||||
end_time = datetime.today()
|
||||
|
||||
logs = model.list_logs(start_time, end_time, performer=performer, repository=repository,
|
||||
|
|
|
@ -143,7 +143,7 @@ class Organization(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
org_data = request.get_json()
|
||||
if 'invoice_email' in org_data:
|
||||
logger.debug('Changing invoice_email for organization: %s', org.username)
|
||||
|
@ -153,10 +153,10 @@ class Organization(ApiResource):
|
|||
new_email = org_data['email']
|
||||
if model.find_user_by_email(new_email):
|
||||
raise request_error(message='E-mail address already used')
|
||||
|
||||
|
||||
logger.debug('Changing email address for organization: %s', org.username)
|
||||
model.update_email(org, new_email)
|
||||
|
||||
|
||||
teams = model.get_teams_within_org(org)
|
||||
return org_view(org, teams)
|
||||
raise Unauthorized()
|
||||
|
@ -186,13 +186,13 @@ class OrgPrivateRepositories(ApiResource):
|
|||
plan = get_plan(cus.subscription.plan.id)
|
||||
if plan:
|
||||
repos_allowed = plan['privateRepos']
|
||||
|
||||
|
||||
data['privateAllowed'] = (private_repos < repos_allowed)
|
||||
|
||||
|
||||
|
||||
if AdministerOrganizationPermission(orgname).can():
|
||||
data['privateCount'] = private_repos
|
||||
|
||||
|
||||
return data
|
||||
|
||||
raise Unauthorized()
|
||||
|
@ -211,19 +211,19 @@ class OrgnaizationMemberList(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
# Loop to create the members dictionary. Note that the members collection
|
||||
# will return an entry for *every team* a member is on, so we will have
|
||||
# duplicate keys (which is why we pre-build the dictionary).
|
||||
members_dict = {}
|
||||
members = model.get_organization_members_with_teams(org)
|
||||
members = model.get_organization_members_with_teams(org)
|
||||
for member in members:
|
||||
if not member.user.username in members_dict:
|
||||
members_dict[member.user.username] = {'name': member.user.username,
|
||||
'kind': 'user',
|
||||
'is_robot': member.user.robot,
|
||||
'teams': []}
|
||||
|
||||
|
||||
members_dict[member.user.username]['teams'].append(member.team.name)
|
||||
|
||||
return {'members': members_dict}
|
||||
|
@ -244,7 +244,7 @@ class OrganizationMember(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
member_dict = None
|
||||
member_teams = model.get_organization_members_with_teams(org, membername=membername)
|
||||
for member in member_teams:
|
||||
|
@ -253,7 +253,7 @@ class OrganizationMember(ApiResource):
|
|||
'kind': 'user',
|
||||
'is_robot': member.user.robot,
|
||||
'teams': []}
|
||||
|
||||
|
||||
member_dict['teams'].append(member.team.name)
|
||||
|
||||
if not member_dict:
|
||||
|
@ -364,7 +364,7 @@ class OrganizationApplications(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
app_data = request.get_json()
|
||||
application = model.oauth.create_application(
|
||||
org, app_data['name'],
|
||||
|
@ -397,7 +397,7 @@ class OrganizationApplicationResource(ApiResource):
|
|||
'required': [
|
||||
'name',
|
||||
'redirect_uri',
|
||||
'application_uri'
|
||||
'application_uri'
|
||||
],
|
||||
'properties': {
|
||||
'name': {
|
||||
|
@ -452,7 +452,7 @@ class OrganizationApplicationResource(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
application = model.oauth.lookup_application(org, client_id)
|
||||
if not application:
|
||||
raise NotFound()
|
||||
|
@ -485,7 +485,7 @@ class OrganizationApplicationResource(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
application = model.oauth.delete_application(org, client_id)
|
||||
if not application:
|
||||
raise NotFound()
|
||||
|
@ -510,7 +510,7 @@ class OrganizationApplicationResetClientSecret(ApiResource):
|
|||
org = model.get_organization(orgname)
|
||||
except model.InvalidOrganizationException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
application = model.oauth.lookup_application(org, client_id)
|
||||
if not application:
|
||||
raise NotFound()
|
||||
|
|
|
@ -70,7 +70,7 @@ class RepositoryUserPermissionList(RepositoryParamResource):
|
|||
org_members)
|
||||
|
||||
role_view_func = wrapped_role_org_view
|
||||
|
||||
|
||||
# Load and return the permissions.
|
||||
repo_perms = model.get_all_repo_users(namespace, repository)
|
||||
return {
|
||||
|
@ -150,7 +150,7 @@ class RepositoryUserPermission(RepositoryParamResource):
|
|||
pass
|
||||
except model.DataModelException as ex:
|
||||
raise request_error(exception=ex)
|
||||
|
||||
|
||||
log_action('change_repo_permission', namespace,
|
||||
{'username': username, 'repo': repository,
|
||||
'role': new_permission['role']},
|
||||
|
@ -170,7 +170,7 @@ class RepositoryUserPermission(RepositoryParamResource):
|
|||
log_action('delete_repo_permission', namespace,
|
||||
{'username': username, 'repo': repository},
|
||||
repo=model.get_repository(namespace, repository))
|
||||
|
||||
|
||||
return 'Deleted', 204
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ def log_prototype_action(action_kind, orgname, prototype, **kwargs):
|
|||
log_params['delegate_user'] = prototype.delegate_user.username
|
||||
elif prototype.delegate_team:
|
||||
log_params['delegate_team'] = prototype.delegate_team.name
|
||||
|
||||
|
||||
log_action(action_kind, orgname, log_params)
|
||||
|
||||
|
||||
|
@ -100,7 +100,7 @@ class PermissionPrototypeList(ApiResource):
|
|||
'name': {
|
||||
'type': 'string',
|
||||
'description': 'The name for the delegate team or user',
|
||||
},
|
||||
},
|
||||
'kind': {
|
||||
'type': 'string',
|
||||
'description': 'Whether the delegate is a user or a team',
|
||||
|
@ -108,7 +108,7 @@ class PermissionPrototypeList(ApiResource):
|
|||
'user',
|
||||
'team',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -128,7 +128,7 @@ class PermissionPrototypeList(ApiResource):
|
|||
permissions = model.get_prototype_permissions(org)
|
||||
org_members = model.get_organization_member_set(orgname)
|
||||
return {'prototypes': [prototype_view(p, org_members) for p in permissions]}
|
||||
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
@nickname('createOrganizationPrototypePermission')
|
||||
|
@ -148,7 +148,7 @@ class PermissionPrototypeList(ApiResource):
|
|||
if ('activating_user' in details and details['activating_user'] and
|
||||
'name' in details['activating_user']):
|
||||
activating_username = details['activating_user']['name']
|
||||
|
||||
|
||||
delegate = details['delegate'] if 'delegate' in details else {}
|
||||
delegate_kind = delegate.get('kind', None)
|
||||
delegate_name = delegate.get('name', None)
|
||||
|
@ -174,7 +174,7 @@ class PermissionPrototypeList(ApiResource):
|
|||
log_prototype_action('create_prototype_permission', orgname, prototype)
|
||||
org_members = model.get_organization_member_set(orgname)
|
||||
return prototype_view(prototype, org_members)
|
||||
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
|
||||
|
@ -221,7 +221,7 @@ class PermissionPrototype(ApiResource):
|
|||
log_prototype_action('delete_prototype_permission', orgname, prototype)
|
||||
|
||||
return 'Deleted', 204
|
||||
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
@nickname('updateOrganizationPrototypePermission')
|
||||
|
@ -249,5 +249,5 @@ class PermissionPrototype(ApiResource):
|
|||
original_role=existing.role.name)
|
||||
org_members = model.get_organization_member_set(orgname)
|
||||
return prototype_view(prototype, org_members)
|
||||
|
||||
|
||||
raise Unauthorized()
|
||||
|
|
|
@ -45,7 +45,7 @@ class RepositoryAuthorizedEmail(RepositoryParamResource):
|
|||
@nickname('sendAuthorizeRepoEmail')
|
||||
def post(self, namespace, repository, email):
|
||||
""" Starts the authorization process for an e-mail address on a repository. """
|
||||
|
||||
|
||||
with tf(db):
|
||||
record = model.get_email_authorized_for_repo(namespace, repository, email)
|
||||
if record and record.confirmed:
|
||||
|
|
|
@ -201,7 +201,7 @@ class Repository(RepositoryParamResource):
|
|||
}
|
||||
|
||||
raise NotFound()
|
||||
|
||||
|
||||
@require_repo_write
|
||||
@nickname('updateRepo')
|
||||
@validate_json_request('RepoUpdate')
|
||||
|
@ -212,7 +212,7 @@ class Repository(RepositoryParamResource):
|
|||
values = request.get_json()
|
||||
repo.description = values['description']
|
||||
repo.save()
|
||||
|
||||
|
||||
log_action('set_repo_description', namespace,
|
||||
{'repo': repository, 'description': values['description']},
|
||||
repo=repo)
|
||||
|
|
|
@ -78,7 +78,7 @@ class RepositoryNotificationList(RepositoryParamResource):
|
|||
json['config'])
|
||||
|
||||
resp = notification_view(notification)
|
||||
log_action('add_repo_notification', namespace,
|
||||
log_action('add_repo_notification', namespace,
|
||||
{'repo': repository, 'notification_id': notification.uuid,
|
||||
'event': json['event'], 'method': json['method']},
|
||||
repo=repo)
|
||||
|
@ -117,7 +117,7 @@ class RepositoryNotification(RepositoryParamResource):
|
|||
def delete(self, namespace, repository, uuid):
|
||||
""" Deletes the specified notification. """
|
||||
notification = model.delete_repo_notification(namespace, repository, uuid)
|
||||
log_action('delete_repo_notification', namespace,
|
||||
log_action('delete_repo_notification', namespace,
|
||||
{'repo': repository, 'notification_id': uuid,
|
||||
'event': notification.event.name, 'method': notification.method.name},
|
||||
repo=model.get_repository(namespace, repository))
|
||||
|
|
|
@ -96,7 +96,7 @@ class OrgRobot(ApiResource):
|
|||
parent = model.get_organization(orgname)
|
||||
robot, password = model.get_robot(robot_shortname, parent)
|
||||
return robot_view(robot.username, password)
|
||||
|
||||
|
||||
raise Unauthorized()
|
||||
|
||||
@require_scope(scopes.ORG_ADMIN)
|
||||
|
|
|
@ -36,7 +36,7 @@ class EntitySearch(ApiResource):
|
|||
robot_namespace = namespace_name
|
||||
|
||||
if args['includeTeams']:
|
||||
teams = model.get_matching_teams(prefix, organization)
|
||||
teams = model.get_matching_teams(prefix, organization)
|
||||
|
||||
if args['includeOrgs'] and AdministerOrganizationPermission(namespace_name) \
|
||||
and namespace_name.startswith(prefix):
|
||||
|
@ -124,6 +124,6 @@ class FindRepositories(ApiResource):
|
|||
matching = model.get_matching_repositories(prefix, username)
|
||||
return {
|
||||
'repositories': [repo_view(repo) for repo in matching
|
||||
if (repo.visibility.name == 'public' or
|
||||
if (repo.visibility.name == 'public' or
|
||||
ReadRepositoryPermission(repo.namespace_user.username, repo.name).can())]
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ def subscribe(user, plan, token, require_business_plan):
|
|||
# They want a real paying plan, create the customer and plan
|
||||
# simultaneously
|
||||
card = token
|
||||
|
||||
|
||||
try:
|
||||
cus = billing.Customer.create(email=user.email, plan=plan, card=card)
|
||||
user.stripe_id = cus.id
|
||||
|
@ -116,7 +116,7 @@ def subscribe(user, plan, token, require_business_plan):
|
|||
return carderror_response(e)
|
||||
except stripe.APIConnectionError as e:
|
||||
return connection_response(e)
|
||||
|
||||
|
||||
response_json = subscription_view(cus.subscription, private_repos)
|
||||
check_repository_usage(user, plan_found)
|
||||
log_action('account_change_plan', user.username, {'plan': plan})
|
||||
|
|
|
@ -38,7 +38,7 @@ class SuperUserLogs(ApiResource):
|
|||
performer_name = args['performer']
|
||||
start_time = args['starttime']
|
||||
end_time = args['endtime']
|
||||
|
||||
|
||||
return get_logs(start_time, end_time)
|
||||
|
||||
abort(403)
|
||||
|
@ -196,7 +196,7 @@ class SuperUserManagement(ApiResource):
|
|||
user = model.get_user(username)
|
||||
if not user or user.organization or user.robot:
|
||||
abort(404)
|
||||
|
||||
|
||||
return user_view(user)
|
||||
|
||||
abort(403)
|
||||
|
@ -237,7 +237,7 @@ class SuperUserManagement(ApiResource):
|
|||
|
||||
if 'email' in user_data:
|
||||
model.update_email(user, user_data['email'])
|
||||
|
||||
|
||||
return user_view(user)
|
||||
|
||||
abort(403)
|
||||
|
|
|
@ -36,7 +36,7 @@ class RepositoryTag(RepositoryParamResource):
|
|||
image = model.get_repo_image(namespace, repository, image_id)
|
||||
if not image:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
original_image_id = None
|
||||
try:
|
||||
original_tag_image = model.get_tag_image(namespace, repository, tag)
|
||||
|
|
|
@ -28,7 +28,7 @@ def try_accept_invite(code, user):
|
|||
|
||||
|
||||
def handle_addinvite_team(inviter, team, user=None, email=None):
|
||||
invite = model.add_or_invite_to_team(inviter, team, user, email,
|
||||
invite = model.add_or_invite_to_team(inviter, team, user, email,
|
||||
requires_invite = features.MAILING)
|
||||
if not invite:
|
||||
# User was added to the team directly.
|
||||
|
@ -146,7 +146,7 @@ class OrganizationTeam(ApiResource):
|
|||
team = model.set_team_org_permission(team, details['role'],
|
||||
get_authenticated_user().username)
|
||||
log_action('org_set_team_role', orgname, {'team': teamname, 'role': details['role']})
|
||||
|
||||
|
||||
return team_view(orgname, team), 200
|
||||
|
||||
raise Unauthorized()
|
||||
|
@ -181,7 +181,7 @@ class TeamMemberList(ApiResource):
|
|||
team = model.get_organization_team(orgname, teamname)
|
||||
except model.InvalidTeamException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
members = model.get_organization_team_members(team.id)
|
||||
invites = []
|
||||
|
||||
|
@ -220,14 +220,14 @@ class TeamMember(ApiResource):
|
|||
user = model.get_user(membername)
|
||||
if not user:
|
||||
raise request_error(message='Unknown user')
|
||||
|
||||
|
||||
# Add or invite the user to the team.
|
||||
inviter = get_authenticated_user()
|
||||
invite = handle_addinvite_team(inviter, team, user=user)
|
||||
if not invite:
|
||||
log_action('org_add_team_member', orgname, {'member': membername, 'team': teamname})
|
||||
return member_view(user, invited=False)
|
||||
|
||||
|
||||
# User was invited.
|
||||
log_action('org_invite_team_member', orgname, {
|
||||
'user': membername,
|
||||
|
@ -254,7 +254,7 @@ class TeamMember(ApiResource):
|
|||
team = model.get_organization_team(orgname, teamname)
|
||||
except model.InvalidTeamException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
# Find the member.
|
||||
member = model.get_user(membername)
|
||||
if not member:
|
||||
|
@ -294,7 +294,7 @@ class InviteTeamMember(ApiResource):
|
|||
team = model.get_organization_team(orgname, teamname)
|
||||
except model.InvalidTeamException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
# Invite the email to the team.
|
||||
inviter = get_authenticated_user()
|
||||
invite = handle_addinvite_team(inviter, team, email=email)
|
||||
|
@ -320,7 +320,7 @@ class InviteTeamMember(ApiResource):
|
|||
team = model.get_organization_team(orgname, teamname)
|
||||
except model.InvalidTeamException:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
# Delete the invite.
|
||||
model.delete_team_email_invite(team, email)
|
||||
log_action('org_delete_team_member_invite', orgname, {
|
||||
|
@ -345,7 +345,7 @@ class TeamMemberInvite(ApiResource):
|
|||
# Accept the invite for the current user.
|
||||
team = try_accept_invite(code, get_authenticated_user())
|
||||
if not team:
|
||||
raise NotFound()
|
||||
raise NotFound()
|
||||
|
||||
orgname = team.organization.username
|
||||
return {
|
||||
|
|
|
@ -76,7 +76,7 @@ class BuildTrigger(RepositoryParamResource):
|
|||
# We are just going to eat this error
|
||||
logger.warning('Trigger deactivation problem: %s', ex)
|
||||
|
||||
log_action('delete_repo_trigger', namespace,
|
||||
log_action('delete_repo_trigger', namespace,
|
||||
{'repo': repository, 'trigger_id': trigger_uuid,
|
||||
'service': trigger.service.name, 'config': config_dict},
|
||||
repo=model.get_repository(namespace, repository))
|
||||
|
@ -192,7 +192,7 @@ class BuildTriggerActivate(RepositoryParamResource):
|
|||
|
||||
# Make sure the namespace matches that of the trigger.
|
||||
if robot_namespace != namespace:
|
||||
raise Unauthorized()
|
||||
raise Unauthorized()
|
||||
|
||||
# Set the pull robot.
|
||||
trigger.pull_robot = pull_robot
|
||||
|
@ -224,7 +224,7 @@ class BuildTriggerActivate(RepositoryParamResource):
|
|||
repo = model.get_repository(namespace, repository)
|
||||
log_action('setup_repo_trigger', namespace,
|
||||
{'repo': repository, 'namespace': namespace,
|
||||
'trigger_id': trigger.uuid, 'service': trigger.service.name,
|
||||
'trigger_id': trigger.uuid, 'service': trigger.service.name,
|
||||
'pull_robot': trigger.pull_robot.username if trigger.pull_robot else None,
|
||||
'config': final_config}, repo=repo)
|
||||
|
||||
|
@ -284,7 +284,7 @@ class BuildTriggerAnalyze(RepositoryParamResource):
|
|||
'status': 'error',
|
||||
'message': 'Could not parse the Dockerfile specified'
|
||||
}
|
||||
|
||||
|
||||
# Determine the base image (i.e. the FROM) for the Dockerfile.
|
||||
base_image = parsed.get_base_image()
|
||||
if not base_image:
|
||||
|
@ -346,7 +346,7 @@ class BuildTriggerAnalyze(RepositoryParamResource):
|
|||
# Make sure the current user can see/administer the robot.
|
||||
(robot_namespace, shortname) = parse_robot_username(user.username)
|
||||
return AdministerOrganizationPermission(robot_namespace).can()
|
||||
|
||||
|
||||
repo_users = list(model.get_all_repo_users_transitive(base_namespace, base_repository))
|
||||
read_robots = [robot_view(user) for user in repo_users if is_valid_robot(user)]
|
||||
|
||||
|
@ -366,7 +366,7 @@ class BuildTriggerAnalyze(RepositoryParamResource):
|
|||
}
|
||||
|
||||
raise NotFound()
|
||||
|
||||
|
||||
|
||||
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/start')
|
||||
class ActivateBuildTrigger(RepositoryParamResource):
|
||||
|
@ -462,7 +462,7 @@ class BuildTriggerFieldValues(RepositoryParamResource):
|
|||
|
||||
if values is None:
|
||||
raise NotFound()
|
||||
|
||||
|
||||
return {
|
||||
'values': values
|
||||
}
|
||||
|
@ -486,7 +486,7 @@ class BuildTriggerSources(RepositoryParamResource):
|
|||
user_permission = UserAdminPermission(trigger.connected_user.username)
|
||||
if user_permission.can():
|
||||
trigger_handler = BuildTriggerBase.get_trigger_for_service(trigger.service.name)
|
||||
|
||||
|
||||
return {
|
||||
'sources': trigger_handler.list_build_sources(trigger.auth_token)
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ class User(ApiResource):
|
|||
user = get_authenticated_user()
|
||||
user_data = request.get_json()
|
||||
|
||||
try:
|
||||
try:
|
||||
if 'password' in user_data:
|
||||
logger.debug('Changing password for user: %s', user.username)
|
||||
log_action('account_change_password', user.username)
|
||||
|
@ -189,8 +189,8 @@ class User(ApiResource):
|
|||
if model.find_user_by_email(new_email):
|
||||
# Email already used.
|
||||
raise request_error(message='E-mail address already used')
|
||||
|
||||
if features.MAILING:
|
||||
|
||||
if features.MAILING:
|
||||
logger.debug('Sending email to change email address for user: %s',
|
||||
user.username)
|
||||
code = model.create_confirm_email_code(user, new_email=new_email)
|
||||
|
@ -206,7 +206,7 @@ class User(ApiResource):
|
|||
raise request_error(message='Username is already in use')
|
||||
|
||||
model.change_username(user, new_username)
|
||||
|
||||
|
||||
except model.InvalidPasswordException, ex:
|
||||
raise request_error(exception=ex)
|
||||
|
||||
|
@ -275,7 +275,7 @@ class PrivateRepositories(ApiResource):
|
|||
plan = get_plan(cus.subscription.plan.id)
|
||||
if plan:
|
||||
repos_allowed = plan['privateRepos']
|
||||
|
||||
|
||||
return {
|
||||
'privateCount': private_repos,
|
||||
'privateAllowed': (private_repos < repos_allowed)
|
||||
|
|
|
@ -37,4 +37,4 @@ def csrf_protect(func):
|
|||
return wrapper
|
||||
|
||||
|
||||
app.jinja_env.globals['csrf_token'] = generate_csrf_token
|
||||
app.jinja_env.globals['csrf_token'] = generate_csrf_token
|
||||
|
|
|
@ -146,7 +146,7 @@ def get_user():
|
|||
'username': '$oauthtoken',
|
||||
'email': None,
|
||||
})
|
||||
elif get_authenticated_user():
|
||||
elif get_authenticated_user():
|
||||
return jsonify({
|
||||
'username': get_authenticated_user().username,
|
||||
'email': get_authenticated_user().email,
|
||||
|
@ -205,7 +205,7 @@ def create_repository(namespace, repository):
|
|||
elif repo:
|
||||
permission = ModifyRepositoryPermission(namespace, repository)
|
||||
if not permission.can():
|
||||
abort(403,
|
||||
abort(403,
|
||||
message='You do not have permission to modify repository %(namespace)s/%(repository)s',
|
||||
issue='no-repo-write-permission',
|
||||
namespace=namespace, repository=repository)
|
||||
|
@ -214,7 +214,7 @@ def create_repository(namespace, repository):
|
|||
permission = CreateRepositoryPermission(namespace)
|
||||
if not permission.can():
|
||||
logger.info('Attempt to create a new repo with insufficient perms.')
|
||||
abort(403,
|
||||
abort(403,
|
||||
message='You do not have permission to create repositories in namespace "%(namespace)s"',
|
||||
issue='no-create-permission',
|
||||
namespace=namespace)
|
||||
|
@ -369,7 +369,7 @@ def get_search():
|
|||
matching = []
|
||||
|
||||
results = [result_view(repo) for repo in matching
|
||||
if (repo.visibility.name == 'public' or
|
||||
if (repo.visibility.name == 'public' or
|
||||
ReadRepositoryPermission(repo.namespace_user.username, repo.name).can())]
|
||||
|
||||
data = {
|
||||
|
|
|
@ -83,7 +83,7 @@ class BuildQueueEvent(NotificationEvent):
|
|||
|
||||
def get_level(self, event_data, notification_data):
|
||||
return 'info'
|
||||
|
||||
|
||||
def get_sample_data(self, repository):
|
||||
build_uuid = 'fake-build-id'
|
||||
|
||||
|
@ -94,9 +94,9 @@ class BuildQueueEvent(NotificationEvent):
|
|||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_kind': 'GitHub'
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build queued for repository %s' % (event_data['repository'])
|
||||
return 'Build queued for repository %s' % (event_data['repository'])
|
||||
|
||||
|
||||
class BuildStartEvent(NotificationEvent):
|
||||
|
@ -116,7 +116,7 @@ class BuildStartEvent(NotificationEvent):
|
|||
'docker_tags': ['latest', 'foo', 'bar'],
|
||||
'trigger_kind': 'GitHub'
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build started for repository %s' % (event_data['repository'])
|
||||
|
||||
|
@ -161,7 +161,7 @@ class BuildFailureEvent(NotificationEvent):
|
|||
'trigger_kind': 'GitHub',
|
||||
'error_message': 'This is a fake error message'
|
||||
}, subpage='/build?current=%s' % build_uuid)
|
||||
|
||||
|
||||
def get_summary(self, event_data, notification_data):
|
||||
return 'Build failure for repository %s' % (event_data['repository'])
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import json
|
|||
|
||||
def build_event_data(repo, extra_data={}, subpage=None):
|
||||
repo_string = '%s/%s' % (repo.namespace_user.username, repo.name)
|
||||
homepage = '%s://%s/repository/%s' % (app.config['PREFERRED_URL_SCHEME'],
|
||||
homepage = '%s://%s/repository/%s' % (app.config['PREFERRED_URL_SCHEME'],
|
||||
app.config['SERVER_HOSTNAME'],
|
||||
repo_string)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ class NotificationMethod(object):
|
|||
Validates that the notification can be created with the given data. Throws
|
||||
a CannotValidateNotificationMethodException on failure.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
raise NotImplementedError
|
||||
|
||||
def perform(self, notification, event_handler, notification_data):
|
||||
"""
|
||||
|
@ -70,7 +70,7 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
status, err_message, target_users = self.find_targets(repository, config_data)
|
||||
if err_message:
|
||||
raise CannotValidateNotificationMethodException(err_message)
|
||||
|
||||
|
||||
def find_targets(self, repository, config_data):
|
||||
target_info = config_data['target']
|
||||
|
||||
|
@ -100,7 +100,7 @@ class QuayNotificationMethod(NotificationMethod):
|
|||
except model.InvalidTeamException:
|
||||
# Probably deleted.
|
||||
return (True, 'Unknown team %s' % target_info['name'], None)
|
||||
|
||||
|
||||
# Lookup the team's members
|
||||
return (True, None, model.get_organization_team_members(team.id))
|
||||
|
||||
|
@ -194,7 +194,7 @@ class WebhookMethod(NotificationMethod):
|
|||
|
||||
class FlowdockMethod(NotificationMethod):
|
||||
""" Method for sending notifications to Flowdock via the Team Inbox API:
|
||||
https://www.flowdock.com/api/team-inbox
|
||||
https://www.flowdock.com/api/team-inbox
|
||||
"""
|
||||
@classmethod
|
||||
def method_name(cls):
|
||||
|
@ -288,7 +288,7 @@ class HipchatMethod(NotificationMethod):
|
|||
'color': color,
|
||||
'message': event_handler.get_message(notification_data['event_data'], notification_data),
|
||||
'notify': level == 'error',
|
||||
'message_format': 'html',
|
||||
'message_format': 'html',
|
||||
}
|
||||
|
||||
try:
|
||||
|
|
|
@ -59,4 +59,4 @@ def track_and_log(event_name, repo, **kwargs):
|
|||
model.log_action(event_name, namespace,
|
||||
performer=get_authenticated_user(),
|
||||
ip=request.remote_addr, metadata=metadata,
|
||||
repository=repo)
|
||||
repository=repo)
|
||||
|
|
|
@ -100,7 +100,7 @@ class BuildTrigger(object):
|
|||
raise NotImplementedError
|
||||
|
||||
def activate(self, trigger_uuid, standard_webhook_url, auth_token, config):
|
||||
"""
|
||||
"""
|
||||
Activates the trigger for the service, with the given new configuration.
|
||||
Returns new configuration that should be stored if successful.
|
||||
"""
|
||||
|
@ -246,7 +246,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
gh_client = self._get_client(auth_token)
|
||||
source = config['build_source']
|
||||
|
||||
try:
|
||||
try:
|
||||
repo = gh_client.get_repo(source)
|
||||
|
||||
# Find the first matching branch.
|
||||
|
@ -381,7 +381,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
raise SkipRequestException()
|
||||
|
||||
if should_skip_commit(commit_message):
|
||||
raise SkipRequestException()
|
||||
raise SkipRequestException()
|
||||
|
||||
short_sha = GithubBuildTrigger.get_display_name(commit_sha)
|
||||
|
||||
|
@ -419,7 +419,7 @@ class GithubBuildTrigger(BuildTrigger):
|
|||
branches = self.list_field_values(auth_token, config, 'branch_name')
|
||||
tags = self.list_field_values(auth_token, config, 'tag_name')
|
||||
|
||||
return ([{'kind': 'branch', 'name': b} for b in branches] +
|
||||
return ([{'kind': 'branch', 'name': b} for b in branches] +
|
||||
[{'kind': 'tag', 'name': tag} for tag in tags])
|
||||
|
||||
if field_name == 'tag_name':
|
||||
|
|
|
@ -40,7 +40,7 @@ def _open_stream(namespace, repository, tag, synthetic_image_id, image_json, ima
|
|||
current_image_path = store.image_layer_path(current_image_entry.storage.uuid)
|
||||
current_image_stream = store.stream_read_file(current_image_entry.storage.locations,
|
||||
current_image_path)
|
||||
|
||||
|
||||
current_image_id = current_image_entry.id
|
||||
logger.debug('Returning image layer %s: %s' % (current_image_id, current_image_path))
|
||||
yield current_image_stream
|
||||
|
@ -56,7 +56,7 @@ def _write_synthetic_image_to_storage(linked_storage_uuid, linked_locations, que
|
|||
|
||||
def handle_exception(ex):
|
||||
logger.debug('Exception when building squashed image %s: %s', linked_storage_uuid, ex)
|
||||
|
||||
|
||||
with database.UseThenDisconnect(app.config):
|
||||
model.delete_derived_storage_by_uuid(linked_storage_uuid)
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ def receipt():
|
|||
invoice = stripe.Invoice.retrieve(invoice_id)
|
||||
if invoice:
|
||||
user_or_org = model.get_user_or_org_by_customer_id(invoice.customer)
|
||||
|
||||
|
||||
if user_or_org:
|
||||
if user_or_org.organization:
|
||||
admin_org = AdministerOrganizationPermission(user_or_org.username)
|
||||
|
@ -244,9 +244,9 @@ def receipt():
|
|||
else:
|
||||
if not user_or_org.username == current_user.db_user().username:
|
||||
abort(404)
|
||||
return
|
||||
return
|
||||
|
||||
file_data = renderInvoiceToPdf(invoice, user_or_org)
|
||||
file_data = renderInvoiceToPdf(invoice, user_or_org)
|
||||
return Response(file_data,
|
||||
mimetype="application/pdf",
|
||||
headers={"Content-Disposition": "attachment;filename=receipt.pdf"})
|
||||
|
@ -263,7 +263,7 @@ def confirm_repo_email():
|
|||
record = model.confirm_email_authorization_for_repo(code)
|
||||
except model.DataModelException as ex:
|
||||
return render_page_template('confirmerror.html', error_message=ex.message)
|
||||
|
||||
|
||||
message = """
|
||||
Your E-mail address has been authorized to receive notifications for repository
|
||||
<a href="%s://%s/repository/%s/%s">%s/%s</a>.
|
||||
|
@ -285,13 +285,13 @@ def confirm_email():
|
|||
user, new_email, old_email = model.confirm_user_email(code)
|
||||
except model.DataModelException as ex:
|
||||
return render_page_template('confirmerror.html', error_message=ex.message)
|
||||
|
||||
|
||||
if new_email:
|
||||
send_email_changed(user.username, old_email, new_email)
|
||||
|
||||
common_login(user)
|
||||
|
||||
return redirect(url_for('web.user', tab='email')
|
||||
return redirect(url_for('web.user', tab='email')
|
||||
if new_email else url_for('web.index'))
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ def stripe_webhook():
|
|||
@process_auth
|
||||
def build_trigger_webhook(trigger_uuid, **kwargs):
|
||||
logger.debug('Webhook received with uuid %s', trigger_uuid)
|
||||
|
||||
|
||||
try:
|
||||
trigger = model.get_build_trigger(trigger_uuid)
|
||||
except model.InvalidBuildTriggerException:
|
||||
|
|
Reference in a new issue