From 497d522ce8fcfdffa59f474348299b185e37647a Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Thu, 4 Aug 2022 14:38:43 +0200 Subject: [PATCH] new hello settings --- ereuse_devicehub/config.py | 1 + .../templates/workbench/settings.html | 22 +++++++++++++++---- ereuse_devicehub/workbench/views.py | 9 ++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ereuse_devicehub/config.py b/ereuse_devicehub/config.py index 32fd1a22..490336a7 100644 --- a/ereuse_devicehub/config.py +++ b/ereuse_devicehub/config.py @@ -81,6 +81,7 @@ class DevicehubConfig(Config): """Admin email""" EMAIL_ADMIN = config('EMAIL_ADMIN', '') + EMAIL_DEMO = config('EMAIL_DEMO', 'hello@usody.com') """Definition of path where save the documents of customers""" PATH_DOCUMENTS_STORAGE = config('PATH_DOCUMENTS_STORAGE', '/tmp/') diff --git a/ereuse_devicehub/templates/workbench/settings.html b/ereuse_devicehub/templates/workbench/settings.html index 01301e30..f2f29106 100644 --- a/ereuse_devicehub/templates/workbench/settings.html +++ b/ereuse_devicehub/templates/workbench/settings.html @@ -19,7 +19,7 @@
Download your settings for Workbench
-

Please select one of this options

+ {% if not demo %}
Register devices @@ -34,14 +34,28 @@ {{ iso }}
-

Download ISO workbench and burn it one one usb stick.

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

{% endif %} + + {% else %} + + {% if iso %} +
+
+ {{ iso }} +
+
+

+ Download Checksum: SHA512SUMS +

+
+
+ {% endif %} + {% endif %}
diff --git a/ereuse_devicehub/workbench/views.py b/ereuse_devicehub/workbench/views.py index c23e783f..18f65e65 100644 --- a/ereuse_devicehub/workbench/views.py +++ b/ereuse_devicehub/workbench/views.py @@ -24,12 +24,13 @@ class SettingsView(GenericMixin): def dispatch_request(self): self.get_context() - self.get_iso() self.context.update( { 'page_title': self.page_title, + 'demo': g.user.email == app.config['EMAIL_DEMO'], } ) + self.get_iso() self.opt = request.values.get('opt') if self.opt in ['register']: @@ -39,8 +40,12 @@ class SettingsView(GenericMixin): def get_iso(self): path = Path(__file__).parent.parent + uri = f'{path}/static/iso/' + if self.context.get('demo'): + uri = f'{path}/static/iso/demo/' + files = [ - f for f in os.listdir(f'{path}/static/iso/') if f[-3:].lower() == 'iso' + f for f in os.listdir(uri) if f[-3:].lower() == 'iso' ] self.context['iso'] = ''