From e9a73ea5cbcdda73b0ff9baf8ab6357b9738c07c Mon Sep 17 00:00:00 2001 From: Markus Graf Date: Fri, 10 Nov 2017 10:25:25 +0100 Subject: [PATCH] User can now add a phone number --- app/controllers/supporters_controller.rb | 2 +- app/models/supporter.rb | 1 + app/views/supporters/_form.slim | 1 + app/views/supporters/new.slim | 2 ++ config/locales/de.yml | 1 + config/locales/fr.yml | 3 ++- config/locales/it.yml | 1 + spec/features/support_spec.rb | 2 ++ 8 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/supporters_controller.rb b/app/controllers/supporters_controller.rb index 3ebdbee..2cbb11c 100644 --- a/app/controllers/supporters_controller.rb +++ b/app/controllers/supporters_controller.rb @@ -21,7 +21,7 @@ class SupportersController < ApplicationController private def supporter_form_params - params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :li_membership, :age_category, :city, :comments) + params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :li_membership, :age_category, :city, :comments, :tel) end # We use sendy for newsletters atm diff --git a/app/models/supporter.rb b/app/models/supporter.rb index 34abd97..141f4f5 100644 --- a/app/models/supporter.rb +++ b/app/models/supporter.rb @@ -45,6 +45,7 @@ class Supporter field :comments, type: String field :language, type: String field :duplicate, type: Boolean, default: false + field :tel, type: String validates :first_name, presence: true validates :last_name, presence: true diff --git a/app/views/supporters/_form.slim b/app/views/supporters/_form.slim index 5171f5b..ad4e8ad 100644 --- a/app/views/supporters/_form.slim +++ b/app/views/supporters/_form.slim @@ -9,6 +9,7 @@ = f.input :city, placeholder: t('.placeholders.city') = f.input :zip, placeholder: t('.placeholders.zip') = f.input :email, placeholder: t('.placeholders.email') + = f.input :tel, placeholder: '+41 (0) xxxx' = f.input :support, as: :radio_buttons, collection: t('support_type').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first = f.input :li_membership, as: :boolean = f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first diff --git a/app/views/supporters/new.slim b/app/views/supporters/new.slim index dbf173e..d98336f 100644 --- a/app/views/supporters/new.slim +++ b/app/views/supporters/new.slim @@ -23,6 +23,8 @@ dd == t("age_category.#{current_supporter.age_category}") dt = Supporter.human_attribute_name(:language) dd = t("languages.#{current_supporter.language}") + dt = Supporter.human_attribute_name(:tel) + dd = current_supporter.tel p = link_to t('.edit'), edit_supporter_registration_path(), class: 'pull-right' diff --git a/config/locales/de.yml b/config/locales/de.yml index f5d5ce4..e0e2884 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -138,6 +138,7 @@ de: language: Sprache password_confirmation: Passwort bestätigen current_password: Aktuelles Passwort + tel: Telefon (optional) publicity: state: Status organisation: Organisation diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6732aca..43021eb 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -135,7 +135,8 @@ fr: language: Langue password_confirmation: confirmer le mot de passe current_password: Mot de passe actuel - + tel: Téléphone (facultatif) + publicity: status: Statu organisation: Organisation diff --git a/config/locales/it.yml b/config/locales/it.yml index 63cdf1d..f7700ff 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -137,6 +137,7 @@ it: language: Lingua password_confirmation: conferma password current_password: Password corrente + tel: Telefono (opzionale) publicity: status: Statu organisation: Organizzazione diff --git a/spec/features/support_spec.rb b/spec/features/support_spec.rb index b46f952..d5867e3 100644 --- a/spec/features/support_spec.rb +++ b/spec/features/support_spec.rb @@ -10,6 +10,7 @@ feature 'Support' do fill_in 'Postleitzahl', with: '8704' fill_in 'Ort', with: 'Herrliberg' fill_in 'E-Mail', with: 'blocher@blocher.ch' + fill_in 'Telefon', with: '12345' fill_in 'Kommentar / Feedback', with: 'Test text' choose 'Ich würde eine Volksinitiative für die Legalisierung von Cannabis unterschreiben und helfe aktiv Unterschriften in meiner Umgebung zu sammeln.' @@ -30,6 +31,7 @@ feature 'Support' do expect(supporter.comments).to eq 'Test text' expect(supporter.language).to eq 'de' expect(supporter.li_membership).to eq true + expect(supporter.tel).to eq '12345' end scenario 'A bot tries to enter data' do