mirror of
https://github.com/vale981/dirkules
synced 2025-03-04 17:01:40 -05:00
prepared removal of shares
This commit is contained in:
parent
61fc5ba3c8
commit
a0351df24c
4 changed files with 58 additions and 20 deletions
|
@ -97,25 +97,26 @@ def generate_smb():
|
|||
f.write(samba_global.read())
|
||||
f.write("\n\n")
|
||||
for share in SambaShare.query.all():
|
||||
f.write("[{}]\n".format(share.name))
|
||||
f.write("path = {}\n".format(share.path))
|
||||
if share.recycle or share.btrfs:
|
||||
vfs_obj = ""
|
||||
if share.enabled:
|
||||
f.write("[{}]\n".format(share.name))
|
||||
f.write("path = {}\n".format(share.path))
|
||||
if share.recycle or share.btrfs:
|
||||
vfs_obj = ""
|
||||
if share.recycle:
|
||||
vfs_obj = vfs_obj + "recycle "
|
||||
if share.btrfs:
|
||||
vfs_obj = vfs_obj + "btrfs"
|
||||
f.write("vfs objects = {}\n".format(vfs_obj))
|
||||
f.write(samba_share.read())
|
||||
# reset file pointer
|
||||
samba_share.seek(0)
|
||||
f.write("\n")
|
||||
for entry in share.options:
|
||||
f.write("{} = {}\n".format(entry.option, entry.value))
|
||||
if share.recycle:
|
||||
vfs_obj = vfs_obj + "recycle "
|
||||
if share.btrfs:
|
||||
vfs_obj = vfs_obj + "btrfs"
|
||||
f.write("vfs objects = {}\n".format(vfs_obj))
|
||||
f.write(samba_share.read())
|
||||
# reset file pointer
|
||||
samba_share.seek(0)
|
||||
f.write("\n")
|
||||
for entry in share.options:
|
||||
f.write("{} = {}\n".format(entry.option, entry.value))
|
||||
if share.recycle:
|
||||
f.write(samba_recycle.read())
|
||||
samba_recycle.seek(0)
|
||||
f.write("\n\n")
|
||||
f.write(samba_recycle.read())
|
||||
samba_recycle.seek(0)
|
||||
f.write("\n\n")
|
||||
f.close()
|
||||
samba_global.close()
|
||||
samba_share.close()
|
||||
|
@ -139,6 +140,11 @@ def get_share_by_id(share_id):
|
|||
|
||||
|
||||
def disable_share(share):
|
||||
"""
|
||||
Disables a given share object.
|
||||
:param share: share object
|
||||
:return: nothing
|
||||
"""
|
||||
try:
|
||||
share.enabled = False
|
||||
db.session.commit()
|
||||
|
@ -147,6 +153,11 @@ def disable_share(share):
|
|||
|
||||
|
||||
def enable_share(share):
|
||||
"""
|
||||
Enables a given share object.
|
||||
:param share: share object
|
||||
:return: nothing
|
||||
"""
|
||||
try:
|
||||
share.enabled = True
|
||||
db.session.commit()
|
||||
|
|
|
@ -51,7 +51,13 @@
|
|||
<i class="play icon"></i> Inkludieren
|
||||
</div>
|
||||
</a>
|
||||
{% endif %}</td>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('.remove', share=share.id) }}">
|
||||
<div class="ui orange icon button">
|
||||
<i class="trash icon"></i>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{% endfor %}
|
||||
|
|
11
dirkules/samba/templates/samba/remove.html
Normal file
11
dirkules/samba/templates/samba/remove.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}Freigabe entfernen{% endblock %}
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="topspacer"></div>
|
||||
<div class="ui container">
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -62,7 +62,7 @@ def add():
|
|||
form.path.choices = smb_man.get_pools()
|
||||
if request.method == 'POST' and form.validate():
|
||||
smb_man.create_share(form.name.data, form.path.data, form.user.data, form.dir_mask.data, form.create_mask.data,
|
||||
form.writeable.data, form.btrfs.data, form.recycling.data)
|
||||
form.writeable.data, form.btrfs.data, form.recycling.data)
|
||||
return redirect(url_for('.index'))
|
||||
return render_template('samba/add.html', form=form)
|
||||
|
||||
|
@ -71,3 +71,13 @@ def add():
|
|||
def generate():
|
||||
smb_man.generate_smb()
|
||||
return redirect(url_for('.index'))
|
||||
|
||||
|
||||
@bp_samba.route('/remove', methods=['GET', 'POST'])
|
||||
def remove():
|
||||
share_id = request.args.get('share')
|
||||
if share_id is None:
|
||||
flash("Can't remove drive without id.")
|
||||
return redirect(url_for('.index'))
|
||||
else:
|
||||
return render_template('samba/remove.html')
|
||||
|
|
Loading…
Add table
Reference in a new issue