Commit fc014701 authored by Alexander Philipp Nowosad's avatar Alexander Philipp Nowosad
Browse files

Fix load docs only one time

parent 71e1b7aa
Pipeline #139482 passed with stages
in 10 minutes and 13 seconds
......@@ -54,7 +54,7 @@ def db(ctx, server, name):
@click.argument('initdata', type=click.File('rb'), nargs=-1)
def init(database, initdata):
management.init_db(database, initdata)
management.init_db(database, initdata=initdata)
'Sucessfully initialized database {}.'.format(,
......@@ -21,14 +21,16 @@ def check_server_maintenance_mode(server):
def set_server_maintenance(server, value):
def init_db(database, initdata):
def init_db(database, initdata=None, docs=None):
if not Expressions.GROUP.match(
raise ManagementException(
'Database for group should have the form "group[0-9]+"'
if len(initdata) > 0:
if initdata is not None and len(initdata) > 0:
if docs is not None:
'members': { 'roles': ['_admin',, 'mgmt_backup'] },
'admins': { 'roles': ['_admin'] }
......@@ -81,6 +83,7 @@ def init_server(server, usersfile, passwordsfile, initdata):
writer = utils.csv_writer(passwordsfile)
users = utils.import_csv(usersfile)
groups = defaultdict(list)
docs = utils.import_docs(initdata)
for i, (username, group) in enumerate(users):
if not Expressions.GROUP.match(group):
raise ManagementException(
......@@ -94,7 +97,7 @@ def init_server(server, usersfile, passwordsfile, initdata):
database.server = server = group
if not database.exists():
init_db(database, initdata)
init_db(database, docs=docs)
for username in users:
user = User()
user.server = server
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment