1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-09-19 18:31:16 +00:00
AdvLabDB/cli/maintain/copy_admin_templates.py

51 lines
1.4 KiB
Python
Raw Normal View History

2022-08-14 00:54:22 +00:00
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<ul class="navbar-nav mr-auto">
| Becomes:\t<ul class="nav navbar-nav mr-auto">
|
| This will prevent the navigation bar from expanding
| such that some elements can not be seen.
| Refer to this pull request:
| https://github.com/flask-admin/flask-admin/pull/2233
|
| If the above pull request is merged and flask-admin
| is on a new release after the merge,
| then this step is not needed.
_________
""",
fg="yellow",
)
)