From 5f96c9916d47886182b5f56144626ee4ec2e056d Mon Sep 17 00:00:00 2001 From: Sylvain Date: Thu, 28 Jul 2016 12:20:51 +0200 Subject: [PATCH] [feature] newsletter : ask conscent + export in xlsx --- .../javascripts/controllers/application.coffee.erb | 1 + app/assets/templates/shared/_member_form.html.erb | 14 ++++++++++++++ app/assets/templates/shared/signupModal.html.erb | 10 ++++++++++ app/controllers/api/members_controller.rb | 4 ++-- app/controllers/application_controller.rb | 2 +- app/views/api/members/show.json.jbuilder | 2 +- app/views/exports/users_members.xlsx.axlsx | 8 ++++---- config/locales/app.public.en.yml | 1 + config/locales/app.public.fr.yml | 1 + config/locales/en.yml | 1 + config/locales/fr.yml | 1 + ...60728095026_add_is_allow_newsletter_to_users.rb | 5 +++++ db/schema.rb | 3 ++- 13 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20160728095026_add_is_allow_newsletter_to_users.rb diff --git a/app/assets/javascripts/controllers/application.coffee.erb b/app/assets/javascripts/controllers/application.coffee.erb index d9b12e334..5a0a8716b 100644 --- a/app/assets/javascripts/controllers/application.coffee.erb +++ b/app/assets/javascripts/controllers/application.coffee.erb @@ -88,6 +88,7 @@ Application.Controllers.controller 'ApplicationController', ["$rootScope", "$sco # default user's parameters $scope.user = is_allow_contact: true + is_allow_newsletter: false # Errors display $scope.alerts = [] diff --git a/app/assets/templates/shared/_member_form.html.erb b/app/assets/templates/shared/_member_form.html.erb index 72ec5edcf..c9adb2fc0 100644 --- a/app/assets/templates/shared/_member_form.html.erb +++ b/app/assets/templates/shared/_member_form.html.erb @@ -277,6 +277,20 @@ + +
+ + + +
+
diff --git a/app/assets/templates/shared/signupModal.html.erb b/app/assets/templates/shared/signupModal.html.erb index faa60bfd4..ba98c759a 100644 --- a/app/assets/templates/shared/signupModal.html.erb +++ b/app/assets/templates/shared/signupModal.html.erb @@ -168,6 +168,16 @@
+
+
+ + {{ 'i_accept_to_receive_informations_from_the_fablab' }} +
+
+
[: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