1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

[feature] newsletter : ask conscent + export in xlsx

This commit is contained in:
Sylvain 2016-07-28 12:20:51 +02:00
parent 5cacb1d34a
commit 5f96c9916d
13 changed files with 44 additions and 9 deletions

View File

@ -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 = []

View File

@ -277,6 +277,20 @@
<input type="hidden" name="user[is_allow_contact]" value="{{user.is_allow_contact}}"/>
</div>
<!-- allow receive newsletter -->
<div class="form-group">
<label for="allowNewsletter" translate>{{ 'i_accept_to_receive_informations_from_the_fablab' }}</label>
<input bs-switch
ng-model="user.is_allow_newsletter"
id="allowNewsletter"
type="checkbox"
class="form-control"
switch-on-text="{{ 'yes' | translate }}"
switch-off-text="{{ 'no' | translate }}"
switch-animate="true" />
<input type="hidden" name="user[is_allow_newsletter]" value="{{user.is_allow_newsletter}}"/>
</div>
<div id="social" ng-init="social={}">
<div class="form-group" ng-show="social.facebook || user.profile.facebook" ng-class="{'has-error': userForm['user[profile_attributes][facebook]'].$dirty && userForm['user[profile_attributes][facebook]'].$invalid}">
<div class="input-group">

View File

@ -168,6 +168,16 @@
</div>
</div>
<div class="form-group" ng-class="{'has-error': signupForm.is_allow_newsletter.$dirty && signupForm.is_allow_newsletter.$invalid}">
<div class="col-sm-12">
<input type="checkbox"
name="is_allow_newsletter"
ng-model="user.is_allow_newsletter"
value="true"/>
<span translate>{{ 'i_accept_to_receive_informations_from_the_fablab' }}</span>
</div>
</div>
<div class="form-group" ng-class="{'has-error': signupForm.cgu.$dirty && signupForm.cgu.$invalid}" ng-show="cgu">
<div class="col-sm-12">
<input type="checkbox"

View File

@ -255,13 +255,13 @@ class API::MembersController < API::ApiController
def user_params
if current_user.id == params[:id].to_i
params.require(:user).permit(:username, :email, :password, :password_confirmation, :group_id, :is_allow_contact,
params.require(:user).permit(:username, :email, :password, :password_confirmation, :group_id, :is_allow_contact, :is_allow_newsletter,
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,
:user_avatar_attributes => [: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,

View File

@ -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

View File

@ -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?

View File

@ -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,

View File

@ -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"

View File

@ -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"

View File

@ -121,6 +121,7 @@ en:
surname: "Surname"
first_name: "First name"
email: "E-mail"
newsletter: "Newsletter"
gender: "Gender"
age: "Age"
address: "Address"

View File

@ -121,6 +121,7 @@ fr:
surname: "Nom"
first_name: "Prénom"
email: "Courriel"
newsletter: "Lettre d'informations"
gender: "Genre"
age: "Âge"
address: "Adresse"

View File

@ -0,0 +1,5 @@
class AddIsAllowNewsletterToUsers < ActiveRecord::Migration
def change
add_column :users, :is_allow_newsletter, :boolean
end
end

View File

@ -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