Mj2 : modular and prepare for client options
This commit is contained in:
@@ -140,7 +140,9 @@ def options():
|
||||
'player_id': row['player_id'],
|
||||
'player_name': row['player_name'] or 'Άγνωστος',
|
||||
'joined_at': row['joined_at'][:10] if row['joined_at'] else '',
|
||||
'is_online': is_online
|
||||
'is_online': is_online,
|
||||
'feat_farm': 'farm' in (row['features'] or 'farm,admin'),
|
||||
'feat_admin': 'admin' in (row['features'] or 'farm,admin'),
|
||||
})
|
||||
|
||||
conn.close()
|
||||
@@ -191,9 +193,6 @@ def regenerate_key():
|
||||
return redirect(url_for('auth.options'))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# POST /auth/clan/remove-member/<player_id>
|
||||
# ------------------------------------------------------------------
|
||||
@auth.route('/auth/clan/remove-member/<player_id>', methods=['POST'])
|
||||
@login_required
|
||||
def remove_member(player_id):
|
||||
@@ -209,3 +208,28 @@ def remove_member(player_id):
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return redirect(url_for('auth.options'))
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# POST /auth/clan/update-features/<player_id>
|
||||
# ------------------------------------------------------------------
|
||||
@auth.route('/auth/clan/update-features/<player_id>', methods=['POST'])
|
||||
@login_required
|
||||
def update_member_features(player_id):
|
||||
farm = 'farm' if request.form.get('farm') else None
|
||||
admin = 'admin' if request.form.get('admin') else None
|
||||
features = ','.join(f for f in [farm, admin] if f) or ''
|
||||
|
||||
conn = get_db()
|
||||
clan = conn.execute(
|
||||
'SELECT id FROM clans WHERE owner_id = ?', (current_user.id,)
|
||||
).fetchone()
|
||||
if clan:
|
||||
conn.execute(
|
||||
'UPDATE clan_members SET features = ? WHERE clan_id = ? AND player_id = ?',
|
||||
(features, clan['id'], player_id)
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return redirect(url_for('auth.options'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user