Make the site contact a drop down of admin users
This commit is contained in:
parent
f5a36befc6
commit
644bcbc253
|
@ -3266,8 +3266,8 @@ en:
|
||||||
label: "Contact URL"
|
label: "Contact URL"
|
||||||
placeholder: "http://www.example.com/contact-us"
|
placeholder: "http://www.example.com/contact-us"
|
||||||
description: "Will be displayed on your \"About\" page."
|
description: "Will be displayed on your \"About\" page."
|
||||||
site_contact_username:
|
site_contact:
|
||||||
label: "Site Contact Username"
|
label: "Site Contact"
|
||||||
description: "All automated messages will be sent from this user."
|
description: "All automated messages will be sent from this user."
|
||||||
|
|
||||||
corporate:
|
corporate:
|
||||||
|
|
|
@ -56,10 +56,16 @@ class Wizard
|
||||||
@wizard.append_step('contact') do |step|
|
@wizard.append_step('contact') do |step|
|
||||||
step.add_field(id: 'contact_email', type: 'text', required: true, value: SiteSetting.contact_email)
|
step.add_field(id: 'contact_email', type: 'text', required: true, value: SiteSetting.contact_email)
|
||||||
step.add_field(id: 'contact_url', type: 'text', value: SiteSetting.contact_url)
|
step.add_field(id: 'contact_url', type: 'text', value: SiteSetting.contact_url)
|
||||||
step.add_field(id: 'site_contact_username', type: 'text', value: SiteSetting.site_contact_username)
|
|
||||||
|
username = SiteSetting.site_contact_username
|
||||||
|
username = Discourse.system_user.username if username.blank?
|
||||||
|
contact = step.add_field(id: 'site_contact', type: 'dropdown', value: username)
|
||||||
|
|
||||||
|
User.where(admin: true).pluck(:username).each {|c| contact.add_choice(c) }
|
||||||
|
|
||||||
step.on_update do |updater|
|
step.on_update do |updater|
|
||||||
updater.apply_settings(:contact_email, :contact_url, :site_contact_username)
|
updater.apply_settings(:contact_email, :contact_url)
|
||||||
|
updater.update_setting(:site_contact_username, updater.fields[:site_contact])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe Wizard::StepUpdater do
|
||||||
updater = wizard.create_updater('contact',
|
updater = wizard.create_updater('contact',
|
||||||
contact_email: 'eviltrout@example.com',
|
contact_email: 'eviltrout@example.com',
|
||||||
contact_url: 'http://example.com/custom-contact-url',
|
contact_url: 'http://example.com/custom-contact-url',
|
||||||
site_contact_username: user.username)
|
site_contact: user.username)
|
||||||
|
|
||||||
updater.update
|
updater.update
|
||||||
expect(updater).to be_success
|
expect(updater).to be_success
|
||||||
|
|
Loading…
Reference in New Issue