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

Allow Organizations to Update Slug/Username #1411

Merged
merged 13 commits into from Jan 10, 2019

Conversation

Zhao-Andy
Copy link
Contributor

@Zhao-Andy Zhao-Andy commented Dec 27, 2018

What type of PR is this? (check all applicable)

  • Feature

Description

This allows organizations to update their slug or their username.

screen shot 2018-12-27 at 4 37 58 pm

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?

  • no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

A "slug" with a cape smiling!

@Zhao-Andy Zhao-Andy changed the title WIP Allow Organizations to Update Slug/Username Allow Organizations to Update Slug/Username Dec 28, 2018
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Dec 28, 2018
@benhalpern
Copy link
Contributor

This will also need the proper redirects in the stories_controller, similar to users.

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

@Zhao-Andy Zhao-Andy Dec 28, 2018

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.

Copy link
Contributor

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.

@Zhao-Andy Zhao-Andy changed the title Allow Organizations to Update Slug/Username WIP Allow Organizations to Update Slug/Username Dec 28, 2018
@pr-triage pr-triage bot removed the PR: unreviewed bot applied label for PR's with no review label Dec 28, 2018
@Zhao-Andy Zhao-Andy changed the title WIP Allow Organizations to Update Slug/Username Allow Organizations to Update Slug/Username Dec 28, 2018
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Dec 28, 2018
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)
Copy link
Contributor

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.

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels Jan 7, 2019
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels Jan 8, 2019
if @user&.articles&.find_by_slug(params[:slug])
redirect_to "/#{@user.username}/#{params[:slug]}"
return
elsif @organization = @article.organization
Copy link
Contributor Author

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.

@pr-triage pr-triage bot removed the PR: unreviewed bot applied label for PR's with no review label Jan 10, 2019
@pr-triage pr-triage bot added the PR: reviewed-approved bot applied label for PR's where reviewer approves changes label Jan 10, 2019
@benhalpern benhalpern merged commit 68807c6 into forem:master Jan 10, 2019
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: reviewed-approved bot applied label for PR's where reviewer approves changes labels Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
3 participants