From 9a4c39b2079e13936bc386cadeaff27d3a9377a2 Mon Sep 17 00:00:00 2001 From: Godwin Date: Sun, 17 Jul 2016 11:42:21 -0700 Subject: [PATCH] Registration questions complete but need translations --- app/controllers/application_controller.rb | 2 +- app/controllers/conferences_controller.rb | 153 ++------------------- app/helpers/application_helper.rb | 2 +- app/mailers/user_mailer.rb | 20 +-- app/views/application/home.html.haml | 8 +- app/views/conferences/_questions.html.haml | 4 +- config/locales/en.yml | 11 +- config/locales/es.yml | 18 +-- 8 files changed, 50 insertions(+), 168 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e39f1dc..7356f14 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -124,7 +124,7 @@ class ApplicationController < LinguaFrancaApplicationController render 'application/permission_denied', status: 403 end - def error_500(exception) + def error_500(exception = nil) @page_title = 'page_titles.500.An_Error_Occurred' @main_title = 'error.500.title' params[:_original_action] = params[:action] diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 7df73ce..fc55a43 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -431,7 +431,7 @@ class ConferencesController < ApplicationController if request.format.xls? logger.info "Generating stats.xls" @excel_data = { - :columns => [:name, :email, :city, :date, :languages, :arrival, :departure, :housing, :bike, :food, :allergies, :other, :fees_paid], + :columns => [:name, :email, :city, :date, :languages, :arrival, :departure, :housing, :companion, :bike, :food, :allergies, :other, :fees_paid], :key => 'articles.conference_registration.headings', :data => [] } @@ -480,6 +480,7 @@ class ConferencesController < ApplicationController :arrival => r.arrival ? r.arrival.strftime("%F %T") : '', :departure => r.departure ? r.departure.strftime("%F %T") : '', :housing => (I18n.t"articles.conference_registration.questions.housing.#{r.housing || 'none'}"), + :companion => (r.housing_data[:companions] || []).join(', '), :bike => (I18n.t"articles.conference_registration.questions.bike.#{r.bike || 'none'}"), :food => (I18n.t"articles.conference_registration.questions.food.#{r.food || 'meat'}"), :fees_paid => (r.registration_fees_paid || 0.0), @@ -533,8 +534,8 @@ class ConferencesController < ApplicationController @register_template = :confirm_email end - steps = registration_steps - return do_404 unless steps.present? + steps = nil + return do_404 unless registration_steps.present? @register_template = :administration if params[:admin_step].present? @@ -542,8 +543,10 @@ class ConferencesController < ApplicationController @warnings = [] form_step = params[:button] ? params[:button].to_sym : nil + # process any data that was passed to us if form_step if form_step.to_s =~ /^prev_(.+)$/ + steps = registration_steps @register_template = steps[steps.find_index($1.to_sym) - 1] elsif form_step == :paypal_confirm if @registration.present? && @registration.payment_confirmation_token == params[:confirmation_token] @@ -636,6 +639,9 @@ class ConferencesController < ApplicationController @registration.housing = params[:housing] @registration.arrival = params[:arrival] @registration.departure = params[:departure] + @registration.housing_data = { + companions: [ params[:companion] ] + } @registration.bike = params[:bike] @registration.food = params[:food] @registration.allergies = params[:allergies] @@ -666,6 +672,7 @@ class ConferencesController < ApplicationController @register_template = form_step else unless @registration.nil? + steps = registration_steps @register_template = steps[steps.find_index(form_step) + 1] # have we reached a new level? @@ -689,6 +696,9 @@ class ConferencesController < ApplicationController end end + steps ||= registration_steps + + # make sure we're on a valid step @register_template ||= (params[:step] || current_step).to_sym if logged_in? && @register_template != :paypal_confirm @@ -703,143 +713,10 @@ class ConferencesController < ApplicationController # then we'll redirect to the current registration step end - # process data from the last view - # case (params[:button] || '').to_sym - # when :confirm_email - # @register_template = :email_sent if is_post - # when :policy - # @register_template = :questions if is_post - # when :save - # if is_post - # new_registration = !@registration - # @registration = ConferenceRegistration.new if new_registration - - # @registration.conference_id = @this_conference.id - # @registration.user_id = current_user.id - # @registration.is_attending = 'yes' - # @registration.is_confirmed = true - # @registration.city = params[:location] - # @registration.arrival = params[:arrival] - # @registration.languages = params[:languages].keys.to_json - # @registration.departure = params[:departure] - # @registration.housing = params[:housing] - # @registration.bike = params[:bike] - # @registration.food = params[:food] - # @registration.allergies = params[:allergies] - # @registration.other = params[:other] - # @registration.save - - # current_user.firstname = params[:name].squish - # current_user.lastname = nil - # current_user.save - - # if new_registration - # UserMailer.send_mail :registration_confirmation do - # { - # :args => @registration - # } - # end - # end - - # @register_template = @registration.registration_fees_paid ? :done : :payment - # end - # when :payment - # if is_post && @registration - # amount = params[:amount].to_f - - # if amount > 0 - # @registration.payment_confirmation_token = ENV['RAILS_ENV'] == 'test' ? 'token' : Digest::SHA256.hexdigest(rand(Time.now.to_f * 1000000).to_i.to_s) - # @registration.save - - # host = "#{request.protocol}#{request.host_with_port}" - # response = PayPal!.setup( - # PayPalRequest(amount), - # register_paypal_confirm_url(@this_conference.slug, :paypal_confirm, @registration.payment_confirmation_token), - # register_paypal_confirm_url(@this_conference.slug, :paypal_cancel, @registration.payment_confirmation_token) - # ) - # if ENV['RAILS_ENV'] != 'test' - # redirect_to response.redirect_uri - # end - # return - # end - # @register_template = :done - # end - # when :paypal_confirm - # if @registration && @registration.payment_confirmation_token == params[:confirmation_token] - - # if ENV['RAILS_ENV'] == 'test' - # @amount = YAML.load(@registration.payment_info)[:amount] - # else - # @amount = PayPal!.details(params[:token]).amount.total - # # testing this does't work in test but it works in devo and prod - # @registration.payment_info = {:payer_id => params[:PayerID], :token => params[:token], :amount => @amount}.to_yaml - # end - - # @amount = (@amount * 100).to_i.to_s.gsub(/^(.*)(\d\d)$/, '\1.\2') - - # @registration.save! - # @register_template = :paypal_confirm - # end - # when :paypal_confirmed - # info = YAML.load(@registration.payment_info) - # @amount = nil - # status = nil - # if ENV['RAILS_ENV'] == 'test' - # status = info[:status] - # @amount = info[:amount] - # else - # paypal = PayPal!.checkout!(info[:token], info[:payer_id], PayPalRequest(info[:amount])) - # status = paypal.payment_info.first.payment_status - # @amount = paypal.payment_info.first.amount.total - # end - # if status == 'Completed' - # @registration.registration_fees_paid = @amount - # @registration.save! - # @register_template = :done - # else - # @register_template = :payment - # end - # when :paypal_cancel - # if @registration - # @registration.payment_confirmation_token = nil - # @registration.save - # @register_template = :payment - # end - # when :register - # @register_template = :questions - # end - - # if @register_template == :payment && !@this_conference.paypal_username - # @register_template = :done - # end - - # # don't let the user edit registration if registration is closed - # if !@conference.registration_open && @register_template == :questions - # @register_template = :done - # end - - # prepare data for the next view + # prepare the form case @register_template when :questions - @registration ||= ConferenceRegistration.new( - :conference_id => @this_conference.id, - :user_id => current_user.id, - :is_attending => 'yes', - :is_confirmed => true, - :city => view_context.location(view_context.lookup_ip_location), - :arrival => @this_conference.start_date, - :departure => @this_conference.end_date, - :housing => nil, - :bike => nil, - :other => '' - ); - @languages = current_user.languages - - if @languages.blank? && @registration.languages.present? - @languages = (@registration.languages.is_a?(String) ? JSON.parse(@registration.languages) : @registration.languages).map &:to_sym - end - - @languages ||= [I18n.locale.to_sym] + @registration.housing_data ||= { } when :workshops @page_title = 'articles.conference_registration.headings.Workshops' @workshops = Workshop.where(conference_id: @this_conference.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 774f346..c037c96 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1211,7 +1211,7 @@ module ApplicationHelper if options[:heading].present? label_id ||= unique_id("#{name.to_s}-label") - html += content_tag(:h3, _(options[:heading], :t), id: label_id) + html += content_tag(:h3, _(options[:heading], :t, vars: options[:vars] || {}), id: label_id) end help = nil diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index ae4d5c9..1458e95 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -65,7 +65,7 @@ class UserMailer < ActionMailer::Base @subject = (_'email.subject.workshop_request_approved', "You have been added as a facilitator of #{@workshop.title}", :vars => {:workshop_title => @workshop.title}) - mail to: user.named_email, subject: @subject + mail to: @user.named_email, subject: @subject end def workshop_facilitator_request_denied(workshop, user) @@ -75,7 +75,7 @@ class UserMailer < ActionMailer::Base @subject = (_'email.subject.workshop_request_denied', "Your request to facilitate #{@workshop.title} has been denied", :vars => {:workshop_title => @workshop.title}) - mail to: user.named_email, subject: @subject + mail to: @user.named_email, subject: @subject end def workshop_translated(workshop, data, locale, user, translator) @@ -98,7 +98,7 @@ class UserMailer < ActionMailer::Base @wrapper_id = :full_width - mail to: user.named_email, subject: @subject + mail to: @user.named_email, subject: @subject end def workshop_original_content_changed(workshop, data, user, translator) @@ -119,21 +119,21 @@ class UserMailer < ActionMailer::Base @wrapper_id = :full_width - mail to: user.named_email, subject: @subject + mail to: @user.named_email, subject: @subject end def workshop_comment(workshop, comment, user) @workshop = Workshop.find(workshop) if workshop.present? - @comment = comment + @comment = Comment.find(comment) if comment.present? @user = User.find(user) if user.present? - if comment.reply? - @subject = (_'email.subject.workshop_comment.reply', vars: { user_name: comment.user.name }) + if @comment.reply? + @subject = (_'email.subject.workshop_comment.reply', vars: { user_name: @comment.user.name }) else - @subject = (_'email.subject.workshop_comment.comment', vars: { user_name: comment.user.name, workshop_title: workshop.title }) + @subject = (_'email.subject.workshop_comment.comment', vars: { user_name: @comment.user.name, workshop_title: @workshop.title }) end - mail to: user.named_email, subject: @subject + mail to: @user.named_email, subject: @subject end def error_report(subject, message, report, exception, request, params, user) @@ -152,7 +152,7 @@ class UserMailer < ActionMailer::Base @subject = subject @from = from.is_a?(Integer) ? User.find(from) : from - mail to: email_list.join(', '), subject: @subject, reply_to: from.is_a?(User) ? from.named_email : from + mail to: email_list.join(', '), subject: @subject, reply_to: @from.is_a?(User) ? @from.named_email : @from end def contact_details(from, subject, message, request, params) diff --git a/app/views/application/home.html.haml b/app/views/application/home.html.haml index 86dad4f..54c5191 100644 --- a/app/views/application/home.html.haml +++ b/app/views/application/home.html.haml @@ -12,14 +12,14 @@ = render 'schedule/programme', :schedule => @schedule, :conference => @conference, :workshops => @workshops, :events => @events, :locations => @locations, :show_interest => true, :day_parts => @day_parts, :show_previews => true - if @conference.registration_status == :open %h3=_'articles.workshops.headings.Proposed_Workshops' - %p=_'articles.workshops.paragraphs.Proposed_Workshops', "Would you like to facilitate your own workshop? Simply register and visit the workshops page. If you have already registered you can access the page by restarting the registration process." + %p=_'articles.workshops.paragraphs.Proposed_Workshops' %ul.workshop-list - - @conference.workshops.sort_by{ |w| w.title.downcase }.each do |w| + - (@conference.workshops || []).sort_by{ |w| w.title.downcase }.each do |w| %li %h4=w.title .workshop-interest - if w.interested?(current_user) - =_'articles.workshops.info.you_are_interested_count', "You and #{w.interested_count - 1} others are interested in this workshop", :vars => {:count => (w.interested_count - 1)} + =_'articles.workshops.info.you_are_interested_count', :vars => {:count => (w.interested_count - 1)} - elsif w.interested_count > 0 - =_'articles.workshops.info.interested_count', "#{w.interested_count} people are interested in this workshop", :vars => {:count => w.interested_count} + =_'articles.workshops.info.interested_count', :vars => {:count => w.interested_count} .workshop-description=markdown w.info diff --git a/app/views/conferences/_questions.html.haml b/app/views/conferences/_questions.html.haml index e98ec2d..8820617 100644 --- a/app/views/conferences/_questions.html.haml +++ b/app/views/conferences/_questions.html.haml @@ -5,12 +5,12 @@ = form_tag register_path(@this_conference.slug), class: [:centered, :clearfix] do = columns(medium: 12) do = radiobuttons :housing, ConferenceRegistration.all_housing_options, @registration.housing, 'articles.conference_registration.questions.housing', heading: 'articles.conference_registration.headings.housing', vertical: true, big: true, inline: true - = fieldset :hosting_dates, heading: 'articles.conference_registration.headings.arrival_and_departure' do + = fieldset :hosting_dates, heading: 'articles.conference_registration.headings.arrival_and_departure', vars: { city: @this_conference.location.city } do = selectfield :arrival, @registration.arrival || @this_conference.start_date, conference_days_options_list(:before) = selectfield :departure, @registration.departure || @this_conference.start_date, conference_days_options_list(:after) = radiobuttons :bike, ConferenceRegistration.all_bike_options, @registration.bike, 'articles.conference_registration.questions.bike', heading: 'articles.conference_registration.headings.bike', inline: true, big: true = radiobuttons :food, ConferenceRegistration.all_food_options, @registration.food, 'articles.conference_registration.questions.food', heading: 'articles.conference_registration.headings.food', inline: true, big: true - = columns(medium: 12) do + = emailfield :companion, (@registration.housing_data[:companions] || [nil]).first, heading: 'articles.conference_registration.headings.companion', help: 'articles.conference_registration.paragraphs.companion', big: true = textfield :allergies, @registration.allergies, heading: 'articles.conference_registration.headings.allergies' = textarea :other, @registration.other, plain: true, heading: 'articles.conference_registration.headings.other' = button_tag :register, :value => :questions diff --git a/config/locales/en.yml b/config/locales/en.yml index 2300002..2e0e056 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -168,6 +168,7 @@ en: one: 1 error prohibited this %{model} from being saved other: "%{count} errors prohibited this %{model} from being saved" warnings: + location_corrected: housing: space: overbooked: Overbooked @@ -5354,13 +5355,13 @@ en: administration: Administration Policy_Agreement: Safer Space Agreement policy: Policy - arrival_and_departure: For what days will you need housing? (If you don't - need housing, just tell us how long you plan to hang out with Bike!Bike!) + arrival_and_departure: How long do you plan to stay in %{city}? other: Is there anything else you'd like to tell us? email_confirm: Confirm Email Enter_Your_Email: Enter your email address Registration_Info: Registration Info Your_Registration: Your Registration + Your_Conferences: Your Conferences Youre_Done: You're Done! allergies: Do you have any allergies? arrival: Arrival @@ -5405,6 +5406,7 @@ en: admin: edit: info: 'Conference Info' + companion: Companion paragraphs: Policy_Agreement: Ensuring that all attendees feel welcome, safe, and respected at all times is especially important to us all. Please ensure that you have fully read and understand our safer spaces policy below, if you have any questions or concerns you can reach out to the organizers at any time. Confirm_Agreement: By clicking the "I Agree" button, you are pledging to do @@ -5442,7 +5444,7 @@ en: Pressing 'test' will send the email only to you, make sure you do this and use caution in general before pressing 'send' payment_confirm: You are about to confirm your payment of %{amount} for registration. - participants_emailed: Your email has been sent to all participants of %%{conference_title}. + participants_emailed: Your email has been sent to all participants of %{conference_title}. workshops: You can now take a look at proposed workshops and even propose one yourself if you like. Contact_Info: Please let us know a little bit about you. @@ -5462,6 +5464,8 @@ en: admin: edit: info: This is the copy that is displayed on the front page of the site. + companion: Is there someone who you would like us to ensure that you are housed with? + arrival_and_departure: If you don't need housing, just tell us how long you plan to hang out with Bike!Bike! host: considerations: vegan: Vegan or vegetarian only @@ -5667,6 +5671,7 @@ en: open: Open pre: Pre-Registration registration_status: Registration Status + companion: Email address actions: generic: login: Sign In diff --git a/config/locales/es.yml b/config/locales/es.yml index 20dc62b..ef30842 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -707,7 +707,7 @@ es: conference_registration: headings: Registration_Info: Registro - arrival_and_departure: ¿Que día llegas a Guadalajara? + arrival_and_departure: ¿Que día llegas a %{city}? allergies: ¿Eres alergico a algo? languages: ¿Hablas? food: ¿Que comes? @@ -1049,13 +1049,13 @@ es: translate: content: translate_now: Translar ahora - can_you_help: ¿Se puede traducir del %%{language_a} al %%{language_b}? + can_you_help: ¿Se puede traducir del %{language_a} al %{language_b}? outdated_translation: El contenido que ha sido superado translation_out_of_date: Contenido traducido en esta página puede no ser exacta un_translated: Contenido sin traducir not_translation: No es una traducción translation_last_modified: El texto en el idioma original fue modificada por - última vez el %%{date} + última vez el %{date} change_locale: "Leer en %{language}" pages: contexts: @@ -1087,7 +1087,7 @@ es: pluraliztion_same_as_other: Igual que el otro Enabled_Locales: Idiomas habilitados History: Historia - Locale_Translation: Traducción en %%{language} + Locale_Translation: Traducción en %{language} Other_Locales: Otros idiomas Save: Ahorre explain_zero_fallback: Esta traducción se utilice la versión plural para el @@ -1096,10 +1096,10 @@ es: use_default_value: Utilice el valor predeterminado variables: Variables site: - go_to_locale: Ver el sitio %%{language} ahora - locale_is_available: '%%{site_name} está disponible en %%{language}' - locale_needs_help: ¿Puedes ayudar a traducir el sitio al %%{language}? - locale_not_available: Lo sentimos, %%{site_name} no está disponible en %%{language}. + go_to_locale: Ver el sitio %{language} ahora + locale_is_available: '%{site_name} está disponible en %{language}' + locale_needs_help: ¿Puedes ayudar a traducir el sitio al %{language}? + locale_not_available: Lo sentimos, %{site_name} no está disponible en %{language}. volunteer: become_a_volunteer: Conviértete en un traductor voluntario volunteer: ¿Puedes ayudar a traducir esto? @@ -1123,7 +1123,7 @@ es: confirma tu dirección de e-mail por favor. subject: confirm_email: E-mail de confirmación - registration_confirmed: ¡Gracias por registrarte para %%{conference_title}! + registration_confirmed: ¡Gracias por registrarte para %{conference_title}! workshop_facilitator_request: Solicitud para facilitar %{workshop_title} por parte de %{requester_name} workshop_request_approved: Has sido agregadx como facilitador(a) a %{workshop_title}