diff --git a/dirkules/samba/manager.py b/dirkules/samba/manager.py index c60b457..6b35f19 100644 --- a/dirkules/samba/manager.py +++ b/dirkules/samba/manager.py @@ -163,3 +163,12 @@ def enable_share(share): db.session.commit() except: 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() diff --git a/dirkules/samba/views.py b/dirkules/samba/views.py index c1c4e4d..11e6d1b 100644 --- a/dirkules/samba/views.py +++ b/dirkules/samba/views.py @@ -80,4 +80,12 @@ def remove(): flash("Can't remove drive without id.") return redirect(url_for('.index')) 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'))