feat: Add delete tribe function
All checks were successful
Build Docker / Build SLDs Image (push) Successful in 18s
Build Docker / Build Main Image (push) Successful in 20s

This commit is contained in:
Nathan Woodburn 2023-11-22 13:07:55 +11:00
parent cd43dd3dc6
commit 74ab088461
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1
6 changed files with 36 additions and 4 deletions

10
db.py
View File

@ -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()

22
main.py
View File

@ -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('/<path:path>')
def catch_all(path):
account = "Login"

View File

@ -43,7 +43,7 @@
<div class="col" style="background: var(--bs-body-color);margin-right: 10px;border-radius: 10px;margin-top: 10px;margin-left: 10px;">
<h1 style="margin: 10px;">Edit {{tribe}} tribe</h1>
<form method="post" style="margin-bottom: 20px;"><input class="form-control" type="text" style="margin-top: 20px;" name="tribe" placeholder="Tribe Name" value="{{tribe}}"><textarea class="form-control" style="margin-top: 20px;" rows="5" placeholder="Content" name="data">{{data}}</textarea>
<p style="margin-top: 20px;">{{members|safe}}</p><input class="btn btn-primary" type="submit" style="margin-top: 20px;" value="Edit">
<p style="margin-top: 20px;">{{members|safe}}</p><input class="btn btn-primary" type="submit" style="margin-top: 20px;" value="Edit"><a class="btn btn-primary" role="button" style="margin-top: 20px;margin-left: 50px;" href="/delete_tribe">Delete Tribe</a>
</form>
</div>
</div>

View File

@ -60,7 +60,7 @@
<div class="row" style="margin: 0px;">
<div class="col" style="background: var(--bs-body-color);margin-right: 10px;border-radius: 10px;margin-top: 10px;margin-left: 10px;">
<h1 style="margin: 10px;">Tribes</h1>
<p style="margin: 10px;">{{tribes|safe}}</p>
<p style="margin: 10px;font-size: 20px;">{{tribes|safe}}</p>
</div>
</div>
</section>

View File

@ -42,7 +42,7 @@
<div class="row" style="margin: 0px;">
<div class="col" style="background: var(--bs-body-color);margin-right: 10px;border-radius: 10px;margin-top: 10px;margin-left: 10px;">
<h1 style="margin: 10px;">Create a tribe</h1>
<form method="post"><input class="form-control" type="text" style="margin-top: 20px;" name="tribe" placeholder="Tribe Name"><input class="btn btn-primary" type="submit" style="margin-top: 20px;" value="Create"></form>
<form method="post" style="margin-bottom: 20px;"><input class="form-control" type="text" style="margin-top: 20px;" name="tribe" placeholder="Tribe Name"><input class="btn btn-primary" type="submit" style="margin-top: 20px;" value="Create"></form>
</div>
</div>
</section>

View File

@ -42,7 +42,7 @@
<div class="row" style="margin: 0px;">
<div class="col" style="background: var(--bs-body-color);margin-right: 10px;border-radius: 10px;margin-top: 10px;margin-left: 10px;">
<h1 style="margin: 10px;">About Tribes</h1>
<p style="margin: 10px;">ShakeCities is a site offering free personalizable&nbsp;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.<br>Secured with HTTPS powered by DANE (DNS-based Authentication of Named Entities).<br>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 <code>@yourname.{{CITY_DOMAIN}}</code><br>Your ShakeCity domain can be used to chat on <a href="https://hns.chat" target="_blank">HNSChat</a>&nbsp;or to authenticate on any site using Varo auth<br>Join us in building a decentralized, secure, and innovative internet landscape. Embrace the future with ShakeCities where Handshake domains meet simplicity.</p>
<p style="margin: 10px;">ShakeCities offers tribes as a way to create communities on ShakeCities. Create a tribe with your group of friends or colleagues.</p>
</div>
<div class="col" style="background: var(--bs-body-color);margin-left: 10px;border-radius: 10px;margin-top: 10px;margin-right: 10px;">
<h1 style="margin: 10px;">Find a tribe</h1>