From a3a8f377f0b0a7d82663110ac209697bd3d82b9a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Aug 2022 14:09:59 +0200 Subject: [PATCH 1/7] new settins page --- ereuse_devicehub/templates/workbench/settings.html | 14 +++++--------- ereuse_devicehub/workbench/views.py | 8 ++++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index 01301e30..a38a787a 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -18,26 +18,22 @@
-
Download your settings for Workbench
-

Please select one of this options

+
Workbench 2022
-

Download the settings only for register devices.

- {% if iso %} + {% if 2022_iso %}
-

Download ISO workbench and burn it one one usb stick.

- Download Checksum: SHA512SUMS | - Signature + Download Checksum: SHA512SUMS |

diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index c23e783f..259279f0 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -20,7 +20,7 @@ workbench = Blueprint('workbench', __name__, url_prefix='/workbench') class SettingsView(GenericMixin): decorators = [login_required] template_name = 'workbench/settings.html' - page_title = "Workbench Settings" + page_title = "Workbench" def dispatch_request(self): self.get_context() @@ -43,8 +43,8 @@ class SettingsView(GenericMixin): f for f in os.listdir(f'{path}/static/iso/') if f[-3:].lower() == 'iso' ] - self.context['iso'] = '' - self.context['iso_sha'] = '' + self.context['2022_iso'] = '' + self.context['2022_iso_sha'] = '' if files: self.context['iso'] = files[0] @@ -89,4 +89,4 @@ class SettingsView(GenericMixin): return token -workbench.add_url_rule('/settings/', view_func=SettingsView.as_view('settings')) +workbench.add_url_rule('/', view_func=SettingsView.as_view('settings')) From 8c1ea5786ed1ca1ea707f87a02b59f71f9f8fd47 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 5 Aug 2022 11:07:54 +0200 Subject: [PATCH 2/7] add v14 iso for download erease settings --- ereuse_devicehub/static/iso/SHA512SUMS | 1 - ereuse_devicehub/static/iso/SHA512SUMS.sign | 0 .../templates/workbench/settings.html | 94 +++++++++++++------ .../templates/workbench/wbSettings.ini | 6 ++ ereuse_devicehub/workbench/views.py | 36 ++++--- 5 files changed, 97 insertions(+), 40 deletions(-) delete mode 100644 ereuse_devicehub/static/iso/SHA512SUMS delete mode 100644 ereuse_devicehub/static/iso/SHA512SUMS.sign diff --git a/ereuse_devicehub/static/iso/SHA512SUMS b/ereuse_devicehub/static/iso/SHA512SUMS deleted file mode 100644 index 04c30697..00000000 --- a/ereuse_devicehub/static/iso/SHA512SUMS +++ /dev/null @@ -1 +0,0 @@ -868e59911be73a941938644143d81f21a2fdbe82ea0841493c2d9fc04701e058334af5fecd69c1a1525ebd5c8c17ac3f49d8ecc53bbfc8a018f169be48fe79d6 USODY_2022.5.2-beta.iso diff --git a/ereuse_devicehub/static/iso/SHA512SUMS.sign b/ereuse_devicehub/static/iso/SHA512SUMS.sign deleted file mode 100644 index e69de29b..00000000 diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index b66f5475..6f2b28cd 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -11,6 +11,7 @@
+ {% if demo %}
@@ -19,29 +20,6 @@
Workbench 2022
- {% if not demo %} - - {% if 2022_iso %} -
- -
-

- Download Checksum: SHA512SUMS | -

-
-
- {% endif %} - - {% else %} - {% if iso %}
@@ -53,18 +31,80 @@

- {% endif %} - {% endif %}
-
-
+ {% endif %} + + {% else %} + {% for d, v in iso.items() %} + {% if d != 'demo' %} +
+
+ +
+
+ +
+
Workbench {{ d }}
+

Settings

+ {% if d == 'v14' %} + + + {% else %} + + {% endif %} + {% if iso %} +

iso

+
+ +
+

+ Download Checksum: SHA512SUMS | +

