[:id, :attachment, :_destroy], :address_attributes => [:id, :address]])
elsif current_user.is_admin?
- params.require(:user).permit(:username, :email, :password, :password_confirmation, :invoicing_disabled, :is_allow_contact,
+ params.require(:user).permit(:username, :email, :password, :password_confirmation, :invoicing_disabled, :is_allow_contact, :is_allow_newsletter,
:group_id, training_ids: [], tag_ids: [],
profile_attributes: [:id, :first_name, :last_name, :gender, :birthday, :phone, :interest, :software_mastered, :website, :job,
:facebook, :twitter, :google_plus, :viadeo, :linkedin, :instagram, :youtube, :vimeo, :dailymotion, :github, :echosciences, :pinterest, :lastfm, :flickr,
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 8ca0b4026..9c2c1e961 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -30,7 +30,7 @@ class ApplicationController < ActionController::Base
devise_parameter_sanitizer.for(:sign_up) <<
{profile_attributes: [:phone, :last_name, :first_name,
:gender, :birthday, :interest, :software_mastered]}
- devise_parameter_sanitizer.for(:sign_up).concat [:username, :is_allow_contact, :cgu, :group_id]
+ devise_parameter_sanitizer.for(:sign_up).concat [:username, :is_allow_contact, :is_allow_newsletter, :cgu, :group_id]
end
def default_url_options
diff --git a/app/views/api/members/show.json.jbuilder b/app/views/api/members/show.json.jbuilder
index 2bb02f670..d22731fb6 100644
--- a/app/views/api/members/show.json.jbuilder
+++ b/app/views/api/members/show.json.jbuilder
@@ -1,6 +1,6 @@
requested_current = (current_user and current_user.id == @member.id)
-json.extract! @member, :id, :uid, :username, :email, :group_id, :slug, :invoicing_disabled, :is_allow_contact
+json.extract! @member, :id, :uid, :username, :email, :group_id, :slug, :invoicing_disabled, :is_allow_contact, :is_allow_newsletter
json.role @member.roles.first.name
json.name @member.profile.full_name
json.need_completion @member.need_completion?
diff --git a/app/views/exports/users_members.xlsx.axlsx b/app/views/exports/users_members.xlsx.axlsx
index 6d3fe0060..6e9068c38 100644
--- a/app/views/exports/users_members.xlsx.axlsx
+++ b/app/views/exports/users_members.xlsx.axlsx
@@ -8,7 +8,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
## data table
# heading labels
columns = [t('export_members.id'), t('export_members.surname'), t('export_members.first_name'), t('export_members.email'),
- t('export_members.gender'), t('export_members.age'), t('export_members.address'), t('export_members.phone'),
+ t('export_members.newsletter'), t('export_members.gender'), t('export_members.age'), t('export_members.address'), t('export_members.phone'),
t('export_members.website'), t('export_members.job'), t('export_members.interests'),
t('export_members.cad_software_mastered'), t('export_members.group'), t('export_members.subscription'),
t('export_members.subscription_end_date'), t('export_members.validated_trainings'), t('export_members.tags'),
@@ -20,7 +20,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
@members.each do |member|
data = [
member.id, member.profile.last_name, member.profile.first_name,
- member.email, member.profile.gender ? t('export_members.man') : t('export_members.woman'), member.profile.age,
+ member.email, member.is_allow_newsletter, member.profile.gender ? t('export_members.man') : t('export_members.woman'), member.profile.age,
member.profile.address ? member.profile.address.address : '', member.profile.phone, member.profile.website,
member.profile.job, member.profile.interest, member.profile.software_mastered, member.group.name,
(member.subscription and member.subscription.expired_at > Time.now) ? member.subscription.plan.name : t('export_members.without_subscriptions'),
@@ -30,7 +30,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.profile.echosciences || ''
]
styles = [nil, nil, nil,
- nil, nil, nil,
+ nil, nil, nil, nil,
nil, nil, nil,
nil, nil, nil, nil,
nil,
@@ -39,7 +39,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
nil, nil, nil,
nil]
types = [:integer, :string, :string,
- :string, :string, :integer,
+ :string, :boolean, :string, :integer,
:string, :string, :string,
:string, :string, :string, :string,
:string,
diff --git a/config/locales/app.public.en.yml b/config/locales/app.public.en.yml
index c4af3384a..8b59043c6 100644
--- a/config/locales/app.public.en.yml
+++ b/config/locales/app.public.en.yml
@@ -75,6 +75,7 @@ en:
phone_number: "Phone number"
phone_number_is_required: "Phone number is required."
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "I authorize FabLab users, registered on the site, to contact me"
+ i_accept_to_receive_informations_from_the_fablab: "I accept to receive informations from the FabLab"
i_ve_read_and_i_accept_: "I've read and I accept"
_the_fablab_policy: "the FabLab policy"
diff --git a/config/locales/app.public.fr.yml b/config/locales/app.public.fr.yml
index b7c764b5a..c7fefb4f0 100644
--- a/config/locales/app.public.fr.yml
+++ b/config/locales/app.public.fr.yml
@@ -75,6 +75,7 @@ fr:
phone_number: "Numéro de téléphone"
phone_number_is_required: "Le numéro de téléphone est requis."
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "J'autorise les utilisateurs du Fab Lab inscrits sur le site à me contacter"
+ i_accept_to_receive_informations_from_the_fablab: "J'accepte de recevoir des informations du Fab Lab"
i_ve_read_and_i_accept_: "J'ai lu et j'accepte"
_the_fablab_policy: "la charte d'utilisation du Fab Lab"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 6e8a33473..963e9038e 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -121,6 +121,7 @@ en:
surname: "Surname"
first_name: "First name"
email: "E-mail"
+ newsletter: "Newsletter"
gender: "Gender"
age: "Age"
address: "Address"
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index 8c0f6b98f..0eea8d189 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -121,6 +121,7 @@ fr:
surname: "Nom"
first_name: "Prénom"
email: "Courriel"
+ newsletter: "Lettre d'informations"
gender: "Genre"
age: "Âge"
address: "Adresse"
diff --git a/db/migrate/20160728095026_add_is_allow_newsletter_to_users.rb b/db/migrate/20160728095026_add_is_allow_newsletter_to_users.rb
new file mode 100644
index 000000000..f36d56b0f
--- /dev/null
+++ b/db/migrate/20160728095026_add_is_allow_newsletter_to_users.rb
@@ -0,0 +1,5 @@
+class AddIsAllowNewsletterToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :is_allow_newsletter, :boolean
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 89856f731..357678e37 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: 20160726144257) do
+ActiveRecord::Schema.define(version: 20160728095026) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -684,6 +684,7 @@ ActiveRecord::Schema.define(version: 20160726144257) do
t.string "uid"
t.string "auth_token"
t.datetime "merged_at"
+ t.boolean "is_allow_newsletter"
end
add_index "users", ["auth_token"], name: "index_users_on_auth_token", using: :btree