diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index 8a4aca2a8..88e20bb79 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -1,6 +1,12 @@
class Users::RegistrationsController < Devise::RegistrationsController
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
+ def new
+ super do |user|
+ user.use_redeemable_code = true if params[:use_redeemable_code].present?
+ end
+ end
+
def create
build_resource(sign_up_params)
if resource.valid_with_captcha?
@@ -52,7 +58,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
def sign_up_params
params.require(:user).permit(:username, :email, :password,
:password_confirmation, :captcha,
- :captcha_key, :terms_of_service, :locale)
+ :captcha_key, :terms_of_service, :locale,
+ :redeemable_code)
end
def erase_params
diff --git a/app/models/user.rb b/app/models/user.rb
index cf96a69cf..fa049ed11 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -41,6 +41,7 @@ class User < ActiveRecord::Base
accepts_nested_attributes_for :organization, update_only: true
attr_accessor :skip_password_validation
+ attr_accessor :use_redeemable_code
scope :administrators, -> { joins(:administrators) }
scope :moderators, -> { joins(:moderator) }
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb
index 61ac4031b..e5ba6560b 100644
--- a/app/views/users/registrations/new.html.erb
+++ b/app/views/users/registrations/new.html.erb
@@ -14,12 +14,16 @@
+ <%= f.hidden_field :use_redeemable_code %>
+ <%= f.hidden_field :locale, value: I18n.locale %>
+
<%= f.label :username %>
<%= t("devise_views.users.registrations.new.username_note") %>
<%= f.text_field :username, maxlength: User.username_max_length, placeholder: t("devise_views.users.registrations.new.username_label"), label: false %>
<%= f.email_field :email, placeholder: t("devise_views.users.registrations.new.email_label") %>
+
<%= f.password_field :password, autocomplete: "off",
placeholder: t("devise_views.users.registrations.new.password_label") %>
@@ -27,11 +31,12 @@
label: t("devise_views.users.registrations.new.password_confirmation_label"),
placeholder: t("devise_views.users.registrations.new.password_confirmation_label") %>
- <%= f.hidden_field :locale, value: I18n.locale %>
+ <% if resource.use_redeemable_code %>
+ <%= f.text_field :redeemable_code, placeholder: t("devise_views.users.registrations.new.redeemable_code") %>
+ <% end %>
<%= f.simple_captcha input_html: {required: false} %>
-
<%= f.label :terms_of_service do %>
<%= f.check_box :terms_of_service, label: false %>
diff --git a/app/views/welcome/verification.html.erb b/app/views/welcome/verification.html.erb
index 88c69aa77..49fccea9c 100644
--- a/app/views/welcome/verification.html.erb
+++ b/app/views/welcome/verification.html.erb
@@ -8,7 +8,7 @@
<%= link_to(t("welcome.verification.i_have_an_account"), verification_path, class: "button success radius expand") %>
- <%= link_to(t("welcome.verification.i_dont_have_an_account"), new_user_registration_path, class: "button radius expand") %>
+ <%= link_to(t("welcome.verification.i_dont_have_an_account"), new_user_registration_path(use_redeemable_code: true), class: "button radius expand") %>
diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml
index 42c29fed8..9451a2875 100644
--- a/config/locales/activerecord.en.yml
+++ b/config/locales/activerecord.en.yml
@@ -58,10 +58,12 @@ en:
user:
email: "Email"
username: "Username"
+ password_confirmation: "Password confirmation"
password: "Password"
phone_number: "Phone number"
official_position: "Official position"
official_level: "Official level"
+ redeemable_code: "Verification code received via email"
organization:
name: "Name of organisation"
responsible_name: "Person responsible for the group"
diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml
index 780595562..c18288bdc 100644
--- a/config/locales/activerecord.es.yml
+++ b/config/locales/activerecord.es.yml
@@ -58,10 +58,12 @@ es:
user:
email: "Correo electrónico"
username: "Nombre de usuario"
+ password_confirmation: "Confirmación de contraseña"
password: "Contraseña"
phone_number: "Teléfono"
official_position: "Cargo público"
official_level: "Nivel del cargo"
+ redeemable_code: "Código de verificación por carta (opcional)"
organization:
name: "Nombre de organización"
responsible_name: "Persona responsable del colectivo"
diff --git a/config/locales/devise_views.en.yml b/config/locales/devise_views.en.yml
index 8253a7ccc..7272da0a5 100755
--- a/config/locales/devise_views.en.yml
+++ b/config/locales/devise_views.en.yml
@@ -113,6 +113,7 @@ en:
organization_signup_link: Sign up here
password_confirmation_label: Confirm password
password_label: Password
+ redeemable_code: Verification code received via email (optional)
submit: Register
terms: By registering you accept the %{terms}
terms_link: terms and conditions of use
diff --git a/config/locales/devise_views.es.yml b/config/locales/devise_views.es.yml
index b203040c6..abed497cd 100644
--- a/config/locales/devise_views.es.yml
+++ b/config/locales/devise_views.es.yml
@@ -108,11 +108,12 @@ es:
waiting_for: 'Esperando confirmación de:'
new:
cancel: Cancelar login
- email_label: Email
+ email_label: Tu correo electrónico
organization_signup: "¿Representas a una organización / colectivo? %{signup_link}"
organization_signup_link: Regístrate aquí
- password_confirmation_label: Confirmar contraseña
- password_label: Contraseña
+ password_confirmation_label: Repite la contraseña anterior
+ password_label: Contraseña que utilizarás para acceder a este sitio web
+ redeemable_code: Tu código de verificación (si has recibido una carta con él)
submit: Registrarse
terms: Al registrarte aceptas las %{terms}
terms_link: condiciones de uso
@@ -120,7 +121,7 @@ es:
username_is_available: "Nombre de usuario disponible"
username_is_not_available: "Nombre de usuario ya existente"
username_label: Nombre de usuario
- username_note: Nombre que aparecerá en tus publicacionesß
+ username_note: Nombre público que aparecerá en tus publicaciones
success:
back_to_index: Entendido, volver a la página principal
instructions_1_html: Por favor revisa tu correo electrónico - te hemos enviado un enlace para confirmar tu cuenta.
diff --git a/db/migrate/20160222145100_add_redeemable_code_to_user.rb b/db/migrate/20160222145100_add_redeemable_code_to_user.rb
new file mode 100644
index 000000000..38cba9357
--- /dev/null
+++ b/db/migrate/20160222145100_add_redeemable_code_to_user.rb
@@ -0,0 +1,5 @@
+class AddRedeemableCodeToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :redeemable_code, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index dd3633461..2c948febc 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: 20160220181602) do
+ActiveRecord::Schema.define(version: 20160222145100) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -409,6 +409,7 @@ ActiveRecord::Schema.define(version: 20160220181602) do
t.boolean "registering_with_oauth", default: false
t.string "oauth_email"
t.integer "geozone_id"
+ t.string "redeemable_code"
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree