Merge pull request #330 from eReuse/feature/3683-wb-page

Feature/3683 wb page
This commit is contained in:
cayop 2022-08-12 10:55:30 +02:00 committed by GitHub
commit eec5c7143c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 158 additions and 43 deletions

View file

@ -23,3 +23,6 @@
padding-top: 0px;
padding-bottom: 5px;
}
.help {
color: #993365;
}

View file

@ -1 +0,0 @@
868e59911be73a941938644143d81f21a2fdbe82ea0841493c2d9fc04701e058334af5fecd69c1a1525ebd5c8c17ac3f49d8ecc53bbfc8a018f169be48fe79d6 USODY_2022.5.2-beta.iso

View file

@ -18,31 +18,32 @@
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Download your settings for Workbench</h5>
{% if not demo %}
<div class="row pt-3">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary">Register devices</a>
</div>
<div class="col">
<p class="small">Download the settings only for register devices.</p>
<p>Please download the ISO file and the settings file of the
version you want and follow these steps
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</div>
</div>
{% if iso %}
<div class="row pt-3">
<div class="col-5">
<a href="/static/iso/{{ iso }}" class="btn btn-primary">{{ iso }}</a>
</div>
<div class="col">
<p class="small">
Download Checksum: <a style="color: #993365;" href="/static/iso/SHA512SUMS">SHA512SUMS</a>
</p>
</div>
</div>
{% endif %}
</div>
</div>
{% else %}
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% if demo %}
<div class="row">
<div class="col-xl-6">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench 2022</h5>
{% if iso %}
<div class="row pt-3">
<div class="col-5">
@ -50,22 +51,88 @@
</div>
<div class="col">
<p class="small">
Download Checksum: <a style="color: #993365;" href="/static/iso/demo/SHA512SUMS">SHA512SUMS</a>
Download Checksum: <a class="help" href="/static/iso/demo/SHA512SUMS">SHA512SUMS</a>
</p>
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% else %}
{% for d, v in iso.items() %}
{% if d != 'demo' %}
<div class="row">
<div class="col-xl-6">
<div class="card">
<div class="card-body">
<div class="pt-6 pb-2">
<h5 class="card-title text-center pb-0 fs-4">Workbench {{ d }}</h5>
<h4>Settings</h4>
{% if d == 'v14' %}
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_basic" class="btn btn-primary">Get settings for basic erease</a>
</div>
<div class="col">
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</div>
</div>
<div class="row pt-2">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=erease_sectors" class="btn btn-primary">Get settings for erease by sectors</a>
</div>
<div class="col">
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</div>
</div>
{% else %}
<div class="row">
<div class="col-5">
<a href="{{ url_for('workbench.settings') }}?opt=register" class="btn btn-primary">Get settings for register devices</a>
</div>
<div class="col">
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</div>
</div>
{% endif %}
{% if iso %}
<h4 class="pt-3">iso</h4>
<div class="row">
<div class="col-5">
<a href="/static/iso/{{ d }}/{{ v }}" class="btn btn-primary">Get {{ v }}</a>
</div>
<div class="col">
<p class="small">
Download Checksum: <a class="help" href="/static/iso/{{ d }}/SHA512SUMS">SHA512SUMS</a> |
<a href="https://help.usody.com/es/setup/setup-pendrive/" target="_blank" class="help">Help</a></p>
</p>
</div>
</div>
{% endif %}
</div>
</div>
</div>
</div>
<div class="col-xl-8">
</div>
</div>
{% endif %}
{% endfor %}
{% endif %}
</section>
{% endblock main %}

View file

@ -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 %}

View file

@ -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'))

View file

@ -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'] == {

View file

@ -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'