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
CB-230: Migrate Moderation Log code off the ORM. #93
CB-230: Migrate Moderation Log code off the ORM. #93
Conversation
a157957
to
03bc4e0
Compare
critiquebrainz/db/moderation_log.py
Outdated
reason (str): Reason for blocking a user or hiding a review. | ||
""" | ||
if not review_id and not user_id: | ||
raise TypeError("No review ID or user ID specified.") |
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.
ValueError
would be more appropriate here and below.
critiquebrainz/db/moderation_log.py
Outdated
|
||
def create(*, admin_id, review_id=None, user_id=None, | ||
action, reason): | ||
"""Log blocking a user or hiding a review with IDs. |
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.
blocking a user or hiding a review
This doesn't have to be so specific. You could just say something like "Make a record in the moderation log."
critiquebrainz/db/moderation_log.py
Outdated
logs = result.fetchall() | ||
logs = [dict(log) for log in logs] | ||
if logs: | ||
for log in logs: |
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.
Instead of having two loops you could just do something like
logs = []
for log in result.fetchall():
...
6c63ff5
to
ad38d95
Compare
critiquebrainz/db/moderation_log.py
Outdated
if not review_id and not user_id: | ||
raise ValueError("No review ID or user ID specified.") | ||
if action != ACTION_BLOCK_USER and action != ACTION_HIDE_REVIEW: | ||
raise TypeError("Please specify a valid action.") |
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.
Same problem with exception. Make sure to use the right class everywhere.
Added functions
moderation_log.create
andmoderation_log.list_logs
and corresponding tests for managing logs.