Rename database_error
This commit is contained in:
parent
aed7a520bd
commit
bba741b4a5
@ -83,7 +83,7 @@ def admin() -> str:
|
||||
configuration=BrickConfigurationList.list(),
|
||||
brickset_checkboxes=brickset_checkboxes,
|
||||
database_counters=database_counters,
|
||||
database_error=request.args.get('error'),
|
||||
database_error=request.args.get('database_error'),
|
||||
database_exception=database_exception,
|
||||
database_upgrade_needed=database_upgrade_needed,
|
||||
database_version=database_version,
|
||||
|
@ -38,14 +38,18 @@ def delete() -> str:
|
||||
return render_template(
|
||||
'admin.html',
|
||||
delete_database=True,
|
||||
error=request.args.get('error')
|
||||
database_error=request.args.get('database_error')
|
||||
)
|
||||
|
||||
|
||||
# Actually delete the database
|
||||
@admin_database_page.route('/delete', methods=['POST'])
|
||||
@login_required
|
||||
@exception_handler(__file__, post_redirect='admin_database.delete')
|
||||
@exception_handler(
|
||||
__file__,
|
||||
post_redirect='admin_database.delete',
|
||||
error_name='database_error'
|
||||
)
|
||||
def do_delete() -> Response:
|
||||
BrickSQL.delete()
|
||||
|
||||
@ -89,14 +93,18 @@ def drop() -> str:
|
||||
return render_template(
|
||||
'admin.html',
|
||||
drop_database=True,
|
||||
error=request.args.get('error')
|
||||
database_error=request.args.get('database_error')
|
||||
)
|
||||
|
||||
|
||||
# Actually drop the database
|
||||
@admin_database_page.route('/drop', methods=['POST'])
|
||||
@login_required
|
||||
@exception_handler(__file__, post_redirect='admin_database.drop')
|
||||
@exception_handler(
|
||||
__file__,
|
||||
post_redirect='admin_database.drop',
|
||||
error_name='database_error'
|
||||
)
|
||||
def do_drop() -> Response:
|
||||
BrickSQL.drop()
|
||||
|
||||
@ -108,7 +116,11 @@ def do_drop() -> Response:
|
||||
# Actually upgrade the database
|
||||
@admin_database_page.route('/upgrade', methods=['POST'])
|
||||
@login_required
|
||||
@exception_handler(__file__, post_redirect='admin_database.upgrade')
|
||||
@exception_handler(
|
||||
__file__,
|
||||
post_redirect='admin_database.upgrade',
|
||||
error_name='database_error'
|
||||
)
|
||||
def do_upgrade() -> Response:
|
||||
BrickSQL(failsafe=True).upgrade()
|
||||
|
||||
@ -125,14 +137,18 @@ def upload() -> str:
|
||||
return render_template(
|
||||
'admin.html',
|
||||
import_database=True,
|
||||
error=request.args.get('error')
|
||||
database_error=request.args.get('database_error')
|
||||
)
|
||||
|
||||
|
||||
# Actually import a database
|
||||
@admin_database_page.route('/import', methods=['POST'])
|
||||
@login_required
|
||||
@exception_handler(__file__, post_redirect='admin_database.upload')
|
||||
@exception_handler(
|
||||
__file__,
|
||||
post_redirect='admin_database.upload',
|
||||
error_name='database_error'
|
||||
)
|
||||
def do_upload() -> Response:
|
||||
file = upload_helper(
|
||||
'database',
|
||||
@ -153,7 +169,7 @@ def do_upload() -> Response:
|
||||
# Upgrade the database
|
||||
@admin_database_page.route('/upgrade', methods=['GET'])
|
||||
@login_required
|
||||
@exception_handler(__file__, post_redirect='admin.admin')
|
||||
@exception_handler(__file__)
|
||||
def upgrade() -> str | Response:
|
||||
database = BrickSQL(failsafe=True)
|
||||
|
||||
@ -166,5 +182,5 @@ def upgrade() -> str | Response:
|
||||
migrations=BrickSQLMigrationList().pending(
|
||||
database.version
|
||||
),
|
||||
error=request.args.get('error')
|
||||
database_error=request.args.get('database_error')
|
||||
)
|
||||
|
@ -36,7 +36,7 @@
|
||||
{{ accordion.footer() }}
|
||||
|
||||
{{ accordion.header('Database danger zone', 'database-danger', 'admin', danger=true, class='text-end') }}
|
||||
{% if error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
|
||||
{% if database_error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ database_error }}.</div>{% endif %}
|
||||
<a href="{{ url_for('admin_database.upload') }}" class="btn btn-warning" role="button"><i class="ri-upload-line"></i> Import a database file</a>
|
||||
<a href="{{ url_for('admin_database.drop') }}" class="btn btn-danger" role="button"><i class="ri-close-line"></i> Drop the database</a>
|
||||
<a href="{{ url_for('admin_database.delete') }}" class="btn btn-danger" role="button"><i class="ri-delete-bin-2-line"></i> Delete the database file</a>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{{ accordion.header('Database danger zone', 'database-danger', 'admin', expanded=true, danger=true, class='text-end') }}
|
||||
<form action="{{ url_for('admin_database.do_delete') }}" method="post">
|
||||
{% if error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
|
||||
{% if database_error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ database_error }}.</div>{% endif %}
|
||||
<div class="alert alert-danger text-center" role="alert">You are about to <strong>delete the database file</strong>. This action is irreversible.</div>
|
||||
<a class="btn btn-danger" href="{{ url_for('admin.admin') }}" role="button"><i class="ri-arrow-left-long-line"></i> Back to the admin</a>
|
||||
<button type="submit" class="btn btn-danger"><i class="ri-delete-bin-2-line"></i> Delete <strong>the database file</strong></button>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{{ accordion.header('Database danger zone', 'database-danger', 'admin', expanded=true, danger=true, class='text-end') }}
|
||||
<form action="{{ url_for('admin_database.do_drop') }}" method="post">
|
||||
{% if error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
|
||||
{% if database_error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ database_error }}.</div>{% endif %}
|
||||
<div class="alert alert-danger text-center" role="alert">You are about to <strong>drop all the tables from the database</strong>. This action is irreversible.</div>
|
||||
<a class="btn btn-danger" href="{{ url_for('admin.admin') }}" role="button"><i class="ri-arrow-left-long-line"></i> Back to the admin</a>
|
||||
<button type="submit" class="btn btn-danger"><i class="ri-close-line"></i> Drop <strong>the whole database</strong></button>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{{ accordion.header('Database danger zone', 'database-danger', 'admin', expanded=true, danger=true) }}
|
||||
<form action="{{ url_for('admin_database.do_upload') }}" method="post" enctype="multipart/form-data">
|
||||
{% if error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
|
||||
{% if database_error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ database_error }}.</div>{% endif %}
|
||||
<div class="alert alert-warning text-center" role="alert">You are about to <strong>import a database file</strong>. This will replace the <strong>whole content</strong> of the database. This action is irreversible.</div>
|
||||
<div class="mb-3">
|
||||
<label for="database" class="form-label">New database file</label>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{{ accordion.header('Database', 'database', 'admin', expanded=true, icon='database-2-line') }}
|
||||
<form action="{{ url_for('admin_database.do_upgrade') }}" method="post">
|
||||
{% if error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ error }}.</div>{% endif %}
|
||||
{% if database_error %}<div class="alert alert-danger text-start" role="alert"><strong>Error:</strong> {{ database_error }}.</div>{% endif %}
|
||||
<div class="alert alert-warning text-center" role="alert">
|
||||
You are about to <strong>upgrade your database file</strong>. This action is irreversible.<br>
|
||||
The process shold be lossless, but just to be sure, grab a copy of your database before proceeding.<br>
|
||||
|
Loading…
Reference in New Issue
Block a user