pull/997/head
Louis Vézina 5 years ago
parent 67d5e2a9c2
commit 62093864f2

@ -127,7 +127,8 @@ class Search(Resource):
class SaveSettings(Resource): class SaveSettings(Resource):
@authenticate @authenticate
def post(self): def post(self):
save_settings(request.form.items())
save_settings(zip(request.form.keys(), request.form.listvalues()))
scheduler.update_configurable_tasks() scheduler.update_configurable_tasks()
return '', 200 return '', 200

@ -151,11 +151,17 @@ base_url = settings.general.base_url
def save_settings(settings_items): def save_settings(settings_items):
from database import database
for key, value in settings_items: for key, value in settings_items:
if key == 'enabled_languages': if key == 'enabled_languages':
print(key) database.execute("UPDATE table_settings_languages SET enabled=0")
for item in value:
database.execute("UPDATE table_settings_languages SET enabled=1 WHERE code2=?", (item,))
continue continue
if isinstance(value, list) and len(value) == 1:
value = value[0]
settings_keys = key.split('-') settings_keys = key.split('-')
if value == 'true': if value == 'true':

@ -3,7 +3,11 @@
{% block title %}Languages - Bazarr{% endblock %} {% block title %}Languages - Bazarr{% endblock %}
{% block page_head %} {% block page_head %}
<style>
.warning {
color: red;
}
</style>
{% endblock page_head %} {% endblock page_head %}
{% block bcleft %} {% block bcleft %}
@ -33,11 +37,13 @@
<div class="col-sm-3 text-right"> <div class="col-sm-3 text-right">
<b>Single Language</b> <b>Single Language</b>
</div> </div>
<div class="form-group col-sm-1"> <div class="form-group col-sm-8">
<label class="custom-control custom-checkbox"> <label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-general-single_language" name="settings-general-single_language"> <input type="checkbox" class="custom-control-input" id="settings-general-single_language" name="settings-general-single_language">
<span class="custom-control-label" for="settings-general-single_language"></span> <span class="custom-control-label" for="settings-general-single_language"></span>
</label> </label>
<label>Download a single Subtitles file without adding the language code to the filename.</label>
<label class="warning">We don't recommend enabling this option unless absolutely required (ie: media player not supporting language code in subtitles filename). Results may vary.</label>
</div> </div>
</div> </div>
<br> <br>
@ -143,7 +149,6 @@
$('input[type=checkbox]').each(function () { $('input[type=checkbox]').each(function () {
formdata.set($(this).prop('id'), $(this).prop('checked')); formdata.set($(this).prop('id'), $(this).prop('checked'));
}); });
$.ajax({ $.ajax({
url: "{{ url_for('api.savesettings') }}", url: "{{ url_for('api.savesettings') }}",
data: formdata, data: formdata,
@ -179,8 +184,11 @@
$.ajax({ $.ajax({
url: "{{ url_for('api.languages') }}?enabled=true", url: "{{ url_for('api.languages') }}?enabled=true",
success: function (data) { success: function (data) {
console.log(data); let optArr = [];
$('#enabled_languages').selectpicker('val', data); $.each(data, function (i, item) {
optArr.push(item.code2);
});
$('#enabled_languages').selectpicker('val', optArr);
} }
}); });
} }

Loading…
Cancel
Save