Commit e9067925 authored by Martin Mareš's avatar Martin Mareš
Browse files

DB conversion commands are no longer needed

parent 2b2ded40
......@@ -1586,45 +1586,6 @@ def cli_add_teacher(course_ident, teacher):
db_connection.commit()
@app.cli.command("convert-emails")
def cli_convert_emails():
"""Convert e-mail addresses in the database from old SIS format."""
db_query("""
SELECT *
FROM owl_users
WHERE email LIKE '%%{%%'
""")
users = db.fetchall()
for u in users:
primary = primary_cas_email(u.email)
print(u.uid, u.full_name, u.email, '->', primary)
db_query("UPDATE owl_users SET email=%s WHERE uid=%s", (primary, u.uid))
db_connection.commit()
@app.cli.command("convert-names")
def cli_convert_emails():
"""Convert names in the database to new format."""
db_query("""
SELECT *
FROM owl_users
""")
users = db.fetchall()
for u in users:
f = u.full_name.split(' ')
if len(f) == 2:
db_query("UPDATE owl_users SET first_name=%s, last_name=%s WHERE uid=%s", (f[0], f[1], u.uid))
else:
print(f'UID {u.uid} needs manual fix: {f}')
db_connection.commit()
### Sending notifications ###
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment