Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Group action bugfixes
Dieser Commit ist enthalten in:
Ursprung
8cfdaf94ef
Commit
74e8525251
1 geänderte Dateien mit 17 neuen und 15 gelöschten Zeilen
|
@ -23,8 +23,7 @@ class CustomWizard::Action
|
||||||
|
|
||||||
if @log.any?
|
if @log.any?
|
||||||
@log.each do |item|
|
@log.each do |item|
|
||||||
log << "; result: "
|
log << "; #{item.to_s}"
|
||||||
log << item.to_s
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,12 +123,12 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
if result
|
if result
|
||||||
log_success("updated profile fields", params.keys.map{ |p| p.to_s }.join(','))
|
log_success("updated profile fields", "fields: #{params.keys.map{ |p| p.to_s }.join(',')}")
|
||||||
else
|
else
|
||||||
log_error("failed to update profile fields")
|
log_error("failed to update profile fields", "result: #{result.inspect}")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log_error("invalid profile fields params", params.inspect)
|
log_error("invalid profile fields params", "params: #{params.inspect}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,7 +188,7 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_group
|
def add_to_group
|
||||||
groups = CustomWizard::Mapper.new(
|
group_map = CustomWizard::Mapper.new(
|
||||||
inputs: action['group'],
|
inputs: action['group'],
|
||||||
data: data,
|
data: data,
|
||||||
user: user,
|
user: user,
|
||||||
|
@ -198,17 +197,19 @@ class CustomWizard::Action
|
||||||
}
|
}
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
groups = groups.flatten.reduce([]) do |result, g|
|
groups = group_map.flatten.reduce([]) do |groups, g|
|
||||||
begin
|
begin
|
||||||
result.push(Integer(g))
|
groups.push(Integer(g))
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
group = Group.find_by(name: g)
|
group = Group.find_by(name: g)
|
||||||
result.push(group.id) if group
|
groups.push(group.id) if group
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
groups
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result = nil
|
||||||
|
|
||||||
if groups.present?
|
if groups.present?
|
||||||
groups.each do |group_id|
|
groups.each do |group_id|
|
||||||
group = Group.find(group_id) if group_id
|
group = Group.find(group_id) if group_id
|
||||||
|
@ -217,9 +218,10 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
if result
|
if result
|
||||||
log_success("added to groups", groups.map { |g| g.id.to_s }.join(','))
|
log_success("added to groups", "groups: #{groups.map(&:to_s).join(',')}")
|
||||||
else
|
else
|
||||||
log_error("failed to add to groups")
|
detail = groups.present? ? "groups: #{groups.map(&:to_s).join(',')}" : nil
|
||||||
|
log_error("failed to add to groups", detail)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -354,14 +356,14 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_success(message, detail = nil)
|
def log_success(message, detail = nil)
|
||||||
@log.push("success - #{message} - #{detail}")
|
@log.push("success: #{message} - #{detail}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_error(message, detail = nil)
|
def log_error(message, detail = nil)
|
||||||
@log.push("error - #{message} - #{detail}")
|
@log.push("error: #{message} - #{detail}")
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_info(message, detail = nil)
|
def log_info(message, detail = nil)
|
||||||
@log.push("info - #{message} - #{detail}")
|
@log.push("info: #{message} - #{detail}")
|
||||||
end
|
end
|
||||||
end
|
end
|
Laden …
In neuem Issue referenzieren