pull/884/head
Louis Vézina 5 years ago
parent 15ab30cce4
commit a36bd38729

@ -151,12 +151,22 @@ class Series(Resource):
class SeriesEditSave(Resource):
def post(self):
changed_series = request.json
lang = changed_series['languages']
hi = changed_series['hi']
forced = changed_series['forced']
if lang == ['None']:
lang = 'None'
for item in changed_series['seriesid']:
seriesid = item.lstrip('row_')
try:
database.execute("UPDATE table_shows SET languages=?, hearing_impaired=?, forced=? WHERE "
"sonarrSeriesId=?", (str(changed_series['languages']), changed_series['hi'][0],
changed_series['forced'][0], seriesid))
if len(lang):
database.execute("UPDATE table_shows SET languages=? WHERE sonarrSeriesId=?", (str(lang), seriesid))
if len(hi):
database.execute("UPDATE table_shows SET hearing_impaired=? WHERE sonarrSeriesId=?", (hi[0], seriesid))
if len(forced):
database.execute("UPDATE table_shows SET forced=? WHERE sonarrSeriesId=?", (forced[0], seriesid))
except:
pass
else:

@ -549,36 +549,6 @@ def search_json(query):
return dict(items=search_list)
@app.route('/edit_serieseditor', methods=['POST'])
@login_required
def edit_serieseditor():
ref = request.environ['HTTP_REFERER']
series = request.form.get('series')
series = ast.literal_eval(str('[' + series + ']'))
lang = request.form.getlist('languages')
hi = request.form.get('hearing_impaired')
forced = request.form.get('forced')
for serie in series:
if str(lang) != "[]" and str(lang) != "['']":
if str(lang) == "['None']":
lang = 'None'
else:
lang = str(lang)
database.execute("UPDATE table_shows SET languages=? WHERE sonarrSeriesId=?", (lang,serie))
if hi != '':
database.execute("UPDATE table_shows SET hearing_impaired=? WHERE sonarrSeriesId=?", (hi, serie))
if forced != '':
database.execute("UPDATE table_shows SET forced=? WHERE sonarrSeriesId=?", (forced, serie))
for serie in series:
list_missing_subtitles(no=serie)
redirect(ref)
@app.route('/episodes/<int:no>', methods=['GET'])
@app.route('/episodes/')
@login_required

@ -664,6 +664,7 @@
$('#edit_languages_select').empty();
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
$('#edit_languages_select').append('<option value="None">None</option>');
}
$.each(enabledLanguages, function (i, item) {
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');

@ -227,7 +227,10 @@
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').selectpicker({maxOptions: 1});
}
$.each(enabledLanguages, function (i, item) {
if ('{{settings.general.single_language}}' === 'True') {
$('#edit_languages_select').append('<option value="None">None</option>');
}
$.each(enabledLanguages, function (i, item) {
$('#edit_languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
});
$("#edit_languages_select").selectpicker("refresh");

@ -28,13 +28,13 @@
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="languages_select">Language(s): </label>
<select class="selectpicker" id="languages_select" name="languages" multiple></select>
<select class="selectpicker" id="languages_select" name="languages" title="No change" multiple></select>
</div>
</div>
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="hi_select">Hearing-Impaired: </label>
<select class="selectpicker show-tick" id="hi_select" name="hi" multiple>
<select class="selectpicker show-tick" id="hi_select" name="hi" title="No change" multiple>
<option value="False">False</option>
<option value="True">True</option>
</select>
@ -43,7 +43,7 @@
<div class="form-check form-check-inline">
<div class="form-group" style="margin-bottom: 0px;">
<label for="forced_select">Forced: </label>
<select class="selectpicker show-tick" id="forced_select" name="forced" multiple>
<select class="selectpicker show-tick" id="forced_select" name="forced" title="No change" multiple>
<option value="False">False</option>
<option value="True">True</option>
<option value="Both">Both</option>
@ -59,6 +59,8 @@
{% block tail %}
<script>
$(document).ready(function () {
$('#series_nav').addClass("active");
getEnabledLanguages();
events.on('event', function(event) {
@ -97,6 +99,12 @@
}
});
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
var table = $('#series').DataTable({
"processing": true,
"serverSide": true,
@ -150,8 +158,6 @@
]
});
new $.fn.dataTable.Buttons( table, {
"buttons": [
'selectAll',
@ -161,6 +167,24 @@
table.buttons().container().appendTo('#buttons');
table.on( 'select', function () {
$('.selectpicker').prop('disabled', false);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', false);
$('#save_button').removeClass('disabled');
$('#save_button').css('cursor', 'auto');
} );
table.on( 'deselect', function () {
if (table.rows( '.selected' ).count() === 0) {
$('.selectpicker').prop('disabled', true);
$('.selectpicker').selectpicker('refresh');
$('#save_button').prop('disabled', true);
$('#save_button').addClass('disabled');
$('#save_button').css('cursor', 'not-allowed');
}
} );
if ('{{settings.general.single_language}}' === 'True') {
$('#languages_select').selectpicker({maxOptions: 1});
}
@ -195,6 +219,9 @@
$.ajax({
url: "{{ url_for('api.languages') }}?enabled=true",
success:function(data) {
if ('{{settings.general.single_language}}' === 'True') {
$('#languages_select').append('<option value="None">None</option>');
}
$.each(data, function (i, item) {
$('#languages_select').append('<option value="'+item.code2+'">'+item.name+'</option>');
});

Loading…
Cancel
Save