created function for removing shares

This commit is contained in:
Daniel 2019-11-02 19:46:11 +01:00
parent a0351df24c
commit 9c6c72ab21
2 changed files with 18 additions and 1 deletions

View file

@ -163,3 +163,12 @@ def enable_share(share):
db.session.commit() db.session.commit()
except: except:
db.session.rollback() db.session.rollback()
def remove_share(share, remove_data=False):
# TODO: Handling of remove_data. Not implemented because removing of share folder is a future thing.
try:
db.session.delete(share)
db.session.commit()
except:
db.session.rollback()

View file

@ -80,4 +80,12 @@ def remove():
flash("Can't remove drive without id.") flash("Can't remove drive without id.")
return redirect(url_for('.index')) return redirect(url_for('.index'))
else: else:
return render_template('samba/remove.html') try:
share_id = int(share_id)
share = smb_man.get_share_by_id(share_id)
return render_template('samba/remove.html')
except ValueError:
flash("ValueError: id is not an int")
except LookupError:
flash("LookupError: id not valid")
return redirect(url_for('.index'))