Make instructions failsafe in the admin

This commit is contained in:
Gregoo 2025-02-04 10:47:22 +01:00
parent 7ce029029d
commit 3d660c594b
2 changed files with 25 additions and 20 deletions

View File

@ -34,6 +34,7 @@ def admin() -> str:
database_exception: Exception | None = None
database_upgrade_needed: bool = False
database_version: int = -1
instructions: BrickInstructionsList | None = None
metadata_owners: list[BrickSetOwner] = []
metadata_statuses: list[BrickSetStatus] = []
metadata_storages: list[BrickSetStorage] = []
@ -50,6 +51,8 @@ def admin() -> str:
database_version = database.version
database_counters = BrickSQL().count_records()
instructions = BrickInstructionsList()
metadata_owners = BrickSetOwnerList.list()
metadata_statuses = BrickSetStatusList.list(all=True)
metadata_storages = BrickSetStorageList.list()
@ -104,7 +107,7 @@ def admin() -> str:
database_exception=database_exception,
database_upgrade_needed=database_upgrade_needed,
database_version=database_version,
instructions=BrickInstructionsList(),
instructions=instructions,
metadata_owners=metadata_owners,
metadata_statuses=metadata_statuses,
metadata_storages=metadata_storages,

View File

@ -6,8 +6,9 @@
The instructions files folder is: <code>{{ config['INSTRUCTIONS_FOLDER'] }}</code>. <br>
Allowed file formats for instructions are the following: <code>{{ ', '.join(config['INSTRUCTIONS_ALLOWED_EXTENSIONS']) }}</code>.
</p>
<h5 class="border-bottom">Counters</h5>
<p>
{% if instructions %}
<h5 class="border-bottom">Counters</h5>
<p>
<div class="d-flex justify-content-start">
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-start">
@ -24,7 +25,8 @@
</li>
</ul>
</div>
</p>
</p>
{% endif %}
<h5 class="border-bottom">Refresh</h5>
<p>
<a href="{{ url_for('admin_instructions.refresh') }}" class="btn btn-primary" role="button"><i class="ri-refresh-line"></i> Refresh the instructions cache</a>