+
+
+ {% endif %} +
+
+ +
+ +
+
+
+
+ {% endif %} + {% endfor %} + + {% endif %} + + {% endblock main %} diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index 7d0b9088..8f756c1a 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -2,3 +2,9 @@ DH_TOKEN = {{ token }} DH_URL = {{ url }} +{% if erease_basic %} +EREASE_BASIC = True +{% endif %} +{% if erease_sectors %} +EREASE_SECTORS = True +{% endif %} diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index 4b9ec4d0..9ef4d6e6 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -33,7 +33,7 @@ class SettingsView(GenericMixin): self.get_iso() self.opt = request.values.get('opt') - if self.opt in ['register']: + if self.opt in ['register', 'erease_basic', 'erease_sectors']: return self.download() return flask.render_template(self.template_name, **self.context) @@ -44,27 +44,39 @@ class SettingsView(GenericMixin): if self.context.get('demo'): uri = f'{path}/static/iso/demo/' - files = [ - f for f in os.listdir(uri) if f[-3:].lower() == 'iso' - ] + self.context['iso'] = {} - self.context['2022_iso'] = '' - self.context['2022_iso_sha'] = '' + versions = os.listdir(f'{path}/static/iso/') + versions.sort() - if files: - self.context['iso'] = files[0] - self.context['iso_sha'] = 'aaa' + for d in versions: + dir_iso = f'{uri}/{d}' + if not os.path.isdir(dir_iso): + continue + + files = [f for f in os.listdir(dir_iso) if f[-3:].lower() == 'iso'] + + if files: + self.context['iso'][f'{d}'] = files[0] def download(self): url = "https://{}/api/inventory/".format(app.config['HOST']) self.wbContext = { 'token': self.get_token(), 'url': url, + 'erease_basic': None, + 'erease_sectors': None, } - options = {"register": self.register} - return options[self.opt]() + # if is a v14 version + # TODO when not use more v14, we can remove this if + if 'erease' in self.opt: + url = "https://{}/actions/".format(app.config['HOST']) + self.wbContext['url'] = url + if self.opt == 'erease_basic': + self.wbContext['erease_basic'] = True + if self.opt == 'erease_sectors': + self.wbContext['erease_sectors'] = True - def register(self): data = flask.render_template('workbench/wbSettings.ini', **self.wbContext) return self.response_download(data) From 6bcaa94a3d322dbbc2667cc75b77809e6d6f2699 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 11 Aug 2022 10:01:20 +0200 Subject: [PATCH 3/7] template for erase wb 14 --- .../templates/workbench/wbSettings.ini | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index 8f756c1a..33bf4754 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -3,8 +3,24 @@ DH_TOKEN = {{ token }} DH_URL = {{ url }} {% if erease_basic %} -EREASE_BASIC = True +WB_BENCHMARK = True +WB_STRESS_TEST = 0 +WB_SMART_TEST = short + +WB_ERASE = EraseBasic +WB_ERASE_STEPS = 1 +WB_ERASE_LEADING_ZEROS = False + +WB_DEBUG = True {% endif %} {% if erease_sectors %} -EREASE_SECTORS = True +WB_BENCHMARK = True +WB_STRESS_TEST = 0 +WB_SMART_TEST = short + +WB_ERASE = EraseSectors +WB_ERASE_STEPS = 1 +WB_ERASE_LEADING_ZEROS = True + +WB_DEBUG = True {% endif %} From 803c02ef35941c90ef2458e37158c1f47f9ae116 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 11 Aug 2022 18:04:30 +0200 Subject: [PATCH 4/7] add help to the template --- ereuse_devicehub/static/css/devicehub.css | 3 ++ .../templates/workbench/settings.html | 34 +++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/static/css/devicehub.css b/ereuse_devicehub/static/css/devicehub.css index 8ff63bbb..169d7fd2 100644 --- a/ereuse_devicehub/static/css/devicehub.css +++ b/ereuse_devicehub/static/css/devicehub.css @@ -23,3 +23,6 @@ padding-top: 0px; padding-bottom: 5px; } +.help { + color: #993365; +} diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index 6f2b28cd..fcfe4a99 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -11,6 +11,30 @@
+
+
+ +
+
+ +
+
+
+

Please download the ISO file and the settings file of the + version you want and follow these steps + Help

+
+
+
+
+ +
+ +
+
+
+
+ {% if demo %}
@@ -27,10 +51,11 @@

- Download Checksum: SHA512SUMS + Download Checksum: SHA512SUMS

+ {% endif %} @@ -40,7 +65,6 @@
- {% endif %} {% else %} {% for d, v in iso.items() %} @@ -60,6 +84,7 @@ Get settings for basic erease
+ Help

+ Help

{% else %} @@ -75,6 +101,7 @@ Get settings for register devices
+ Help

{% endif %} @@ -86,7 +113,8 @@

- Download Checksum: SHA512SUMS | + Download Checksum: SHA512SUMS | + Help

From cf6965f2e6da0a30ddee243f38f172929781521f Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 11 Aug 2022 18:10:46 +0200 Subject: [PATCH 5/7] modify template wb --- ereuse_devicehub/templates/workbench/wbSettings.ini | 8 ++++++++ ereuse_devicehub/workbench/views.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index 33bf4754..14459454 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -3,6 +3,10 @@ DH_TOKEN = {{ token }} DH_URL = {{ url }} {% if erease_basic %} +DH_HOST = {{ host }} +DH_DATABASE = {{ schema }} +DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/ + WB_BENCHMARK = True WB_STRESS_TEST = 0 WB_SMART_TEST = short @@ -14,6 +18,10 @@ WB_ERASE_LEADING_ZEROS = False WB_DEBUG = True {% endif %} {% if erease_sectors %} +DH_HOST = {{ host }} +DH_DATABASE = {{ schema }} +DEVICEHUB_URL = https://${DB_HOST}/${DB_DATABASE}/ + WB_BENCHMARK = True WB_STRESS_TEST = 0 WB_SMART_TEST = short diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index 9ef4d6e6..ea6d5e4f 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -72,6 +72,8 @@ class SettingsView(GenericMixin): if 'erease' in self.opt: url = "https://{}/actions/".format(app.config['HOST']) self.wbContext['url'] = url + self.wbContext['host'] = app.config['HOST'] + self.wbContext['schema'] = app.config['SCHEMA'] if self.opt == 'erease_basic': self.wbContext['erease_basic'] = True if self.opt == 'erease_sectors': From 29d69cd285e24bd8273d2d2d2ab7cff1a334a407 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 12 Aug 2022 09:58:19 +0200 Subject: [PATCH 6/7] fix tests --- tests/test_basic.py | 2 +- tests/test_render_2_0.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 39b2ca25..d4595a9c 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -100,7 +100,7 @@ def test_api_docs(client: Client): '/users/login/', '/users/logout/', '/versions/', - '/workbench/settings/', + '/workbench/', } assert docs['info'] == {'title': 'Devicehub', 'version': '0.2'} assert docs['components']['securitySchemes']['bearerAuth'] == { diff --git a/tests/test_render_2_0.py b/tests/test_render_2_0.py index 49c151ab..382db6b4 100644 --- a/tests/test_render_2_0.py +++ b/tests/test_render_2_0.py @@ -1282,18 +1282,17 @@ def test_action_datawipe(user3: UserClientFlask): @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_wb_settings(user3: UserClientFlask): - uri = '/workbench/settings/' + uri = '/workbench/' body, status = user3.get(uri) assert status == '200 OK' - assert "Download your settings for Workbench" in body - assert "Workbench Settings" in body + assert "Please download the ISO file and the settings file of the" in body @pytest.mark.mvp @pytest.mark.usefixtures(conftest.app_context.__name__) def test_wb_settings_register(user3: UserClientFlask): - uri = '/workbench/settings/?opt=register' + uri = '/workbench/?opt=register' body, status = user3.get(uri) assert status == '200 OK' From dcd229f12bcc1251fd2dbef9dfd17d3d31f480f0 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Fri, 12 Aug 2022 10:23:06 +0200 Subject: [PATCH 7/7] fix not exist iso dir --- ereuse_devicehub/workbench/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index ea6d5e4f..bce2f5a8 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -46,6 +46,9 @@ class SettingsView(GenericMixin): self.context['iso'] = {} + if not os.path.exists(uri): + return + versions = os.listdir(f'{path}/static/iso/') versions.sort()