From eff0eb9e3203959af4841beb1247d1950b167a5c Mon Sep 17 00:00:00 2001
From: Son NK <>
Date: Sat, 2 May 2020 18:14:09 +0200
Subject: [PATCH] can delete referral
---
.../templates/dashboard/referral.html | 37 +++++++++++++++++++
app/dashboard/views/referral.py | 9 +++++
2 files changed, 46 insertions(+)
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.
+
+
+
+
{% 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")