From 1717de8373bbcb327a720a6bc6c5a69bea69b016 Mon Sep 17 00:00:00 2001 From: haunter Date: Sun, 26 Apr 2026 23:18:12 +0300 Subject: [PATCH] mj2 add leave clan --- routes/auth.py | 16 ++++++++++++++++ templates/options.html | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/routes/auth.py b/routes/auth.py index 81c4fbb..7b80d8e 100644 --- a/routes/auth.py +++ b/routes/auth.py @@ -299,5 +299,21 @@ def remove_admin(admin_id): conn.close() return redirect(url_for('auth.options')) +# ------------------------------------------------------------------ +# POST /auth/clan/leave +# ------------------------------------------------------------------ +@auth.route('/auth/clan/leave', methods=['POST']) +@login_required +def leave_clan(): + conn = get_db() + if current_user.clan_id: + clan = conn.execute('SELECT owner_id FROM clans WHERE id = ?', (current_user.clan_id,)).fetchone() + if clan and clan['owner_id'] != current_user.id: + conn.execute('UPDATE users SET clan_id = NULL WHERE id = ?', (current_user.id,)) + conn.commit() + current_user.clan_id = None + flash("Έχετε αποχωρήσει από την ομάδα.", "success") + conn.close() + return redirect(url_for('auth.options')) diff --git a/templates/options.html b/templates/options.html index e1307ff..ccba294 100644 --- a/templates/options.html +++ b/templates/options.html @@ -319,6 +319,19 @@ {% endif %} + {% if clan.owner_id != current_user.id %} + +
+
🚪 Αποχώρηση από Clan
+

+ Εάν αποχωρήσετε, δεν θα έχετε πλέον πρόσβαση στους παίκτες αυτής της ομάδας. +

+
+ +
+
+ {% endif %} + {% else %}