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
|
||||
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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -14,12 +14,16 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
|
||||
<%= f.hidden_field :use_redeemable_code %>
|
||||
<%= f.hidden_field :locale, value: I18n.locale %>
|
||||
|
||||
<%= f.label :username %>
|
||||
<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.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 %>
|
||||
<span class="checkbox">
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<%= link_to(t("welcome.verification.i_have_an_account"), verification_path, class: "button success radius expand") %>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <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.
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user