-
<%= t("devise_views.sessions.new.title") %>
+
+
+
+
<%= t("devise_views.sessions.new.title") %>
- <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
-
-
- <%= f.label :email, t("devise_views.sessions.new.email_label") %>
- <%= f.email_field :email, autofocus: true, placeholder: t("devise_views.sessions.new.email_label") %>
-
-
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
+
+
+ <%= f.label :email, t("devise_views.sessions.new.email_label") %>
+ <%= f.email_field :email, autofocus: true, placeholder: t("devise_views.sessions.new.email_label") %>
+
-
-
- <%= f.label :password, t("devise_views.sessions.new.password_label") %>
- <%= f.password_field :password, autocomplete: "off", placeholder: t("devise_views.sessions.new.password_label") %>
-
-
+
+ <%= f.label :password, t("devise_views.sessions.new.password_label") %>
+ <%= f.password_field :password, autocomplete: "off", placeholder: t("devise_views.sessions.new.password_label") %>
+
- <% if devise_mapping.rememberable? -%>
-
-
- <%= f.check_box :remember_me %>
- <%= f.label :remember_me, t("devise_views.sessions.new.remember_me") %>
-
-
- <% end -%>
-
-
-
- <%= f.submit(t("devise_views.sessions.new.submit"), class: "button radius expand") %>
-
-
- <% end %>
-
- <%= render "devise/shared/links" %>
+ <% if devise_mapping.rememberable? -%>
+
+ <%= f.check_box :remember_me %>
+ <%= f.label :remember_me, t("devise_views.sessions.new.remember_me") %>
+ <% end -%>
+
+
+ <%= f.submit(t("devise_views.sessions.new.submit"), class: "button radius expand") %>
+
+ <% end %>
+
+ <%= render "devise/shared/links" %>
+
\ No newline at end of file
diff --git a/app/views/layouts/devise.html.erb b/app/views/layouts/devise.html.erb
new file mode 100644
index 000000000..fe73e5553
--- /dev/null
+++ b/app/views/layouts/devise.html.erb
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
<%= content_for?(:title) ? yield(:title) : "Participación" %>
+ <%= stylesheet_link_tag "application" %>
+ <%= javascript_include_tag "vendor/modernizr" %>
+ <%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
+ <%= csrf_meta_tags %>
+
+
+
+
+
+ <% if notice %>
+
<%= notice %>
+ <% end %>
+
+ <% if alert %>
+
<%= alert %>
+ <% end %>
+
+
+
+
+ <%= link_to root_path do %>
+ <%= image_tag('logo_madrid_white.png', class: 'left', size: '96x96') %>
+ <%= t("layouts.header.open_gov", open: "#{t('layouts.header.open')}").html_safe %> | <%= t("layouts.header.participation") %>
+ <% end %>
+
+
+
+
+ <%= yield %>
+
+
+
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index 4055e45b6..cc325bc6c 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -20,6 +20,11 @@ module Participacion
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :es
+ config.i18n.available_locales = [:en, :es]
+
+ # Add the new directories to the locales load path
+ config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
+
config.assets.paths << Rails.root.join("app", "assets", "fonts")
# Do not swallow errors in after_commit/after_rollback callbacks.
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml
new file mode 100644
index 000000000..f9b28d6a2
--- /dev/null
+++ b/config/i18n-tasks.yml
@@ -0,0 +1,106 @@
+# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
+
+# The "main" locale.
+base_locale: en
+## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
+# locales: [es, fr]
+## Reporting locale, default: en. Available: en, ru.
+# internal_locale: en
+
+# Read and write translations.
+data:
+ ## Translations are read from the file system. Supported format: YAML, JSON.
+ ## Provide a custom adapter:
+ # adapter: I18n::Tasks::Data::FileSystem
+
+ # Locale files or `File.find` patterns where translations are read from:
+ read:
+ ## Default:
+ # - config/locales/%{locale}.yml
+ ## More files:
+ # - config/locales/**/*.%{locale}.yml
+ ## Another gem (replace %#= with %=):
+ # - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"
+ - config/locales/%{locale}.yml
+ - config/locales/devise_views.%{locale}.yml
+ - config/locales/responders.%{locale}.yml
+
+ # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
+ write:
+ ## For example, write devise and simple form keys to their respective files:
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
+ ## Catch-all default:
+ # - config/locales/%{locale}.yml
+
+ ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
+ # router: convervative_router
+
+ yaml:
+ write:
+ # do not wrap lines at 80 characters
+ line_width: -1
+
+ ## Pretty-print JSON:
+ # json:
+ # write:
+ # indent: ' '
+ # space: ' '
+ # object_nl: "\n"
+ # array_nl: "\n"
+
+# Find translate calls
+search:
+ ## Paths or `File.find` patterns to search in:
+ # paths:
+ # - app/
+
+ ## Root directories for relative keys resolution.
+ # relative_roots:
+ # - app/controllers
+ # - app/helpers
+ # - app/mailers
+ # - app/presenters
+ # - app/views
+
+ ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
+ ## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
+ exclude:
+ - app/assets/images
+ - app/assets/fonts
+
+ ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
+ ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
+ # include: ["*.rb", "*.html.slim"]
+
+ ## Default scanner finds t() and I18n.t() calls.
+ # scanner: I18n::Tasks::Scanners::PatternWithScopeScanner
+
+## Google Translate
+# translation:
+# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
+# api_key: "AbC-dEf5"
+
+## Do not consider these keys missing:
+# ignore_missing:
+# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
+# - '{devise,simple_form}.*'
+
+## Consider these keys used:
+# ignore_unused:
+# - 'activerecord.attributes.*'
+# - '{devise,kaminari,will_paginate}.*'
+# - 'simple_form.{yes,no}'
+# - 'simple_form.{placeholders,hints,labels}.*'
+# - 'simple_form.{error_notification,required}.:'
+
+## Exclude these keys from the `i18n-tasks eq-base' report:
+# ignore_eq_base:
+# all:
+# - common.ok
+# fr,es:
+# - common.brand
+
+## Ignore these keys completely:
+# ignore:
+# - kaminari.*
diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb
deleted file mode 100644
index 9aa77cd8b..000000000
--- a/config/initializers/i18n.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-I18n.available_locales = [:en, :es]
-
-I18n.default_locale = :es
-
-# Add the new directories to the locales load path
-I18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml
index d07d487ad..7675a204e 100644
--- a/config/locales/devise_views.en.yml
+++ b/config/locales/devise_views.en.yml
@@ -56,6 +56,8 @@ en:
title: "Sign up"
first_name_label: "First name"
last_name_label: "Last name"
+ nickname_label: "Nickname"
+ use_nickname_label: "Use nickname"
email_label: "Email"
password_label: "Password"
min_length: "(%{min} characters minimum)"
diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml
index 1fa6fe880..63e3159e0 100644
--- a/config/locales/devise_views.es.yml
+++ b/config/locales/devise_views.es.yml
@@ -55,7 +55,9 @@ es:
new:
title: "Registrarse"
first_name_label: "Nombre"
- last_name_label: "Apellido"
+ last_name_label: "Apellidos"
+ nickname_label: "Pseudónimo"
+ use_nickname_label: "Usar pseudónimo"
email_label: "Email"
password_label: "Contraseña"
min_length: "(mínimo %{min} caracteres)"
@@ -80,4 +82,4 @@ es:
signin_with_provider: "Entrar con %{provider}"
new_password: "¿Olvidaste tu contraseña?"
new_confirmation: "¿No has recibido instrucciones para confirmar tu cuenta?"
- new_unlock: "¿No has recibido instrucciones para desbloquear?"
\ No newline at end of file
+ new_unlock: "¿No has recibido instrucciones para desbloquear?"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 2a8562a6e..7fdf7a214 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -20,9 +20,6 @@ en:
votes: votes
comment: Comment
comments: Comments
- agree: I agree
- disagree: I disagree
- leave_comment: Comment
form:
error: error
errors: errors
@@ -48,7 +45,7 @@ en:
new:
publish_new: Publish new debate
back_link: Back
- recommendations_tite: Tips for creating a debate
+ recommendations_title: Tips for creating a debate
recommendation_one: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore"
recommendation_two: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore"
recommendation_three: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore"
@@ -61,12 +58,18 @@ en:
agree: I agree
disagree: I disagree
supports: Supports
- notice_thanks: "Thanks for voting."
- notice_already_registered: "Your vote is already registered."
account:
show:
title: "My account"
save_changes_submit: "Save changes"
+ change_credentials_link: "Change my credentials"
+ first_name_label: "First Name"
+ last_name_label: "Last Name"
+ use_nickname_label: "Use nickname"
+ nickname_label: "Nickname"
+ recaptcha:
+ errors:
+ verification_failed: "The captcha verification failed"
shared:
tags_cloud:
tags: Tags
diff --git a/config/locales/es.yml b/config/locales/es.yml
index d5869b284..9bbdde6b6 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -20,9 +20,6 @@ es:
votes: votos
comment: Comentario
comments: Comentarios
- agree: Estoy de acuerdo
- disagree: No estoy de acuerdo
- leave_comment: Comentar
form:
error: error
errors: errores
@@ -61,12 +58,19 @@ es:
agree: Estoy de acuerdo
disagree: No estoy de acuerdo
supports: Apoyos
- notice_thanks: "Gracias por votar."
- notice_already_registered: "Tu voto ya ha sido registrado."
account:
show:
title: "Mi cuenta"
save_changes_submit: "Guardar cambios"
+ change_credentials_link: "Cambiar mi contraseña"
+ first_name_label: "Nombre"
+ last_name_label: "Apellidos"
+ use_nickname_label: "Usar pseudónimo"
+ nickname_label: "Pseudónimo"
+ recaptcha:
+ errors:
+ verification_failed: "La verificación por captcha falló"
shared:
tags_cloud:
tags: Etiquetas
+
diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml
index cd0d93fe8..41c13a326 100644
--- a/config/locales/responders.en.yml
+++ b/config/locales/responders.en.yml
@@ -4,12 +4,12 @@ en:
create:
notice: '%{resource_name} was successfully created.'
# alert: '%{resource_name} could not be created.'
- update:
- notice: '%{resource_name} was successfully updated.'
+ # update:
+ # notice: '%{resource_name} was successfully updated.'
# alert: '%{resource_name} could not be updated.'
- destroy:
- notice: '%{resource_name} was successfully destroyed.'
- alert: '%{resource_name} could not be destroyed.'
+ # destroy:
+ # notice: '%{resource_name} was successfully destroyed.'
+ # alert: '%{resource_name} could not be destroyed.'
save_changes:
notice: "Saved"
diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml
index ad8012f9e..e11fbccbc 100644
--- a/config/locales/responders.es.yml
+++ b/config/locales/responders.es.yml
@@ -3,10 +3,10 @@ es:
actions:
create:
notice: "%{resource_name} creado correctamente."
- update:
- notice: "%{resource_name} actualizado correctamente."
- destroy:
- notice: "%{resource_name} borrado correctamente."
- alert: "%{resource_name} no ha podido ser borrado."
+ # update:
+ # notice: "%{resource_name} actualizado correctamente."
+ # destroy:
+ # notice: "%{resource_name} borrado correctamente."
+ # alert: "%{resource_name} no ha podido ser borrado."
save_changes:
notice: "Cambios guardados"
diff --git a/db/migrate/20150806135245_add_nickname_to_user.rb b/db/migrate/20150806135245_add_nickname_to_user.rb
new file mode 100644
index 000000000..06bf046f9
--- /dev/null
+++ b/db/migrate/20150806135245_add_nickname_to_user.rb
@@ -0,0 +1,5 @@
+class AddNicknameToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :nickname, :string
+ end
+end
diff --git a/db/migrate/20150806140048_add_use_nickname_to_users.rb b/db/migrate/20150806140048_add_use_nickname_to_users.rb
new file mode 100644
index 000000000..032a791cd
--- /dev/null
+++ b/db/migrate/20150806140048_add_use_nickname_to_users.rb
@@ -0,0 +1,5 @@
+class AddUseNicknameToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :use_nickname, :boolean, null: false, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index f75de4884..e5f6f9c0a 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150806111435) do
+ActiveRecord::Schema.define(version: 20150806140048) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -62,24 +62,26 @@ ActiveRecord::Schema.define(version: 20150806111435) do
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
create_table "users", force: :cascade do |t|
- t.string "email", default: "", null: false
- t.string "encrypted_password", default: "", null: false
+ t.string "email", default: "", null: false
+ t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
- t.integer "sign_in_count", default: 0, null: false
+ t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.string "first_name"
t.string "last_name"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
+ t.string "nickname"
+ t.boolean "use_nickname", default: false, null: false
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb
new file mode 100644
index 000000000..5237b7240
--- /dev/null
+++ b/spec/i18n_spec.rb
@@ -0,0 +1,17 @@
+require 'i18n/tasks'
+
+RSpec.describe 'I18n' do
+ let(:i18n) { I18n::Tasks::BaseTask.new }
+ let(:missing_keys) { i18n.missing_keys }
+ let(:unused_keys) { i18n.unused_keys }
+
+ it 'does not have missing keys' do
+ expect(missing_keys).to be_empty,
+ "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them"
+ end
+
+ it 'does not have unused keys' do
+ expect(unused_keys).to be_empty,
+ "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them"
+ end
+end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 77b6755dc..0a7665127 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -2,11 +2,11 @@ require 'rails_helper'
describe User do
- before(:each) do
- @user = create(:user)
- end
-
describe "#votes_on_debates" do
+ before(:each) do
+ @user = create(:user)
+ end
+
it "should return {} if no debate" do
expect(@user.votes_on_debates()).to eq({})
expect(@user.votes_on_debates([])).to eq({})
@@ -27,4 +27,50 @@ describe User do
expect(voted[debate3.id]).to eq(false)
end
end
+
+ subject { build(:user) }
+
+ it "is valid" do
+ expect(subject).to be_valid
+ end
+
+ describe 'use_nickname' do
+ describe 'when true' do
+ before { subject.use_nickname = true }
+
+ it "activates the validation of nickname" do
+ subject.nickname = nil
+ expect(subject).to_not be_valid
+
+ subject.nickname = "dredd"
+ expect(subject).to be_valid
+ end
+
+ it "calculates the name using the nickname" do
+ subject.nickname = "dredd"
+ expect(subject.name).to eq("dredd")
+ end
+ end
+
+ describe 'when false' do
+ before { subject.use_nickname = false }
+
+ it "activates the validation of first_name and last_name" do
+ subject.first_name = nil
+ subject.last_name = nil
+ expect(subject).to_not be_valid
+
+ subject.first_name = "Joseph"
+ subject.last_name = "Dredd"
+ expect(subject).to be_valid
+ end
+
+ it "calculates the name using first_name and last_name" do
+ subject.first_name = "Joseph"
+ subject.last_name = "Dredd"
+ expect(subject.name).to eq("Joseph Dredd")
+ end
+ end
+ end
+
end