-
Notifications
You must be signed in to change notification settings - Fork 2
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
Associate comments with users and use username for author name #831
Conversation
@@ -0,0 +1,28 @@ | |||
"""Start associating comments with registered users and use user information |
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.
I'd frame these migration notes as 1) describing the change on the DB (e.g. "Add a user_id column to user_comments and drop author_name.") 2) then describe why (e.g. "This allows us to associate comments with users in the database.")
Awesome, thanks for doing this. I'm still looking through/commenting, but wanted to ask if the reason for the Anonymous user was for passing seltest tests (the only time I can think of that we have Anonymous users)? |
Thanks for the comments @ihodes -- keep them coming :) About the Anonymous user and the need for seltests: yes and no -- seltests are the only place where we set There might be other workarounds for this, but I thought that this might be good way for us to move forwards where we can customize the fields for Anonymous user and reduce the complexity of the code in other places. |
userify_comment(comment) | ||
return comments | ||
|
||
def userify_comment(comment): |
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.
I'd call this something like add_user_to_comment
to make it a little clearer that's going on (I see the parallels with epochify_comment
, but it's doing something a bit different).
""" | ||
if 'userId' in comment: | ||
with tables(db.engine, 'users') as (con, users): | ||
q = select(users.c).where(users.c.id == comment['userId']) |
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.
q = select([users.c.username, users.c.email, users.c.id])...
; generally better to whitelist than blacklist (which also lets you get rid of "desentisize_user" (if keeping it, spelling -> desensitize).
This looks great; a few mostly minor comments. This really exposed you to the whole Cycledash stack now :) Thanks for handling this! |
d604d04
to
1ea942d
Compare
Thanks @ihodes, this was really fun to work on. The latest changes address all your comments/suggestions. |
Awesome, thanks--looks good to merge once you get it to go green! Mind squashing those commits down a bit, first? |
d6f94e4
to
6b2e0fd
Compare
6b2e0fd
to
536595e
Compare
Associate comments with users and use username for author name
This PR deprecates #813 and adds support for proper associations between comments and their authors. With this change, we get rid of the
Author Name
field from theCommentBox
and automatically assign user to a new comment: if the user logged in, then the comments belong to that user; if not, it is anonymous. If the user authentication is not enabled, all comments will be anonymous.This PR requires a minor update to our DB schema and hence features an alembic migration script. During migration, all of our comments will lose their
author_name
information and therefore will become anonymous.Here are some screenshots to get a feeling of how this looks now: