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/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 f2f29106..fcfe4a99 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -18,31 +18,32 @@
-
Download your settings for Workbench
- {% if not demo %}
-
-

Download the settings only for register devices.

+

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

- {% if iso %} -
-
- {{ iso }} -
-
-

- Download Checksum: SHA512SUMS -

-
-
- {% endif %} +
+
- {% else %} + + +
+
+ + + {% if demo %} +
+
+ +
+
+ +
+
Workbench 2022
{% if iso %}
@@ -50,22 +51,88 @@

- Download Checksum: SHA512SUMS + Download Checksum: SHA512SUMS

{% 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 | + Help

+

+
+
+ {% endif %} +
+
+ +
+ +
+
+
+
+ {% endif %} + {% endfor %} + + {% endif %} + + {% endblock main %} diff --git a/ereuse_devicehub/templates/workbench/wbSettings.ini b/ereuse_devicehub/templates/workbench/wbSettings.ini index 7d0b9088..14459454 100644 --- a/ereuse_devicehub/templates/workbench/wbSettings.ini +++ b/ereuse_devicehub/templates/workbench/wbSettings.ini @@ -2,3 +2,33 @@ 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 + +WB_ERASE = EraseBasic +WB_ERASE_STEPS = 1 +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 + +WB_ERASE = EraseSectors +WB_ERASE_STEPS = 1 +WB_ERASE_LEADING_ZEROS = True + +WB_DEBUG = True +{% endif %} diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index 18f65e65..bce2f5a8 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() @@ -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,44 @@ 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['iso'] = '' - self.context['iso_sha'] = '' + if not os.path.exists(uri): + return - if files: - self.context['iso'] = files[0] - self.context['iso_sha'] = 'aaa' + versions = os.listdir(f'{path}/static/iso/') + versions.sort() + + 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 + 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': + self.wbContext['erease_sectors'] = True - def register(self): data = flask.render_template('workbench/wbSettings.ini', **self.wbContext) return self.response_download(data) @@ -94,4 +111,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')) 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 13e58955..3395cda5 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'