Translations, design and content

This commit is contained in:
2017-03-31 14:42:37 +02:00
parent cfc1fbfd9f
commit c3bfeed620
28 changed files with 296 additions and 25 deletions
+7 -2
View File
@@ -13,8 +13,7 @@ gem 'coffee-rails', '~> 4.1.0'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
@@ -32,6 +31,12 @@ gem 'roadie-rails', '~> 1.0'
# Devise is a flexible authentication solution for Rails based on Warden.
gem 'devise'
# Translations for devise
gem 'devise-i18n'
# Simulate data
gem 'faker'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
+5 -4
View File
@@ -76,6 +76,7 @@ GEM
railties (>= 4.1.0, < 5.1)
responders
warden (~> 1.2.3)
devise-i18n (1.1.2)
diff-lcs (1.3)
dotenv (2.2.0)
dotenv-rails (2.2.0)
@@ -84,6 +85,8 @@ GEM
erubis (2.7.0)
excon (0.55.0)
execjs (2.7.0)
faker (1.7.2)
i18n (~> 0.5)
font-awesome-rails (4.7.0.1)
railties (>= 3.2, < 5.1)
gem_config (0.3.1)
@@ -272,9 +275,6 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.0)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.1.10)
@@ -298,7 +298,9 @@ DEPENDENCIES
capybara
coffee-rails (~> 4.1.0)
devise
devise-i18n
dotenv-rails
faker
geocoder
jbuilder (~> 2.0)
jquery-rails
@@ -321,7 +323,6 @@ DEPENDENCIES
simple_form
slim
slim-rails
turbolinks
uglifier (>= 1.3.0)
web-console (~> 2.0)
-1
View File
@@ -12,7 +12,6 @@
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require typeahead.bundle
//= require markerclusterer_compiled
+7 -1
View File
@@ -29,10 +29,16 @@ $font-size-h3: floor($font-size-base * 1.2)
@import "bootstrap"
@import "typeaheadjs"
.alert-alert
@extend .alert-danger
.alert-notice
@extend .alert-info
body
> .container
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)
padding-top: 20px
padding: 20px
header
h1
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_action :set_locale
before_action :configure_permitted_parameters, if: :devise_controller?
INPUT_TIMEOUT = 2.seconds # We estimate that a user needs more then x seconds to enter some informations
@@ -27,4 +28,10 @@ class ApplicationController < ActionController::Base
def default_url_options(options = {})
options.merge locale: I18n.locale
end
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :street, :city, :zip, :support, :language, :age_category, :unsubscribed])
end
end
+2 -3
View File
@@ -6,8 +6,8 @@ class Supporter
:recoverable, :rememberable, :trackable, :validatable
## Database authenticatable
field :email, type: String, default: ""
field :encrypted_password, type: String, default: ""
field :email, type: String, default: ''
field :encrypted_password, type: String, default: ''
## Recoverable
field :reset_password_token, type: String
@@ -47,7 +47,6 @@ class Supporter
field :street, type: String
field :zip, type: Integer
field :city, type: String
field :email, type: String
field :support, type: String # Indicates the type of support
field :li_membership, type: Boolean, default: false
field :age_category, type: String
+3 -3
View File
@@ -4,8 +4,8 @@ html lang="#{I18n.locale}"
- flash.each do |type, message|
= message
| #CH420 - #{content_for(:title)}
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag 'application', 'data-turbolinks-track' => true
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
link href="/apple-icon-57x57.png" rel="apple-touch-icon" sizes="57x57" /
link href="/apple-icon-60x60.png" rel="apple-touch-icon" sizes="60x60" /
@@ -37,7 +37,7 @@ html lang="#{I18n.locale}"
/ = console if Rails.env.development?
.container
= render 'shared/flashes'
= render 'shared/header'
= render 'shared/topnavigation'
= render 'shared/flashes'
= yield
+2 -1
View File
@@ -4,4 +4,5 @@
= navbar_group id: 'topnav' do
= navbar_item "Home", "/#{I18n.locale}"
= navbar_item t('.donation'), spenden_path
= navbar_item t('.sign_in'), new_supporter_session_path if current_supporter.blank?
= navbar_item t('.sign_in'), new_supporter_session_path unless supporter_signed_in?
= navbar_item t('.sign_out'), destroy_supporter_session_path, nil, 'data-method' => :delete if supporter_signed_in?
@@ -0,0 +1,10 @@
h2
= t(".resend_confirmation_instructions")
= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
= f.full_error :confirmation_token
.form-inputs
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, t(".resend_confirmation_instructions")
= render "supporters/shared/links"
@@ -0,0 +1,7 @@
- require 'devise/version'
p
= t('.greeting', recipient: @resource.email)
p
= t('.instruction')
p
= link_to t('.action'), confirmation_url(@resource, confirmation_token: (Devise::VERSION.start_with?('3.') ? @token : @resource.confirmation_token))
@@ -0,0 +1,14 @@
p
| Hello
= @email
| !
- if @resource.try(:unconfirmed_email?)
p
| We're contacting you to notify you that your email is being changed to
= @resource.unconfirmed_email
| .
- else
p
| We're contacting you to notify you that your email has been changed to
= @resource.email
| .
@@ -0,0 +1,5 @@
- require 'devise/version'
p
= t('.greeting', recipient: @resource.email)
p
= t('.message')
@@ -0,0 +1,11 @@
- require 'devise/version'
p
= t('devise.mailer.reset_password_instructions.greeting', recipient: "#{@resource.first_name} #{@resource.last_name}")
p
= t('devise.mailer.reset_password_instructions.instruction')
p
= link_to t('devise.mailer.reset_password_instructions..action'), edit_password_url(@resource, reset_password_token: (Devise::VERSION.start_with?('3.', '4.') ? @token : @resource.reset_password_token), locale: I18n.locale)
p
= t('devise.mailer.reset_password_instructions.instruction_2')
p
= t('devise.mailer.reset_password_instructions.instruction_3')
@@ -0,0 +1,9 @@
- require 'devise/version'
p
= t('.greeting', recipient: @resource.email)
p
= t('.message')
p
= t('.instruction')
p
= link_to t('.action'), unlock_url(@resource, unlock_token: (Devise::VERSION.start_with?('3.') ? @token :@resource.unlock_token))
+37 -1
View File
@@ -1,2 +1,38 @@
= render 'form'
- if supporter_signed_in?
h1.sr-only = title t('.title', name: current_supporter.first_name)
.row
.col-xs-12.col-md-7
.panel.panel-default
.panel-heading
h2.panel-title = t '.my_data'
.panel-body
dl.dl-horizontal
dt = Supporter.human_attribute_name(:email)
dd = current_supporter.email
dt = Supporter.human_attribute_name(:first_name)
dd = current_supporter.first_name
dt = Supporter.human_attribute_name(:last_name)
dd = current_supporter.last_name
dt = Supporter.human_attribute_name(:street)
dd = current_supporter.street
dt = Supporter.human_attribute_name(:city)
dd = "#{current_supporter.zip} #{current_supporter.city}"
dt = Supporter.human_attribute_name(:support)
dd == t("support_type.#{current_supporter.support}")
dt = Supporter.human_attribute_name(:age_category)
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(:unsubscribed)
dd = current_supporter.unsubscribed? ? t('shared.yes') : t('shared.no')
p
= link_to t('.edit'), edit_supporter_registration_path(), class: 'pull-right'
aside.col-md-5.col-xs-12
= render 'right_side'
- else
= render 'form'
@@ -0,0 +1,11 @@
h2
= t("devise.passwords.edit.change_your_password")
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
= f.input :reset_password_token, as: :hidden
= f.full_error :reset_password_token
.form-inputs
= f.input :password, label: t("devise.passwords.edit.new_password"), required: true, autofocus: true
= f.input :password_confirmation, label: t("devise.passwords.edit.confirm_new_password"), required: true
.form-actions
= f.button :submit, t("devise.passwords.edit.change_my_password")
= render "supporters/shared/links"
@@ -0,0 +1,8 @@
h1= title t("devise.passwords.new.forgot_your_password")
= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, t("devise.passwords.new.send_me_reset_password_instructions")
= render "supporters/shared/links"
@@ -0,0 +1,28 @@
.panel.panel-default
.panel-heading
h1.panel-title = title t("devise.registrations.edit.title", resource: resource_class.model_name.human)
.panel-body
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
.form-inputs
= f.input :current_password, hint: t("devise.registrations.edit.we_need_your_current_password_to_confirm_your_changes"), required: true
= f.input :email, required: true, autofocus: true
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
p
= t(".currently_waiting_confirmation_for_email", email: resource.unconfirmed_email)
= f.input :password, autocomplete: "off", hint: t("devise.registrations.edit.leave_blank_if_you_don_t_want_to_change_it"), required: false
= f.input :password_confirmation, required: false
= f.input :first_name
= f.input :last_name
= f.input :street
= f.input :city
= f.input :zip
= 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 :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first
= f.input :language, as: :radio_buttons, collection: t('languages').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first
= f.input :unsubscribed, as: :boolean
.form-actions
= f.button :submit, t("devise.registrations.edit.update"), class: 'btn btn-primary'
p = link_to t("devise.shared.links.back"), :back
hr
p = link_to t("devise.registrations.edit.cancel_my_account"), registration_path(resource_name), data: { confirm: t("devise.registrations.edit.are_you_sure") }, method: :delete, class: 'btn btn-danger btn-sm pull-right'
@@ -0,0 +1,11 @@
h2
= t(".sign_up")
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true
= f.input :password, required: true
= f.input :password_confirmation, required: true
.form-actions
= f.button :submit, t(".sign_up")
= render "supporters/shared/links"
@@ -0,0 +1,9 @@
h1= title t(".sign_in")
= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.form-inputs
= f.input :email, required: false, autofocus: true
= f.input :password, required: false
= f.input :remember_me, as: :boolean if devise_mapping.rememberable?
.form-actions
= f.button :submit, t("devise.sessions.new.sign_in")
= render "supporters/shared/links"
@@ -0,0 +1,20 @@
- if controller_name != 'sessions'
= link_to t("devise.shared.links.sign_in"), new_session_path(resource_name)
br
- if devise_mapping.registerable? && controller_name != 'registrations'
/= link_to t("devise.shared.links.sign_up"), new_registration_path(resource_name)
= link_to t("devise.shared.links.sign_up"), new_supporter_path
br
- if devise_mapping.recoverable? && controller_name != 'passwords'
= link_to t("devise.shared.links.forgot_your_password"), new_password_path(resource_name)
br
- if devise_mapping.confirmable? && controller_name != 'confirmations'
= link_to t('devise.shared.links.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name)
br
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
= link_to t('devise.shared.links.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name)
br
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
= link_to t('devise.shared.links.sign_in_with_provider', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider)
br
@@ -0,0 +1,10 @@
h2
= t(".resend_unlock_instructions")
= simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f|
= f.error_notification
= f.full_error :unlock_token
.form-inputs
= f.input :email, required: true, autofocus: true
.form-actions
= f.button :submit, t(".resend_unlock_instructions")
= render "supporters/shared/links"
+2
View File
@@ -39,4 +39,6 @@ Rails.application.configure do
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
config.action_mailer.default_url_options = { host: 'localhost:3000' }
config.action_mailer.asset_host = 'http://localhost:3000'
end
+2 -2
View File
@@ -157,7 +157,7 @@ Devise.setup do |config|
# ==> Configuration for :validatable
# Range for password length.
config.password_length = 6..128
config.password_length = 4..128
# Email regex used to validate email formats. It simply asserts that
# one (and only one) @ exists in the given string. This is mainly
@@ -223,7 +223,7 @@ Devise.setup do |config|
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views.
# config.scoped_views = false
config.scoped_views = true
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
+22 -1
View File
@@ -1,11 +1,14 @@
de:
shared:
"yes": Ja
"no": Nein
header:
logo: Logo der Initiative
title_html: Ja, ich will <strong class="text-success">Cannabis</strong> in der Schweiz <strong class="text-success">legalisieren</strong>
topnavigation:
donation: Spenden
sign_in: Anmelden
sign_out: Abmelden
counter:
supporters: "Unterstützer:"
amount_of_supporters: Zurzeit haben wir %{amount} Unterstützer.
@@ -27,6 +30,11 @@ de:
middle: Ich bin 30 bis 64 Jahre alt
retired: Ich bin über 64 Jahre alt
languages:
de: Deutsch
fr: Français
it: Italiano
supporters:
form:
form: Formular
@@ -46,12 +54,19 @@ de:
create:
timeout: Ihre Eingabe war zu schnell.
new:
title: Hallo %{name}
edit: Meine Daten bearbeiten...
my_data: Meine Daten
pages:
thanks:
title: Besten Dank für deine Unterstützung!
mongoid:
attributes:
models:
supporter: Konto
attributes:
supporter:
first_name: Vorname
last_name: Nachname
@@ -63,3 +78,9 @@ de:
age_category: Alterskategorie
li_membership: Ich bin interessiert an einer Mitgliedschaft beim Verein Legalize it! (50 Franken pro Jahr)
comments: Kommentar / Feedback (optional)
remember_me: Angemeldet bleiben
password: Passwort
language: Sprache
unsubscribed: Kein Newsletter
password_confirmation: Passwort bestätigen
current_password: Aktuelles Passwort
+23 -1
View File
@@ -2,6 +2,8 @@ fr:
input_error: Vos entrées ne peuvent pas être enregistrées. Vérifiez les entrées.
shared:
"yes": Oui
"no": Non
counter:
supporters: "Militant:"
amount_of_supporters: Nous avons actuellement %{amount} supporters.
@@ -10,6 +12,8 @@ fr:
title_html: Oui, je veux <strong class="text-success">légaliser le cannabis</strong> en Suisse.
topnavigation:
donation: Donation
sign_out: déconnecter
sign_in: Connexion
welcome_email:
subject: Merci beaucoup pour ton soutien!
@@ -26,6 +30,11 @@ fr:
middle: Jai entre 30 et 64 ans
retired: Jai plus que 64 ans
languages:
de: Deutsch
fr: Français
it: Italiano
supporters:
form:
form: Formulaire
@@ -43,12 +52,19 @@ fr:
create:
timeout: Ihre Eingabe war zu schnell.
new:
title: Salut %{name}
edit: Modifier mes données ...
my_data: Mes données
pages:
thanks:
title: Merci beaucoup pour ton soutien!
mongoid:
attributes:
models:
supporter: compte
attributes:
supporter:
first_name: Prénom
last_name: Nom
@@ -60,3 +76,9 @@ fr:
age_category: Catégorie d’âge
li_membership: Je suis intéressé à joindre l'association Legalize It! (50 francs par an).
comments: Commentaires / Feedback (facultatif)
remember_me: Se souvenir de moi
password: mot de passe
language: Langue
unsubscribed: pas de newslettre
password_confirmation: confirmer le mot de passe
current_password: Mot de passe actuel
+20
View File
@@ -2,11 +2,15 @@ it:
input_error: I dati immessi non potevano essere salvati. Verificare i dati immessi.
shared:
"yes": Si
"No": No
header:
logo: Logo dell'iniziativa
title_html: Si, voglio <strong class="text-success">legalizzare</strong> la <strong class="text-success">cannabis in Svizzera</strong>
topnavigation:
donation: Donazione
sign_out: Disconnettersi
sign_in: Registro
counter:
supporters: "Sostenitore:"
amount_of_supporters: Al momento abbiamo %{amount} sostenitori.
@@ -27,6 +31,11 @@ it:
middle: Ho tra i 30 ed i 64 anni
retired: Ho più di 64 anni
languages:
de: Deutsch
fr: Français
it: Italiano
supporters:
form:
form: Modulo
@@ -45,6 +54,11 @@ it:
create:
timeout: Ihre Eingabe war zu schnell.
new:
title: Ciao %{name}
edit: Modifica i miei dati ...
my_data: Miei dati
pages:
thanks:
title: Grazie mille per il tuo sostegno!
@@ -62,3 +76,9 @@ it:
age_category: Categoria Età
li_membership: Sono interessato a diventare membro attivo di Verein Legalize It (50 franchi annuali di tassa).
comments: Commenti / Feedback (opzionale)
remember_me: Ricordati di mel
password: Password
language: Lingua
unsubscribed: No Newsletter
password_confirmation: conferma password
current_password: Password corrente
+1 -2
View File
@@ -1,6 +1,6 @@
Rails.application.routes.draw do
devise_for :supporters
root to: redirect("/#{I18n.default_locale}")
root to: 'supporters#new'
namespace :admin do
get '/map', to: 'pages#map', as: :map
@@ -12,7 +12,6 @@ Rails.application.routes.draw do
scope '/:locale' do
get '/', to: 'supporters#new'
resources :supporters
get '/thanks', to: 'pages#thanks', as: :thanks
get '/spenden', to: 'pages#spenden', as: :spenden
get '/terms_and_conditions', to: 'pages#terms_and_conditions', as: :terms_and_conditions