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.
|
Just append <em>?slref={{ referral.code }}</em> to any link on SimpleLogin website.
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
@ -83,4 +91,33 @@
|
||||||
<button class="btn btn-success mt-2">Create a new referral code</button>
|
<button class="btn btn-success mt-2">Create a new referral code</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</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 %}
|
{% endblock %}
|
|
@ -39,6 +39,15 @@ def referral_route():
|
||||||
flash("Referral name updated", "success")
|
flash("Referral name updated", "success")
|
||||||
return redirect(
|
return redirect(
|
||||||
url_for("dashboard.referral_route", highlight_id=referral.id)
|
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 a referral
|
||||||
highlight_id = request.args.get("highlight_id")
|
highlight_id = request.args.get("highlight_id")
|
||||||
|
|
Loading…
Reference in a new issue