Skip to content
Snippets Groups Projects
Commit a40a159f authored by Martin Mareš's avatar Martin Mareš
Browse files

Role nyní logujeme pod user_id

Closes #252.
parent 1b2871c6
Branches
No related tags found
No related merge requests found
......@@ -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()
......@@ -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 (
......
......@@ -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
......
......@@ -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))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment