can delete referral
This commit is contained in:
parent
1667356742
commit
eff0eb9e32
|
@ -69,6 +69,14 @@
|
|||
Just append <em>?slref={{ referral.code }}</em> to any link on SimpleLogin website.
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="form-name" value="delete">
|
||||
<input type="hidden" name="referral-id" value="{{ referral.id }}">
|
||||
<span class="delete-referral float-right btn btn-outline-danger">Delete</span>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
@ -84,3 +92,32 @@
|
|||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block script %}
|
||||
<script>
|
||||
$(".delete-referral").on("click", function (e) {
|
||||
let that = $(this);
|
||||
|
||||
bootbox.confirm({
|
||||
message: "This operation is irreversible, please confirm.",
|
||||
buttons: {
|
||||
confirm: {
|
||||
label: 'Yes, delete it',
|
||||
className: 'btn-danger'
|
||||
},
|
||||
cancel: {
|
||||
label: 'Cancel',
|
||||
className: 'btn-outline-primary'
|
||||
}
|
||||
},
|
||||
callback: function (result) {
|
||||
if (result) {
|
||||
that.closest("form").submit();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
|
@ -39,6 +39,15 @@ def referral_route():
|
|||
flash("Referral name updated", "success")
|
||||
return redirect(
|
||||
url_for("dashboard.referral_route", highlight_id=referral.id)
|
||||
)
|
||||
elif request.form.get("form-name") == "delete":
|
||||
referral_id = request.form.get("referral-id")
|
||||
referral = Referral.get(referral_id)
|
||||
if referral and referral.user_id == current_user.id:
|
||||
Referral.delete(referral.id)
|
||||
db.session.commit()
|
||||
flash("Referral deleted", "success")
|
||||
return redirect(url_for("dashboard.referral_route"))
|
||||
|
||||
# Highlight a referral
|
||||
highlight_id = request.args.get("highlight_id")
|
||||
|
|
Loading…
Reference in a new issue