From 7f250b13fbb181497bc2674e9cfcac3794de344e Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Tue, 12 May 2020 20:44:04 +0100 Subject: [PATCH] Hide email input on admin when disabled --- data/static/admin.js | 6 ++++-- data/templates/admin.html | 2 ++ jellyfin_accounts/web.py | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/data/static/admin.js b/data/static/admin.js index 86177f1..8dc3736 100644 --- a/data/static/admin.js +++ b/data/static/admin.js @@ -170,8 +170,10 @@ $("form#inviteForm").submit(function() { '' + 'Loading...'; var send_object = $("form#inviteForm").serializeObject(); - if (document.getElementById('send_to_address_enabled').checked) { - send_object['email'] = document.getElementById('send_to_address').value; + if (document.getElementById('sent_to_address') != null) { + if (document.getElementById('send_to_address_enabled').checked) { + send_object['email'] = document.getElementById('send_to_address').value; + } } var send = JSON.stringify(send_object); $.ajax('/generateInvite', { diff --git a/data/templates/admin.html b/data/templates/admin.html index a194018..c0fbd2a 100644 --- a/data/templates/admin.html +++ b/data/templates/admin.html @@ -120,6 +120,7 @@ + {% if email_enabled %}
@@ -131,6 +132,7 @@
+ {% endif %} diff --git a/jellyfin_accounts/web.py b/jellyfin_accounts/web.py index 7ca6e25..7fc82f1 100644 --- a/jellyfin_accounts/web.py +++ b/jellyfin_accounts/web.py @@ -16,7 +16,9 @@ def page_not_found(e): def admin(): # return app.send_static_file('admin.html') return render_template('admin.html', - contactMessage='') + contactMessage='', + email_enabled=config.getboolean( + 'invite_emails', 'enabled')) @app.route('/') @@ -27,7 +29,6 @@ def static_proxy(path): contactMessage=config['ui']['contact_message']), 404 - @app.route('/invite/') def inviteProxy(path): if checkInvite(path): @@ -48,8 +49,9 @@ def inviteProxy(path): helpMessage=config['ui']['help_message'], successMessage=config['ui']['success_message'], jfLink=config['jellyfin']['server'], - validate=config.getboolean('password_validation', - 'enabled'), + validate=config.getboolean( + 'password_validation', + 'enabled'), requirements=validator.getCriteria(), email=email) elif 'admin.html' not in path and 'admin.html' not in path: