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
Allow Organizations to Update Slug/Username #1411
Allow Organizations to Update Slug/Username #1411
Conversation
This will also need the proper redirects in the |
if @user = User.find_by_old_username(params[:username].tr("@", "").downcase) | ||
potential_username = params[:username].tr("@", "").downcase | ||
@user = User.find_by_old_username(potential_username) || User.find_by_old_old_username(potential_username) | ||
@organization = Organization.find_by_old_slug(potential_username) || Organization.find_by_old_old_slug(potential_username) |
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.
@benhalpern I added proper redirect for org paths. I also changed the method a bit. Not sure if this is the best approach since it technically runs 4 queries each time.
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.
Yeah, I think this should be done differently. We can pair on it if you'd like.
if @user = User.find_by_old_username(params[:username].tr("@", "").downcase) | ||
potential_username = params[:username].tr("@", "").downcase | ||
@user = User.find_by_old_username(potential_username) || User.find_by_old_old_username(potential_username) | ||
@organization = Organization.find_by_old_slug(potential_username) || Organization.find_by_old_old_slug(potential_username) |
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.
Yeah, I think this should be done differently. We can pair on it if you'd like.
if @user&.articles&.find_by_slug(params[:slug]) | ||
redirect_to "/#{@user.username}/#{params[:slug]}" | ||
return | ||
elsif @organization = @article.organization |
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.
This keeps the logic consistent with existing behavior, where it redirects to an organization's article if params[:slug]
found an article. This also means we don't have to look for an organization's old_slug
or old_old_slug
.
What type of PR is this? (check all applicable)
Description
This allows organizations to update their
slug
or theirusername
.Related Tickets & Documents
Resolves #417 by clearing up the confusion of what the
name
field is for, and resolves #462 by allowing organizations to update their URL.Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?