adds a redeemable code to users. It can be filled up when signing up from /cuentasegura
This commit is contained in:
@@ -1,6 +1,12 @@
|
|||||||
class Users::RegistrationsController < Devise::RegistrationsController
|
class Users::RegistrationsController < Devise::RegistrationsController
|
||||||
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
|
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
|
def create
|
||||||
build_resource(sign_up_params)
|
build_resource(sign_up_params)
|
||||||
if resource.valid_with_captcha?
|
if resource.valid_with_captcha?
|
||||||
@@ -52,7 +58,8 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
|||||||
def sign_up_params
|
def sign_up_params
|
||||||
params.require(:user).permit(:username, :email, :password,
|
params.require(:user).permit(:username, :email, :password,
|
||||||
:password_confirmation, :captcha,
|
:password_confirmation, :captcha,
|
||||||
:captcha_key, :terms_of_service, :locale)
|
:captcha_key, :terms_of_service, :locale,
|
||||||
|
:redeemable_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
def erase_params
|
def erase_params
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class User < ActiveRecord::Base
|
|||||||
accepts_nested_attributes_for :organization, update_only: true
|
accepts_nested_attributes_for :organization, update_only: true
|
||||||
|
|
||||||
attr_accessor :skip_password_validation
|
attr_accessor :skip_password_validation
|
||||||
|
attr_accessor :use_redeemable_code
|
||||||
|
|
||||||
scope :administrators, -> { joins(:administrators) }
|
scope :administrators, -> { joins(:administrators) }
|
||||||
scope :moderators, -> { joins(:moderator) }
|
scope :moderators, -> { joins(:moderator) }
|
||||||
|
|||||||
@@ -14,12 +14,16 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
|
||||||
|
<%= f.hidden_field :use_redeemable_code %>
|
||||||
|
<%= f.hidden_field :locale, value: I18n.locale %>
|
||||||
|
|
||||||
<%= f.label :username %>
|
<%= f.label :username %>
|
||||||
<p class="note"><%= t("devise_views.users.registrations.new.username_note") %></p>
|
<p class="note"><%= t("devise_views.users.registrations.new.username_note") %></p>
|
||||||
<%= f.text_field :username, maxlength: User.username_max_length, placeholder: t("devise_views.users.registrations.new.username_label"), label: false %>
|
<%= 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.email_field :email, placeholder: t("devise_views.users.registrations.new.email_label") %>
|
||||||
|
|
||||||
|
|
||||||
<%= f.password_field :password, autocomplete: "off",
|
<%= f.password_field :password, autocomplete: "off",
|
||||||
placeholder: t("devise_views.users.registrations.new.password_label") %>
|
placeholder: t("devise_views.users.registrations.new.password_label") %>
|
||||||
|
|
||||||
@@ -27,11 +31,12 @@
|
|||||||
label: t("devise_views.users.registrations.new.password_confirmation_label"),
|
label: t("devise_views.users.registrations.new.password_confirmation_label"),
|
||||||
placeholder: 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.simple_captcha input_html: {required: false} %>
|
||||||
|
|
||||||
|
|
||||||
<%= f.label :terms_of_service do %>
|
<%= f.label :terms_of_service do %>
|
||||||
<%= f.check_box :terms_of_service, label: false %>
|
<%= f.check_box :terms_of_service, label: false %>
|
||||||
<span class="checkbox">
|
<span class="checkbox">
|
||||||
|
|||||||
@@ -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_have_an_account"), verification_path, class: "button success radius expand") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="small-12 medium-6 column">
|
<div class="small-12 medium-6 column">
|
||||||
<%= 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") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -58,10 +58,12 @@ en:
|
|||||||
user:
|
user:
|
||||||
email: "Email"
|
email: "Email"
|
||||||
username: "Username"
|
username: "Username"
|
||||||
|
password_confirmation: "Password confirmation"
|
||||||
password: "Password"
|
password: "Password"
|
||||||
phone_number: "Phone number"
|
phone_number: "Phone number"
|
||||||
official_position: "Official position"
|
official_position: "Official position"
|
||||||
official_level: "Official level"
|
official_level: "Official level"
|
||||||
|
redeemable_code: "Verification code received via email"
|
||||||
organization:
|
organization:
|
||||||
name: "Name of organisation"
|
name: "Name of organisation"
|
||||||
responsible_name: "Person responsible for the group"
|
responsible_name: "Person responsible for the group"
|
||||||
|
|||||||
@@ -58,10 +58,12 @@ es:
|
|||||||
user:
|
user:
|
||||||
email: "Correo electrónico"
|
email: "Correo electrónico"
|
||||||
username: "Nombre de usuario"
|
username: "Nombre de usuario"
|
||||||
|
password_confirmation: "Confirmación de contraseña"
|
||||||
password: "Contraseña"
|
password: "Contraseña"
|
||||||
phone_number: "Teléfono"
|
phone_number: "Teléfono"
|
||||||
official_position: "Cargo público"
|
official_position: "Cargo público"
|
||||||
official_level: "Nivel del cargo"
|
official_level: "Nivel del cargo"
|
||||||
|
redeemable_code: "Código de verificación por carta (opcional)"
|
||||||
organization:
|
organization:
|
||||||
name: "Nombre de organización"
|
name: "Nombre de organización"
|
||||||
responsible_name: "Persona responsable del colectivo"
|
responsible_name: "Persona responsable del colectivo"
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ en:
|
|||||||
organization_signup_link: Sign up here
|
organization_signup_link: Sign up here
|
||||||
password_confirmation_label: Confirm password
|
password_confirmation_label: Confirm password
|
||||||
password_label: Password
|
password_label: Password
|
||||||
|
redeemable_code: Verification code received via email (optional)
|
||||||
submit: Register
|
submit: Register
|
||||||
terms: By registering you accept the %{terms}
|
terms: By registering you accept the %{terms}
|
||||||
terms_link: terms and conditions of use
|
terms_link: terms and conditions of use
|
||||||
|
|||||||
@@ -108,11 +108,12 @@ es:
|
|||||||
waiting_for: 'Esperando confirmación de:'
|
waiting_for: 'Esperando confirmación de:'
|
||||||
new:
|
new:
|
||||||
cancel: Cancelar login
|
cancel: Cancelar login
|
||||||
email_label: Email
|
email_label: Tu correo electrónico
|
||||||
organization_signup: "¿Representas a una organización / colectivo? %{signup_link}"
|
organization_signup: "¿Representas a una organización / colectivo? %{signup_link}"
|
||||||
organization_signup_link: Regístrate aquí
|
organization_signup_link: Regístrate aquí
|
||||||
password_confirmation_label: Confirmar contraseña
|
password_confirmation_label: Repite la contraseña anterior
|
||||||
password_label: Contraseña
|
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
|
submit: Registrarse
|
||||||
terms: Al registrarte aceptas las %{terms}
|
terms: Al registrarte aceptas las %{terms}
|
||||||
terms_link: condiciones de uso
|
terms_link: condiciones de uso
|
||||||
@@ -120,7 +121,7 @@ es:
|
|||||||
username_is_available: "Nombre de usuario disponible"
|
username_is_available: "Nombre de usuario disponible"
|
||||||
username_is_not_available: "Nombre de usuario ya existente"
|
username_is_not_available: "Nombre de usuario ya existente"
|
||||||
username_label: Nombre de usuario
|
username_label: Nombre de usuario
|
||||||
username_note: Nombre que aparecerá en tus publicacionesß
|
username_note: Nombre público que aparecerá en tus publicaciones
|
||||||
success:
|
success:
|
||||||
back_to_index: Entendido, volver a la página principal
|
back_to_index: Entendido, volver a la página principal
|
||||||
instructions_1_html: Por favor <b>revisa tu correo electrónico</b> - te hemos enviado un <b>enlace para confirmar tu cuenta</b>.
|
instructions_1_html: Por favor <b>revisa tu correo electrónico</b> - te hemos enviado un <b>enlace para confirmar tu cuenta</b>.
|
||||||
|
|||||||
5
db/migrate/20160222145100_add_redeemable_code_to_user.rb
Normal file
5
db/migrate/20160222145100_add_redeemable_code_to_user.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddRedeemableCodeToUser < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :redeemable_code, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -409,6 +409,7 @@ ActiveRecord::Schema.define(version: 20160220181602) do
|
|||||||
t.boolean "registering_with_oauth", default: false
|
t.boolean "registering_with_oauth", default: false
|
||||||
t.string "oauth_email"
|
t.string "oauth_email"
|
||||||
t.integer "geozone_id"
|
t.integer "geozone_id"
|
||||||
|
t.string "redeemable_code"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
|
||||||
|
|||||||
Reference in New Issue
Block a user