diff --git a/bin/add-role b/bin/add-role index 046b33c2d783cc63eb06b8662fcd31634ae57dcb..465c0e194c6ac908d88983ca3f3ff2f690b876cd 100755 --- a/bin/add-role +++ b/bin/add-role @@ -61,8 +61,8 @@ ur = db.UserRole( session.add(ur) session.flush() -mo.util.log(db.LogType.user_role, ur.user_role_id, { - 'action': 'assigned', - 'new': db.row2dict(ur), +mo.util.log(db.LogType.user, user.user_id, { + 'action': 'new-role', + 'role': db.row2dict(ur), }) session.commit() diff --git a/db/db.ddl b/db/db.ddl index 161edc2ef218e4a96f33092d88929a043f571ed9..4e9d5d77cc1767132904f0155416f6472d7bb86f 100644 --- a/db/db.ddl +++ b/db/db.ddl @@ -290,7 +290,7 @@ CREATE TYPE log_type AS ENUM ( 'contest', -- contests(contest_id) 'participant', -- participants(user_id) 'task', -- tasks(task_id) - 'user_role' -- user_roles(user_id) + 'user_role' -- user_roles(user_id) -- momentálně nepoužíváme, změny rolí logujeme pod user_id ); CREATE TABLE log ( diff --git a/mo/imports.py b/mo/imports.py index 0e094d776add33be70fb439c4123b8ed64eb5421..0194f1d9912832f4f73ca134ff3c90e85d58e89d 100644 --- a/mo/imports.py +++ b/mo/imports.py @@ -295,9 +295,9 @@ class Import: sess.flush() logger.info(f'Import: {role.name.title()} user=#{user.user_id} place=#{ place.place_id if place else "null" } user_role=#{ur.user_role_id}') mo.util.log( - type=db.LogType.user_role, - what=ur.user_role_id, - details={'action': 'import', 'new': db.row2dict(ur)}, + type=db.LogType.user, + what=user.user_id, + details={'action': 'import-role', 'role': db.row2dict(ur)}, ) self.cnt_new_roles += 1 diff --git a/mo/web/org_users.py b/mo/web/org_users.py index 7b9f5c44060c2a72452d9f154c1d5ae46398f10b..9058e25375b8ed6ba78e22f91c29a8db694e8769 100644 --- a/mo/web/org_users.py +++ b/mo/web/org_users.py @@ -316,12 +316,12 @@ def org_org(id: int): sess.add(new_role) sess.flush() mo.util.log( - type=db.LogType.user_role, + type=db.LogType.user, what=id, - details={'action': 'new', 'role': db.row2dict(new_role)}, + details={'action': 'new-role', 'role': db.row2dict(new_role)}, ) sess.commit() - app.logger.info(f"New role for user id {id} added: {db.row2dict(new_role)}") + app.logger.info(f"New role for user #{id} added: {db.row2dict(new_role)}") flash(f'Role "{new_role}" úspěšně přidána', 'success') return redirect(url_for('org_user', id=id)) @@ -335,12 +335,12 @@ def org_org(id: int): else: sess.delete(role) mo.util.log( - type=db.LogType.user_role, + type=db.LogType.user, what=id, - details={'action': 'delete', 'role': db.row2dict(role)}, + details={'action': 'delete-role', 'role': db.row2dict(role)}, ) sess.commit() - app.logger.info(f"Role for user {id} removed: {db.row2dict(role)}") + app.logger.info(f"Role for user #{id} removed: {db.row2dict(role)}") flash(f'Role "{role}" úspěšně odebrána', 'success') return redirect(url_for('org_user', id=id))