Browse Source

Fixed locale not found contact form

development
Godwin 8 years ago
parent
commit
553e412685
  1. 20
      app/helpers/application_helper.rb
  2. 3
      app/views/application/_contact.html.haml
  3. 2
      app/views/application/locale_not_available.html.haml

20
app/helpers/application_helper.rb

@ -216,13 +216,21 @@ module ApplicationHelper
content_tag(:span, text.html_safe, id: id, class: 'screen-reader-text')
end
def url_for_locale(locale)
new_params = params.merge({action: (params[:_original_action] || params[:action])})
new_params.delete(:_original_action)
def url_for_locale(locale, url = nil)
unless url.present?
new_params = params.merge({action: (params[:_original_action] || params[:action])})
new_params.delete(:_original_action)
if Rails.env.development? || Rails.env.test?
url = url_for(new_params.merge({lang: locale.to_s}))
else
url = url_for(new_params)
end
end
return url_for(new_params.merge({lang: locale.to_s})) if Rails.env.development? || Rails.env.test?
return "https://preview-#{locale.to_s}.bikebike.org#{url_for(new_params)}" if Rails.env.preview?
"https://#{locale.to_s}.bikebike.org#{url_for(new_params)}"
return url if Rails.env.development? || Rails.env.test?
return "https://preview-#{locale.to_s}.bikebike.org#{url}" if Rails.env.preview?
"https://#{locale.to_s}.bikebike.org#{url}"
end
def registration_steps(conference = @conference)

3
app/views/application/_contact.html.haml

@ -1,5 +1,6 @@
- contact_reason ||= nil
= form_tag contact_send_path, class: 'contact-form' do
- locale ||= nil
= form_tag (locale.present? ? contact_send_url : url_for_locale(locale, contact_send_url)), class: 'contact-form' do
= emailfield :email, nil, big: true, required: true unless logged_in?
- if contact_reason.present?
= hidden_field_tag :reason, contact_reason

2
app/views/application/locale_not_available.html.haml

@ -10,4 +10,4 @@
=_'translate.content.change_locale', "Read in #{locale_translation}", vars: {language: locale_translation}, locale: locale
%h2= _'error.locale_not_available.volunteer.title'
%p= _'error.locale_not_available.volunteer.description'
= render 'contact', cancel_btn: false, contact_reason: :website
= render 'contact', cancel_btn: false, contact_reason: :website, locale: :en
Loading…
Cancel
Save