Accidental refactor, split out legacy.py into separate sumodules and update all call sites.
This commit is contained in:
parent
2109d24483
commit
3efaa255e8
92 changed files with 4458 additions and 4269 deletions
|
@ -27,7 +27,8 @@ bad_count = 0
|
|||
good_count = 0
|
||||
|
||||
def resolve_or_create(repo, docker_image_id, new_ancestry):
|
||||
existing = model.get_repo_image_extended(repo.namespace_user.username, repo.name, docker_image_id)
|
||||
existing = model.image.get_repo_image_extended(repo.namespace_user.username, repo.name,
|
||||
docker_image_id)
|
||||
if existing:
|
||||
logger.debug('Found existing image: %s, %s', existing.id, docker_image_id)
|
||||
return existing
|
||||
|
@ -63,8 +64,8 @@ def all_ancestors_exist(ancestors):
|
|||
cant_fix = []
|
||||
for img in query:
|
||||
try:
|
||||
with_locations = model.get_repo_image_extended(img.repository.namespace_user.username,
|
||||
img.repository.name, img.docker_image_id)
|
||||
with_locations = model.image.get_repo_image_extended(img.repository.namespace_user.username,
|
||||
img.repository.name, img.docker_image_id)
|
||||
ancestry_storage = store.image_ancestry_path(img.storage.uuid)
|
||||
if store.exists(with_locations.storage.locations, ancestry_storage):
|
||||
full_ancestry = json.loads(store.get_content(with_locations.storage.locations,
|
||||
|
|
|
@ -18,7 +18,7 @@ def sendInvoice(invoice_id):
|
|||
return
|
||||
|
||||
customer_id = invoice['customer']
|
||||
user = model.get_user_or_org_by_customer_id(customer_id)
|
||||
user = model.user.get_user_or_org_by_customer_id(customer_id)
|
||||
if not user:
|
||||
print 'No user found for customer %s' % (customer_id)
|
||||
return
|
||||
|
|
|
@ -17,7 +17,7 @@ def get_private_allowed(customer):
|
|||
# Find customers who have more private repositories than their plans allow
|
||||
users = User.select()
|
||||
|
||||
usage = [(user.username, model.get_private_repo_count(user.username),
|
||||
usage = [(user.username, model.user.get_private_repo_count(user.username),
|
||||
get_private_allowed(user)) for user in users]
|
||||
|
||||
for username, used, allowed in usage:
|
||||
|
|
|
@ -59,9 +59,9 @@ if __name__ == "__main__":
|
|||
|
||||
images = []
|
||||
if args.imageid is not None:
|
||||
images = [model.get_image_by_id(args.namespace, args.repository, args.imageid)]
|
||||
images = [model.image.get_image_by_id(args.namespace, args.repository, args.imageid)]
|
||||
else:
|
||||
images = model.get_repository_images(args.namespace, args.repository)
|
||||
images = model.image.get_repository_images(args.namespace, args.repository)
|
||||
|
||||
for img in images:
|
||||
migrate_image(img, location)
|
||||
|
|
|
@ -7,16 +7,16 @@ def renameUser(username, new_name):
|
|||
if username == new_name:
|
||||
raise Exception('Must give a new username')
|
||||
|
||||
check = model.get_user_or_org(new_name)
|
||||
check = model.user.get_user_or_org(new_name)
|
||||
if check is not None:
|
||||
raise Exception('New username %s already exists' % new_name)
|
||||
|
||||
existing = model.get_user_or_org(username)
|
||||
existing = model.user.get_user_or_org(username)
|
||||
if existing is None:
|
||||
raise Exception('Username %s does not exist' % username)
|
||||
|
||||
print 'Renaming user...'
|
||||
model.change_username(existing.id, new_name)
|
||||
model.user.change_username(existing.id, new_name)
|
||||
print 'Rename complete'
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ def sendInvoice(invoice_id):
|
|||
return
|
||||
|
||||
customer_id = invoice['customer']
|
||||
user = model.get_user_or_org_by_customer_id(customer_id)
|
||||
user = model.user.get_user_or_org_by_customer_id(customer_id)
|
||||
if not user:
|
||||
print 'No user found for customer %s' % (customer_id)
|
||||
return
|
||||
|
|
|
@ -10,14 +10,14 @@ from flask import Flask, current_app
|
|||
from flask_mail import Mail
|
||||
|
||||
def sendConfirmation(username):
|
||||
user = model.get_nonrobot_user(username)
|
||||
user = model.user.get_nonrobot_user(username)
|
||||
if not user:
|
||||
print 'No user found'
|
||||
return
|
||||
|
||||
|
||||
with app.app_context():
|
||||
code = model.create_confirm_email_code(user)
|
||||
code = model.user.create_confirm_email_code(user)
|
||||
send_confirmation_email(user.username, user.email, code.code)
|
||||
print 'Email sent to %s' % (user.email)
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ from flask import Flask, current_app
|
|||
from flask_mail import Mail
|
||||
|
||||
def sendReset(username):
|
||||
user = model.get_nonrobot_user(username)
|
||||
user = model.user.get_nonrobot_user(username)
|
||||
if not user:
|
||||
print 'No user found'
|
||||
return
|
||||
|
||||
|
||||
with app.app_context():
|
||||
code = model.create_reset_password_email_code(user.email)
|
||||
code = model.user.create_reset_password_email_code(user.email)
|
||||
send_recovery_email(user.email, code.code)
|
||||
print 'Email sent to %s' % (user.email)
|
||||
|
||||
|
|
Reference in a new issue