diff --git a/app/dashboard/templates/dashboard/referral.html b/app/dashboard/templates/dashboard/referral.html index c30f8702..73eb0e5e 100644 --- a/app/dashboard/templates/dashboard/referral.html +++ b/app/dashboard/templates/dashboard/referral.html @@ -69,6 +69,14 @@ Just append ?slref={{ referral.code }} to any link on SimpleLogin website. +
+
+ + + Delete +
+
+ {% endfor %} @@ -83,4 +91,33 @@ +{% endblock %} + +{% block script %} + {% endblock %} \ No newline at end of file diff --git a/app/dashboard/views/referral.py b/app/dashboard/views/referral.py index 05333bef..29f37c32 100644 --- a/app/dashboard/views/referral.py +++ b/app/dashboard/views/referral.py @@ -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")