modal testing

This commit is contained in:
Daniel 2019-11-04 14:42:19 +01:00
parent a93befa48c
commit 4ef5a16abd
2 changed files with 39 additions and 5 deletions

View file

@ -2,6 +2,18 @@
{% block title %}Freigabe entfernen{% endblock %}
{% block head %}
{{ super() }}
{% if show_modal %}
<script type="text/javascript">
$(document).ready(function () {
$('#security')
.modal('show')
;
$('#confirm').click(function () {
$('.ui.modal').modal('hide');
});
});
</script>
{% endif %}
{% endblock %}
{% block body %}
<div class="topspacer"></div>
@ -23,8 +35,25 @@
{% endif %}
{{ form.hidden_tag() }}
{{ render_field(form.remove_data) }}
{{ render_field(form.okay) }}
<div class="ui tiny modal" id="security">
<div class="ui icon header">
<i class="smile icon"></i> Authentifizierung benötigt
</div>
<div class="content">
<p>Du hast ausgewählt, dass alle Daten der Freigabe restlos entfernt werden sollen. Diese Aktion ist
unumkehrbar!</p>
<p>Die Sicherheitsprotokolle von Dirkules verbieten diese Aktion. Um die Aktion dennoch auszuführen,
bitte die Sicherheitsprotokolle überbrücken.</p>
<p>{{ render_field(form.okay) }}</p>
</div>
<div class="actions">
<div class="ui button" id="confirm">
Bestätigen
</div>
</div>
</div>
{{ render_field(form.submit) }}
</form>
</div>
{% endblock %}

View file

@ -76,6 +76,7 @@ def generate():
@bp_samba.route('/remove', methods=['GET', 'POST'])
def remove():
share_id = request.args.get('share')
show_modal = False
if share_id is None:
flash("Can't remove drive without id.")
return redirect(url_for('.index'))
@ -84,10 +85,14 @@ def remove():
form = SambaRemovalForm(request.form)
share_id = int(share_id)
share = smb_man.get_share_by_id(share_id)
if request.method == 'POST' and form.validate():
print("LOL")
return redirect(url_for('.index'))
return render_template('samba/remove.html', name=share.name, form=form)
if request.method == 'POST':
if form.validate():
print("Alles Easy")
return redirect(url_for('.index'))
else:
show_modal = True
print(form.okay.data)
return render_template('samba/remove.html', name=share.name, form=form, show_modal=show_modal)
except ValueError:
flash("ValueError: id is not an int")
except LookupError: