From 45022e960f317f8c6eb3328f689ecc1668ee24a6 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Wed, 30 Oct 2024 08:49:09 +0000 Subject: [PATCH] Add `confirm` methods to structure and configuration models --- src/aiidalab_qe/app/configuration/__init__.py | 2 +- src/aiidalab_qe/app/configuration/model.py | 3 +++ src/aiidalab_qe/app/main.py | 4 ++-- src/aiidalab_qe/app/structure/__init__.py | 2 +- src/aiidalab_qe/app/structure/model.py | 3 +++ tests/test_app.py | 2 +- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/aiidalab_qe/app/configuration/__init__.py b/src/aiidalab_qe/app/configuration/__init__.py index 228169ace..bd39c5edd 100644 --- a/src/aiidalab_qe/app/configuration/__init__.py +++ b/src/aiidalab_qe/app/configuration/__init__.py @@ -158,7 +158,7 @@ def is_saved(self): return self._model.confirmed def confirm(self, _=None): - self._model.confirmed = True + self._model.confirm() def reset(self): self._model.reset() diff --git a/src/aiidalab_qe/app/configuration/model.py b/src/aiidalab_qe/app/configuration/model.py index 83b0862be..ab5e15faa 100644 --- a/src/aiidalab_qe/app/configuration/model.py +++ b/src/aiidalab_qe/app/configuration/model.py @@ -120,6 +120,9 @@ def set_model_state(self, parameters): if parameters.get(identifier): model.set_model_state(parameters[identifier]) + def confirm(self): + self.confirmed = True + def reset(self): self.confirmed = False self.relax_type_help = self._get_default_relax_type_help() diff --git a/src/aiidalab_qe/app/main.py b/src/aiidalab_qe/app/main.py index 179bbda31..ec3ac00b9 100644 --- a/src/aiidalab_qe/app/main.py +++ b/src/aiidalab_qe/app/main.py @@ -171,12 +171,12 @@ def _update_from_process(self, pk): process = load_node(pk) self._wizard_app_widget.selected_index = 3 self.structure_model.structure = process.inputs.structure - self.structure_model.confirmed = True + self.structure_model.confirm() parameters = process.base.extras.get("ui_parameters", {}) if parameters and isinstance(parameters, str): parameters = deserialize_unsafe(parameters) self.configure_model.set_model_state(parameters) - self.configure_model.confirmed = True + self.configure_model.confirm() self.submit_model.process = process self.submit_model.set_model_state(parameters) self.submit_step.state = WizardAppWidgetStep.State.SUCCESS diff --git a/src/aiidalab_qe/app/structure/__init__.py b/src/aiidalab_qe/app/structure/__init__.py index 97caed840..2148b1a4b 100644 --- a/src/aiidalab_qe/app/structure/__init__.py +++ b/src/aiidalab_qe/app/structure/__init__.py @@ -175,7 +175,7 @@ def is_saved(self): def confirm(self, _=None): self.manager.store_structure() self._model.message_area = "" - self._model.confirmed = True + self._model.confirm() def can_reset(self): return self._model.confirmed diff --git a/src/aiidalab_qe/app/structure/model.py b/src/aiidalab_qe/app/structure/model.py index caaafb76a..f85ec507f 100644 --- a/src/aiidalab_qe/app/structure/model.py +++ b/src/aiidalab_qe/app/structure/model.py @@ -28,6 +28,9 @@ def update_widget_text(self): self.manager_output = "" self.structure_name = str(self.structure.get_formula()) + def confirm(self): + self.confirmed = True + def reset(self): self.structure = None self.structure_name = "" diff --git a/tests/test_app.py b/tests/test_app.py index 6c1681733..9fb1cbda8 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -30,7 +30,7 @@ def test_selecting_new_structure_unconfirms_model(generate_structure_data): model = StructureModel() model.structure = generate_structure_data() assert model.structure is not None - model.confirmed = True + model.confirm() model.structure = generate_structure_data() assert not model.confirmed