feat: Allow tribe renaming
This commit is contained in:
parent
bd149f012e
commit
8ecc960c58
10
db.py
10
db.py
@ -361,3 +361,13 @@ def delete_tribe(tribe):
|
|||||||
connection.commit()
|
connection.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
||||||
|
def rename_tribe(old,new):
|
||||||
|
connection = mysql.connector.connect(**dbargs)
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute("""
|
||||||
|
UPDATE tribes SET tribe = %s WHERE tribe = %s
|
||||||
|
""", (new,old))
|
||||||
|
connection.commit()
|
||||||
|
cursor.close()
|
||||||
|
connection.close()
|
14
main.py
14
main.py
@ -523,6 +523,20 @@ def edit_tribe():
|
|||||||
# Convert to json
|
# Convert to json
|
||||||
data = json.dumps(data)
|
data = json.dumps(data)
|
||||||
db.update_tribe_data_raw(tribe,data)
|
db.update_tribe_data_raw(tribe,data)
|
||||||
|
|
||||||
|
# Check if tribe name changed
|
||||||
|
if tribe != request.form['tribe']:
|
||||||
|
# Verify new tribe name
|
||||||
|
new_tribe = request.form['tribe'].strip().lower()
|
||||||
|
if not re.match("^[a-z0-9_]*$", new_tribe):
|
||||||
|
return error('Sorry tribe can only contain lowercase letters, numbers and underscores')
|
||||||
|
if new_tribe.startswith("_") or new_tribe.endswith("_"):
|
||||||
|
return error('Sorry tribe can\'t start or end with an underscore')
|
||||||
|
|
||||||
|
# Delete old tribe
|
||||||
|
db.rename_tribe(tribe,new_tribe)
|
||||||
|
|
||||||
|
|
||||||
return redirect('/edit_tribe')
|
return redirect('/edit_tribe')
|
||||||
|
|
||||||
@app.route('/remove_member')
|
@app.route('/remove_member')
|
||||||
|
Loading…
Reference in New Issue
Block a user