-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finish audit fields for users
table
#1129
Conversation
@@ -14,6 +14,7 @@ | |||
|
|||
# Config Key Constants | |||
KEY_ALLOWED_EXTENSIONS = "ALLOWED_EXTENSIONS" | |||
KEY_APPROVE_REGISTRATIONS = "APPROVE_REGISTRATIONS" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this as a constant because it was being used throughout the tests.
users
tableusers
table
assert not user.is_disabled | ||
assert user.disabled_at is None | ||
assert user.disabled_by is None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the same statements, but they feel more intuitive written like this. I'd be happy to switch them back tho.
_, user = login_admin(client) | ||
_, current_user = login_admin(client) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the user
variable is referencing feels more clear with this change.
session.add(user) | ||
|
||
rv, _ = login_modified_disabled_user(client) | ||
assert b"/user/sam" in rv.data | ||
|
||
# Disable account again and check that login_required redirects user correctly | ||
user.is_disabled = True | ||
session.add(user) | ||
user.disable_user(User.query.filter_by(is_administrator=True).first().id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we doing is_admin
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the disable_user
function is setup, it requires a user.id
so that we can see who made the action. In this case, I just pulled the first administrator user I could find and took that ID. I could have also just put 1
as the value as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's very helpful and makes perfect sense. Thanks!
Fixes issue
#1004
Description of Changes
Added
disabled_by
,disabled_at
,approved_at
,approved_by
, andconfirmed_at
, andconfirmed_by
fields to theusers
table so that we could keep track of users actions on the platform at a more granular level. I also removed the previously mentioned columns corresponding boolean columns.Tests and Linting
develop
branch.pytest
passes on my local development environment.pre-commit
passes on my local development environment.flask db upgrade
andflask db downgrade
functions work for both migrations.