From bbcd70adc45e062dd4cde72faf0dd3eaf5b9b821 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Louis=20V=C3=A9zina?=
<5130500+morpheus65535@users.noreply.github.com>
Date: Tue, 28 Apr 2020 22:39:30 -0400
Subject: [PATCH] WIP
---
bazarr/config.py | 9 +++-
views/settingslanguages.html | 79 +++++++++++++++++++++++++++++++-----
2 files changed, 76 insertions(+), 12 deletions(-)
diff --git a/bazarr/config.py b/bazarr/config.py
index d142f4618..403591893 100644
--- a/bazarr/config.py
+++ b/bazarr/config.py
@@ -161,10 +161,15 @@ def save_settings(settings_items):
database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,))
continue
- # Make sure that text based form values aren't pass as list
- if isinstance(value, list) and len(value) == 1:
+ # Make sure that text based form values aren't pass as list unless they are language list
+ if isinstance(value, list) and len(value) == 1 and key not in ['settings-general-serie_default_language',
+ 'settings-general-movie_default_language']:
value = value[0]
+ # Make sure empty language list are stored correctly due to bug in bootstrap-select
+ if key in ['settings-general-serie_default_language', 'settings-general-movie_default_language'] and value == ['null']:
+ value = []
+
settings_keys = key.split('-')
if value == 'true':
diff --git a/views/settingslanguages.html b/views/settingslanguages.html
index 537fb7724..6326a27e9 100644
--- a/views/settingslanguages.html
+++ b/views/settingslanguages.html
@@ -63,9 +63,13 @@
Series Default Settings
-
+
+
+
-
@@ -79,14 +83,24 @@
Hearing-Impaired
-
+
+
+
-
Forced
-
+
+
+
@@ -95,9 +109,13 @@
Movies Default Settings
-
+
+
+
-
@@ -111,14 +129,24 @@
Hearing-Impaired
-
+
+
+
-
Forced
-
+
+
+
@@ -170,6 +198,8 @@
// Set Select input values
$('#settings-general-subfolder').val('{{settings.general.subfolder}}').trigger('change');
$('#settings-general-anti_captcha_provider').val('{{settings.general.anti_captcha_provider}}').trigger('change');
+ $('#settings-general-serie_default_forced').val('{{settings.general.serie_default_forced}}').trigger('change');
+ $('#settings-general-movie_default_forced').val('{{settings.general.movie_default_forced}}').trigger('change');
$('.selectpicker').selectpicker('refresh')
// Listen to single language checkbox change to adapt languages menus
@@ -185,12 +215,41 @@
}
});
+ // Hide *_div on default-enabled change
+ $('#settings-general-serie_default_enabled').on('change', function() {
+ if ($(this).prop('checked')) {
+ $('#series_default_div').show();
+ } else {
+ $('#series_default_div').hide();
+ }
+ });
+
+ $('#settings-general-movie_default_enabled').on('change', function() {
+ if ($(this).prop('checked')) {
+ $('#movies_default_div').show();
+ } else {
+ $('#movies_default_div').hide();
+ }
+ });
+
// Set Checkbox input values
$('#settings-general-single_language').prop('checked', {{'true' if settings.general.getboolean('single_language') else 'false'}}).trigger('change');
+ $('#settings-general-serie_default_enabled').prop('checked', {{'true' if settings.general.getboolean('serie_default_enabled') else 'false'}}).trigger('change');
+ $('#settings-general-serie_default_hi').prop('checked', {{'true' if settings.general.getboolean('serie_default_hi') else 'false'}}).trigger('change');
+ $('#settings-general-movie_default_enabled').prop('checked', {{'true' if settings.general.getboolean('movie_default_enabled') else 'false'}}).trigger('change');
+ $('#settings-general-movie_default_hi').prop('checked', {{'true' if settings.general.getboolean('movie_default_hi') else 'false'}}).trigger('change');
$('#save_button').on('click', function() {
var formdata = new FormData(document.getElementById("settings_form"));
+ // Make sure empty default languages select are send (bug in bootstrap-select)
+ if (formdata.get('settings-general-serie_default_language') == null) {
+ formdata.append('settings-general-serie_default_language', null)
+ }
+ if (formdata.get('settings-general-movie_default_language') == null) {
+ formdata.append('settings-general-movie_default_language', null)
+ }
+
// Make sure all checkbox input are sent with true/false value
$('input[type=checkbox]').each(function () {
formdata.set($(this).prop('id'), $(this).prop('checked'));