Fix garbage
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2021-07-10 23:51:07 +02:00
parent 1073d2c1ea
commit e4b00b04e9

View File

@ -114,13 +114,6 @@ def list_animes(url_filters='nyaa,yggtorrent'):
return render_template('list.html', search_form=SearchForm(), titles=results)
def remove_garbage(link):
title = link.title
if title and not len(title.links):
db.session.delete(title)
db.session.commit()
@app.route('/admin', methods=['GET', 'POST'])
@mysql_required
@auth.login_required
@ -133,7 +126,11 @@ def admin():
form.message = '%s (%s) has been successfully deleted' % (link.title.name, link.season)
db.session.delete(link)
db.session.commit()
remove_garbage(link)
title = link.title
if title and not len(title.links):
db.session.delete(title)
db.session.commit()
else:
form._errors = {'id': ['Id %s was not found in the database' % form.id.data]}
@ -230,7 +227,6 @@ def admin_edit(link_id=None):
# Database
db.session.add(link)
db.session.commit()
remove_garbage(link)
# Transmission
if TRANSMISSION_ENABLED and isinstance(instance, Nyaa):