Skip to content
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

Merged
merged 3 commits into from Apr 17, 2017

Conversation

ferbncode
Copy link
Member

Added functions moderation_log.create and moderation_log.list_logs and corresponding tests for managing logs.

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.")
Copy link
Contributor

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.


def create(*, admin_id, review_id=None, user_id=None,
action, reason):
"""Log blocking a user or hiding a review with IDs.
Copy link
Contributor

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."

logs = result.fetchall()
logs = [dict(log) for log in logs]
if logs:
for log in logs:
Copy link
Contributor

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():
    ...

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.")
Copy link
Contributor

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.

@gentlecat gentlecat merged commit eb0c5cf into metabrainz:master Apr 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants