diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 6f4f9c4..b48b700 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -23,14 +23,6 @@ Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/users/registrations_controller.rb'
-# Offense count: 4
-# Configuration parameters: Database, Include.
-# SupportedDatabases: mysql
-# Include: db/**/*.rb
-Rails/NotNullColumn:
- Exclude:
- - 'db/migrate/20240828093926_add_address_columns_to_club.rb'
-
# Offense count: 1
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb
index e26ad69..e1bd03d 100644
--- a/app/controllers/users/registrations_controller.rb
+++ b/app/controllers/users/registrations_controller.rb
@@ -13,11 +13,20 @@ class RegistrationsController < Devise::RegistrationsController
# POST /resource
def create
+ params[:user][:registering] = true
super
return turbo_stream if @user.errors.present?
- @club = Club.create!(name: 'DA IMPOSTARE', email: params[:user][:email])
+ @club = Club.create!(
+ name: @user.club_name,
+ email: @user.club_email,
+ address: @user.club_address,
+ postal_code: @user.club_postal_code,
+ municipality: @user.club_municipality,
+ province: @user.club_province,
+ tax_code: @user.club_tax_code
+ )
@user.club = @club
@user.save
end
@@ -52,7 +61,9 @@ def destroy
# If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params
- devise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name club_name])
+ devise_parameter_sanitizer.permit(:sign_up,
+ keys: %i[first_name last_name registering club_name club_email club_address
+ club_postal_code club_municipality club_province club_tax_code])
end
# If you have extra params to permit, append them to the sanitizer.
diff --git a/app/models/user.rb b/app/models/user.rb
index ff55859..2de3f84 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -21,6 +21,12 @@ class User < ApplicationRecord
scope :with_expiring_blsd,
-> { where(blsd_expires_at: Time.zone.today.beginning_of_day..6.months.from_now) }
+ attr_accessor :registering, :club_name, :club_email, :club_address, :club_postal_code,
+ :club_municipality, :club_province, :club_tax_code
+
+ validates :club_name, :club_email, :club_address, :club_postal_code, :club_municipality, :club_province,
+ :club_tax_code, presence: true, if: -> { registering == true }
+
def admin?
role == 'admin'
end
diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb
index 54978d6..2fe2959 100644
--- a/app/views/devise/registrations/new.html.erb
+++ b/app/views/devise/registrations/new.html.erb
@@ -2,23 +2,18 @@
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
- <%= f.input :email,
- required: true,
- autofocus: true,
- input_html: { autocomplete: "email" }%>
- <%= f.input :first_name,
- required: true,
- autofocus: true %>
- <%= f.input :last_name,
- required: true,
- autofocus: true %>
- <%= f.input :password,
- required: true,
- hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length),
- input_html: { autocomplete: "new-password" } %>
- <%= f.input :password_confirmation,
- required: true,
- input_html: { autocomplete: "new-password" } %>
+ <%= f.input :email,required: true, autofocus: true, input_html: { autocomplete: "email" }%>
+ <%= f.input :first_name,required: true, autofocus: true %>
+ <%= f.input :last_name,required: true, autofocus: true %>
+ <%= f.input :club_name, required: true, autofocus: true %>
+ <%= f.input :club_email, required: true, autofocus: true %>
+ <%= f.input :club_address, required: true, autofocus: true %>
+ <%= f.input :club_postal_code, required: true, autofocus: true %>
+ <%= f.input :club_municipality, required: true, autofocus: true %>
+ <%= f.input :club_province, required: true, autofocus: true %>
+ <%= f.input :club_tax_code, required: true, autofocus: true %>
+ <%= f.input :password,required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length), input_html: { autocomplete: "new-password" } %>
+ <%= f.input :password_confirmation, required: true, input_html: { autocomplete: "new-password" } %>
<%= f.button :submit, "Sign up" %>
diff --git a/config/locales/simple_form.it.yml b/config/locales/simple_form.it.yml
index 5378f2e..7d86890 100644
--- a/config/locales/simple_form.it.yml
+++ b/config/locales/simple_form.it.yml
@@ -15,6 +15,12 @@ it:
first_name: Nome
last_name: Cognome
email: Email
+ club_name: Nome Club
+ club_address: Indirizzo Club
+ club_postal_code: CAP Club
+ club_municipality: Comune Club
+ club_province: Provincia Club
+ club_tax_code: Codice Fiscale/PIva Club
member:
first_name: Nome
last_name: Cognome
diff --git a/db/migrate/20240828093926_add_address_columns_to_club.rb b/db/migrate/20240828093926_add_address_columns_to_club.rb
index e1d9247..dc88ec0 100644
--- a/db/migrate/20240828093926_add_address_columns_to_club.rb
+++ b/db/migrate/20240828093926_add_address_columns_to_club.rb
@@ -3,12 +3,12 @@
class AddAddressColumnsToClub < ActiveRecord::Migration[7.2]
def change
change_table :clubs, bulk: true do |t|
- t.string :address, null: false
- t.string :postal_code, null: false
- t.string :municipality, null: false
- t.string :province, null: false
+ t.string :address, null: false, default: 'DA IMPOSTARE'
+ t.string :postal_code, null: false, default: 'DA IMPOSTARE'
+ t.string :municipality, null: false, default: 'DA IMPOSTARE'
+ t.string :province, null: false, default: 'DA IMPOSTARE'
+ t.string :tax_code, null: false, default: 'DA IMPOSTARE'
t.string :telephone
- t.string :tax_code, null: false
end
end
end
diff --git a/db/schema.rb b/db/schema.rb
index c45b2d8..96833a6 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -47,12 +47,12 @@
t.string "email", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.string "address", null: false
- t.string "postal_code", null: false
- t.string "municipality", null: false
- t.string "province", null: false
+ t.string "address", default: "DA IMPOSTARE", null: false
+ t.string "postal_code", default: "DA IMPOSTARE", null: false
+ t.string "municipality", default: "DA IMPOSTARE", null: false
+ t.string "province", default: "DA IMPOSTARE", null: false
+ t.string "tax_code", default: "DA IMPOSTARE", null: false
t.string "telephone"
- t.string "tax_code", null: false
end
create_table "event_groups", force: :cascade do |t|