Skip to content

Add admin and description fields to AuditRecord model #2225

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

Merged
merged 4 commits into from
Mar 26, 2025

Conversation

jjnesbitt
Copy link
Member

Closes #2224

This introduces two new fields to the AuditRecord model: admin and description. These fields are to be used in conjunction, when the modification of something in the system is done through administrative means, and not the normal workflow. An example of this would be if we were to fix some malformed data that existing in some versions or assets.

@jjnesbitt jjnesbitt requested a review from waxlamp March 20, 2025 17:23
Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but I want to strengthen the check constraint and reduce the "line noise" of the common params abstraction.

Copy link
Member

@waxlamp waxlamp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had talked about making the username column nullable, but I had forgotten that column (along with the user_email and user_fullname columns) is text, not a foreign key to a user model. Does that mean we don't need these columns to be nullable at all, and can instead leave them blank or use stand-in data (like "admin", "[email protected]", and "DANDI admin team")?

If yes, then this is ready to merge; otherwise let's discuss what we should do.

@jjnesbitt
Copy link
Member Author

We had talked about making the username column nullable, but I had forgotten that column (along with the user_email and user_fullname columns) is text, not a foreign key to a user model. Does that mean we don't need these columns to be nullable at all, and can instead leave them blank or use stand-in data (like "admin", "[email protected]", and "DANDI admin team")?

If yes, then this is ready to merge; otherwise let's discuss what we should do.

Correct, my vote would be that we just leave them blank, instead of allow null.

I'm realizing that we may want to require those fields be non-empty if admin=False. Although you could make the case it falls outside the scope of this PR (since if that's desired, the constraint should have already existed anyway).

If you agree we shouldn't address that here and now, then I agree with your previous comment that this is ready to merge.

@mvandenburgh
Copy link
Member

Correct, my vote would be that we just leave them blank, instead of allow null.

I agree. In addition to the reasons already stated, there's also this rule - https://docs.astral.sh/ruff/rules/django-nullable-model-string-field/.

@jjnesbitt jjnesbitt merged commit e09b033 into master Mar 26, 2025
11 checks passed
@jjnesbitt jjnesbitt deleted the admin-audit-records branch March 26, 2025 19:41
@waxlamp
Copy link
Member

waxlamp commented Mar 26, 2025

I'm realizing that we may want to require those fields be non-empty if admin=False

Good point. Please go ahead and do that in a followup PR.

@mvandenburgh mvandenburgh added the minor Increment the minor version when merged label Apr 16, 2025
@dandibot
Copy link
Member

🚀 PR was released in v0.5.0 🚀

@dandibot dandibot added the released This issue/pull request has been released. label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add admin audit records
4 participants