diff --git a/CHANGELOG.md b/CHANGELOG.md index 89548604..ec1dff26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ml). ## testing +- [added] #414 add new vars in the settings file for wb. ## [2.5.0] - 2022-11-30 - [added] #407 erasure section with tabs in top. diff --git a/ereuse_devicehub/migrations/versions/af038a8a388c_add_settings_version_to_snapshots.py b/ereuse_devicehub/migrations/versions/af038a8a388c_add_settings_version_to_snapshots.py new file mode 100644 index 00000000..1b7b5a20 --- /dev/null +++ b/ereuse_devicehub/migrations/versions/af038a8a388c_add_settings_version_to_snapshots.py @@ -0,0 +1,35 @@ +"""add settings_version to snapshots + +Revision ID: af038a8a388c +Revises: 410aadae7652 +Create Date: 2022-11-30 16:21:05.768024 + +""" +import citext +import sqlalchemy as sa +from alembic import context, op + +# revision identifiers, used by Alembic. +revision = 'af038a8a388c' +down_revision = '410aadae7652' +branch_labels = None +depends_on = None + + +def get_inv(): + INV = context.get_x_argument(as_dictionary=True).get('inventory') + if not INV: + raise ValueError("Inventory value is not specified") + return INV + + +def upgrade(): + op.add_column( + 'snapshot', + sa.Column('settings_version', citext.CIText(), nullable=True), + schema=f'{get_inv()}', + ) + + +def downgrade(): + op.drop_column('snapshot', 'settings_version', schema=f'{get_inv()}') diff --git a/ereuse_devicehub/parser/models.py b/ereuse_devicehub/parser/models.py index 6d8cdb4e..38ddbaf7 100644 --- a/ereuse_devicehub/parser/models.py +++ b/ereuse_devicehub/parser/models.py @@ -84,6 +84,14 @@ class SnapshotsLog(Thing): except AttributeError: return '' + def get_version(self): + if not self.snapshot: + return self.version + settings_version = self.snapshot.settings_version or '' + settings_version = "".join([x[0] for x in settings_version.split(' ') if x]) + + return "{} ({})".format(self.version, settings_version) + class PlaceholdersLog(Thing): """A Placeholder log.""" diff --git a/ereuse_devicehub/resources/action/models.py b/ereuse_devicehub/resources/action/models.py index 87a9d392..ac38fad1 100644 --- a/ereuse_devicehub/resources/action/models.py +++ b/ereuse_devicehub/resources/action/models.py @@ -676,6 +676,7 @@ class Snapshot(JoinedWithOneDeviceMixin, ActionWithOneDevice): of time it took to complete. """ sid = Column(CIText(), nullable=True) + settings_version = Column(CIText(), nullable=True) is_server_erase = Column(Boolean(), nullable=True) def get_last_lifetimes(self): diff --git a/ereuse_devicehub/resources/action/schemas.py b/ereuse_devicehub/resources/action/schemas.py index f24e2c83..da70c49a 100644 --- a/ereuse_devicehub/resources/action/schemas.py +++ b/ereuse_devicehub/resources/action/schemas.py @@ -453,6 +453,7 @@ class Snapshot(ActionWithOneDevice): 'Order is preserved, so the component num 0 when' 'submitting is the component num 0 when returning it back.', ) + settings_version = String(required=False) @validates_schema def validate_workbench_version(self, data: dict): diff --git a/ereuse_devicehub/templates/inventory/snapshots_list.html b/ereuse_devicehub/templates/inventory/snapshots_list.html index 1804f364..126d3ac3 100644 --- a/ereuse_devicehub/templates/inventory/snapshots_list.html +++ b/ereuse_devicehub/templates/inventory/snapshots_list.html @@ -61,7 +61,6 @@ Snapshot UUID Version DHID - System UUID Status Type Upload Type Device @@ -88,7 +87,7 @@ {% endif %} - {{ snap.version }} + {{ snap.get_version() }} {% if snap.get_device() %} @@ -97,9 +96,6 @@ {% endif %} - - {{ snap.get_system_uuid() }} - {{ snap.get_status() }} diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index b711ae7d..b28d64a0 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -14,8 +14,8 @@ WB_SMART_TEST = short WB_ERASE = EraseBasic WB_ERASE_STEPS = 1 WB_ERASE_LEADING_ZEROS = False +VERSION = "Basic Erasure (BE)" -WB_DEBUG = True {% elif baseline_erease %} DH_HOST = {{ api_host }} DH_DATABASE = {{ schema }} @@ -28,6 +28,11 @@ WB_SMART_TEST = short WB_ERASE = EraseSectors WB_ERASE_STEPS = {{ erase_steps }} WB_ERASE_LEADING_ZEROS = True +VERSION = {%if erase_steps < 3 %}"Baseline Secure Erasure (BSE)"{% else %}"Enhanced Secure Erasure (ESE)"{% endif %} -WB_DEBUG = True -{% endif %} +{% else %} +SNAPSHOTS_PATH = /mnt +LOGS_PATH = /mnt +VERSION = "Basic Metadata (BM)" + +{% endif %} \ No newline at end of file