From 754dae1fce57ca00d6d2040a23ea79f7b394bd2e Mon Sep 17 00:00:00 2001 From: Mo8it Date: Sun, 14 Aug 2022 02:54:22 +0200 Subject: [PATCH] Split manage.py --- advlabdb/templates/admin/model/list.html | 0 .../templates/admin/model/modals/details.html | 0 cli/maintain/copy_admin_templates.py | 50 ++ cli/maintain/reset_admin_password.py | 51 ++ cli/setup/generate_secrets.py | 21 + cli/setup/init_db.py | 90 ++++ cli/test/generate_test_db.py | 247 ++++++++++ manage.py | 451 +----------------- scripts/setup/logged_server_setup.py | 43 -- 9 files changed, 478 insertions(+), 475 deletions(-) mode change 100644 => 100755 advlabdb/templates/admin/model/list.html mode change 100644 => 100755 advlabdb/templates/admin/model/modals/details.html create mode 100644 cli/maintain/copy_admin_templates.py create mode 100644 cli/maintain/reset_admin_password.py create mode 100644 cli/setup/generate_secrets.py create mode 100644 cli/setup/init_db.py create mode 100644 cli/test/generate_test_db.py delete mode 100644 scripts/setup/logged_server_setup.py diff --git a/advlabdb/templates/admin/model/list.html b/advlabdb/templates/admin/model/list.html old mode 100644 new mode 100755 diff --git a/advlabdb/templates/admin/model/modals/details.html b/advlabdb/templates/admin/model/modals/details.html old mode 100644 new mode 100755 diff --git a/cli/maintain/copy_admin_templates.py b/cli/maintain/copy_admin_templates.py new file mode 100644 index 0000000..242b2ad --- /dev/null +++ b/cli/maintain/copy_admin_templates.py @@ -0,0 +1,50 @@ +from pathlib import Path +from shutil import copytree, rmtree + +import click +from flask_admin import __file__ as flask_admin_path + + +def _copy_admin_templates(): + src = Path(flask_admin_path).parent / "templates/bootstrap4/admin" + if not src.is_dir(): + click.echo(click.style(f"Templates could not be found at {src}", fg="red")) + return + + dist = Path("advlabdb/templates/admin") + if dist.is_dir(): + if not click.confirm( + click.style(f"The directory {dist} already exists! Do you want to overwrite it?", fg="yellow") + ): + return + + rmtree(dist) + click.echo(click.style("Old templates deleted!", fg="yellow")) + + copytree(src, dist) + click.echo(click.style(f"Copied {src} -> {dist}", fg="green")) + + click.echo( + click.style( + f""" +_________ +| WARNING +| ------- +| You might have to edit the file {dist}/base.html +| by adding nav in the following way: +| This line:\t