Skip to content

Commit

Permalink
Temporary work-around to fix and troubleshoot bad Work URLs generated…
Browse files Browse the repository at this point in the history
… in some places
  • Loading branch information
hectorcorrea committed Apr 25, 2024
1 parent e707bd4 commit adcab87
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/mailers/notification_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ def build_message
@message_html = @work_activity.to_html
@url = work_url(@work_activity.work)

# Troubleshooting https://github.com/pulibrary/pdc_describe/issues/1783
if @url.includes?("/describe/describe/")
Rails.logger.error("URL #{@url} included /describe/describe/ and was fixed. See https://github.com/pulibrary/pdc_describe/issues/1783")
@url = @url.gsub("/describe/describe/", "/describe/")
end

mail(to: @user.email, subject: @subject)
end
end
7 changes: 7 additions & 0 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ def update_curator(curator_user_id, current_user)
new_curator = User.find(curator_user_id)

work_url = "[#{title}](#{Rails.application.routes.url_helpers.work_url(self)})"

# Troubleshooting https://github.com/pulibrary/pdc_describe/issues/1783
if work_url.includes?("/describe/describe/")
Rails.logger.error("URL #{work_url} included /describe/describe/ and was fixed. See https://github.com/pulibrary/pdc_describe/issues/1783")
work_url = work_url.gsub("/describe/describe/", "/describe/")
end

message = if curator_user_id.to_i == current_user.id
"Self-assigned @#{current_user.uid} as curator for work #{work_url}"
else
Expand Down
7 changes: 7 additions & 0 deletions app/models/work_state_transition_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ def initialize(work, current_user_id)
@group = work.group
@group_administrators = group.administrators.to_a
@work_url = Rails.application.routes.url_helpers.work_url(work)

# Troubleshooting https://github.com/pulibrary/pdc_describe/issues/1783
if @work_url.includes?("/describe/describe/")
Rails.logger.error("URL #{@work_url} included /describe/describe/ and was fixed. See https://github.com/pulibrary/pdc_describe/issues/1783")
@work_url = @work_url.gsub("/describe/describe/", "/describe/")
end

@work_title = work.title
@notification = notification_for_transition
@id = work.id
Expand Down

0 comments on commit adcab87

Please sign in to comment.