1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-14 21:40:43 +00:00
AdvLabDB/advlabdb/scripts/maintain/copy_admin_templates.py

56 lines
1.7 KiB
Python
Raw Normal View History

2021-05-17 16:49:56 +00:00
from os.path import exists
from shutil import copytree, rmtree
2021-06-02 21:43:41 +00:00
2021-05-17 16:49:56 +00:00
from flask_admin import __file__ as flaskAdminPath
2021-05-17 20:36:24 +00:00
2021-05-17 16:49:56 +00:00
def copyAdminTemplates():
2022-03-02 22:35:20 +00:00
src = flaskAdminPath.removesuffix("__init__.py") + "templates/bootstrap4/admin"
2021-05-17 16:49:56 +00:00
if not exists(src):
print("Templates could not be found in", src)
print("You can also copy them manually.")
return False
dist = "advlabdb/templates/admin"
if exists(dist):
while True:
2021-06-02 21:43:41 +00:00
ans = input(
f"The directory {dist} already exists. Enter 'o' to override it and update the templates or enter 's' to stop the process: "
).lower()
2021-05-17 16:49:56 +00:00
if ans == "s":
print("Process stopped!")
return False
elif ans == "o":
break
rmtree(dist)
print("Old templates deleted!")
copytree(src, dist)
print("Copied", src, "->", dist)
2022-03-03 02:03:48 +00:00
print(
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.
_________
"""
)
2021-05-17 16:49:56 +00:00
return True
2021-05-17 20:36:24 +00:00
2021-05-17 16:49:56 +00:00
if __name__ == "__main__":
2022-03-03 02:03:48 +00:00
if not copyAdminTemplates():
2021-05-17 16:49:56 +00:00
print("Did not copy!")