From 74ab088461c8c90731b3a728f52aab69fac0d583 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Wed, 22 Nov 2023 13:07:55 +1100 Subject: [PATCH] feat: Add delete tribe function --- db.py | 10 ++++++++++ main.py | 22 ++++++++++++++++++++++ templates/edit_tribe.html | 2 +- templates/index.html | 2 +- templates/new_tribe.html | 2 +- templates/tribe.html | 2 +- 6 files changed, 36 insertions(+), 4 deletions(-) diff --git a/db.py b/db.py index 5c2bf7c..f06ca21 100644 --- a/db.py +++ b/db.py @@ -348,6 +348,16 @@ def update_tribe_data_raw(tribe,data): update_query = "UPDATE tribes SET data = %s WHERE tribe = %s" cursor.execute(update_query, (json.dumps(data), tribe)) + connection.commit() + cursor.close() + connection.close() + +def delete_tribe(tribe): + connection = mysql.connector.connect(**dbargs) + cursor = connection.cursor() + cursor.execute(""" + DELETE FROM tribes WHERE tribe = %s + """, (tribe,)) connection.commit() cursor.close() connection.close() \ No newline at end of file diff --git a/main.py b/main.py index 2068066..d03ae4f 100644 --- a/main.py +++ b/main.py @@ -558,6 +558,28 @@ def remove_member(): db.update_tribe_data_raw(tribe,data) return redirect('/edit_tribe') +@app.route('/delete_tribe') +def delete_tribe(): + token = request.cookies['token'] + if not accounts.validate_token(token): + return error('Sorry we had an issue verifying your account') + + # Verify token + user = accounts.validate_token(token) + if not user: + # Remove cookie + resp = make_response(redirect('/')) + resp.set_cookie('token', '', expires=0) + return resp + + tribeData = db.get_user_owned_tribe(user['domain']) + if len(tribeData) == 0: + return error('Sorry you don\'t own a tribe') + + tribe = tribeData[0][1] + db.delete_tribe(tribe) + return redirect('/tribe') + @app.route('/') def catch_all(path): account = "Login" diff --git a/templates/edit_tribe.html b/templates/edit_tribe.html index 9131085..6fcb9b3 100644 --- a/templates/edit_tribe.html +++ b/templates/edit_tribe.html @@ -43,7 +43,7 @@

Edit {{tribe}} tribe

-

{{members|safe}}

+

{{members|safe}}

Delete Tribe
diff --git a/templates/index.html b/templates/index.html index ddb4051..06b7ff9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -60,7 +60,7 @@

Tribes

-

{{tribes|safe}}

+

{{tribes|safe}}

diff --git a/templates/new_tribe.html b/templates/new_tribe.html index 973b036..3d028c8 100644 --- a/templates/new_tribe.html +++ b/templates/new_tribe.html @@ -42,7 +42,7 @@

Create a tribe

-
+
diff --git a/templates/tribe.html b/templates/tribe.html index 6385ef2..e44df1d 100644 --- a/templates/tribe.html +++ b/templates/tribe.html @@ -42,7 +42,7 @@

About Tribes

-

ShakeCities is a site offering free personalizable websites. This is a perfect way to start your journey into Handshake domains! Step into a new experience where Handshake domains become instant sites, and where everyone can create their own unique decentralized page.
Secured with HTTPS powered by DANE (DNS-based Authentication of Named Entities).
But that's not all – ShakeCities goes beyond, allowing you to seamlessly integrate crypto addresses into your site, providing an easy way to get paid. Simply send crypto to @yourname.{{CITY_DOMAIN}}
Your ShakeCity domain can be used to chat on HNSChat or to authenticate on any site using Varo auth
Join us in building a decentralized, secure, and innovative internet landscape. Embrace the future with ShakeCities – where Handshake domains meet simplicity.

+

ShakeCities offers tribes as a way to create communities on ShakeCities. Create a tribe with your group of friends or colleagues.

Find a tribe