FIX: rename action_code_href to action_code_path (#234)

We should use relative paths, therefore name change is necessary to avoid confusions. Post migration is added to fix existing data.
This commit is contained in:
Krzysztof Kotlarek 2021-11-08 14:32:21 +11:00 committed by GitHub
parent 22025b35b8
commit 2d1f5668a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 6 deletions

View File

@ -7,12 +7,12 @@ en:
action_codes: action_codes:
assigned: "assigned %{who} %{when}" assigned: "assigned %{who} %{when}"
assigned_group: "assigned %{who} %{when}" assigned_group: "assigned %{who} %{when}"
assigned_to_post: "assigned %{who} to <a href='%{href}' data-auto-route='true'>post</a> %{when}" assigned_to_post: "assigned %{who} to <a href='%{path}' data-auto-route='true'>post</a> %{when}"
assigned_group_to_post: "assigned %{who} to <a href='%{href}' data-auto-route='true'>post</a> %{when}" assigned_group_to_post: "assigned %{who} to <a href='%{path}' data-auto-route='true'>post</a> %{when}"
unassigned: "unassigned %{who} %{when}" unassigned: "unassigned %{who} %{when}"
unassigned_group: "unassigned %{who} %{when}" unassigned_group: "unassigned %{who} %{when}"
unassigned_from_post: "unassigned %{who} from <a href='%{href}' data-auto-route='true'>post</a> %{when}" unassigned_from_post: "unassigned %{who} from <a href='%{path}' data-auto-route='true'>post</a> %{when}"
unassigned_group_from_post: "unassigned %{who} from <a href='%{href}' data-auto-route='true'>post</a> %{when}" unassigned_group_from_post: "unassigned %{who} from <a href='%{path}' data-auto-route='true'>post</a> %{when}"
discourse_assign: discourse_assign:
add_unassigned_filter: "Add 'unassigned' filter to category" add_unassigned_filter: "Add 'unassigned' filter to category"
cant_act: "You cannot act on flags that have been assigned to other users" cant_act: "You cannot act on flags that have been assigned to other users"

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
class ChangeActionCodeHrefToActionCodePath < ActiveRecord::Migration[6.1]
def up
DB.exec(<<~SQL)
UPDATE post_custom_fields
SET name = 'action_code_path'
WHERE name = 'action_code_href'
SQL
end
def down
DB.exec(<<~SQL)
UPDATE post_custom_fields
SET name = 'action_code_href'
WHERE name = 'action_code_path'
SQL
end
end

View File

@ -253,7 +253,7 @@ class ::Assigner
custom_fields = { "action_code_who" => assign_to.is_a?(User) ? assign_to.username : assign_to.name } custom_fields = { "action_code_who" => assign_to.is_a?(User) ? assign_to.username : assign_to.name }
if post_target? if post_target?
custom_fields.merge!("action_code_href" => "/p/#{@target.id}") custom_fields.merge!("action_code_path" => "/p/#{@target.id}")
end end
topic.add_moderator_post( topic.add_moderator_post(
@ -333,7 +333,7 @@ class ::Assigner
custom_fields = { "action_code_who" => assigned_to.is_a?(User) ? assigned_to.username : assigned_to.name } custom_fields = { "action_code_who" => assigned_to.is_a?(User) ? assigned_to.username : assigned_to.name }
if post_target? if post_target?
custom_fields.merge!("action_code_href" => "/p/#{@target.id}") custom_fields.merge!("action_code_path" => "/p/#{@target.id}")
end end
topic.add_moderator_post( topic.add_moderator_post(