1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

[bug] export members list to excel is broken

This commit is contained in:
Sylvain 2019-07-10 11:27:45 +02:00
parent b77fde2506
commit 38d3ddd48a
3 changed files with 10 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Changelog Fab Manager
- Fix a bug: unable to export members list
- Fix a bug: projects RSS feed fails to render
- Fix a bug: abuses reports are not notified to admins
- Fix a bug: SubscriptionExpireWorker cannot run due to wrong expiration column in SQL query

View File

@ -50,8 +50,9 @@ class UsersExportService
# export members
def export_members(export)
@members = User.with_role(:member)
.includes(:group, :trainings, :tags, :invoices, :projects,
subscriptions: [:plan], profile: [:address, organization: [:address]])
.includes(:group, :tags, :projects, :profile,
invoicing_profile: [:invoices, :address, organization: [:address]],
statistic_profile: [:trainings, subscriptions: [:plan]])
ActionController::Base.prepend_view_path './app/views/'
# place data in view_assigns

View File

@ -38,6 +38,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
# data rows
@members.each do |member|
expiration = member&.subscription&.expired_at
data = [
member.id,
member.profile.last_name,
@ -45,7 +46,7 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.email,
member.is_allow_newsletter,
member.statistic_profile.gender ? t('export_members.man') : t('export_members.woman'),
member.profile.age,
member.statistic_profile.age,
member.invoicing_profile&.address&.address || '',
member.profile.phone,
member.profile.website,
@ -53,8 +54,8 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.profile.interest,
member.profile.software_mastered,
member.group&.name,
member.subscription && member.subscription.expired_at > Time.now ? member.subscription.plan.name : t('export_members.without_subscriptions'),
member.subscription && member.subscription.expired_at > Time.now ? member.subscription.expired_at.to_date : nil,
expiration && Time.now < expiration ? member.subscription.plan.name : t('export_members.without_subscriptions'),
expiration && Time.now < expiration ? member.subscription.expired_at.to_date : nil,
member.trainings.map(&:name).join("\n"),
member.tags.map(&:name).join("\n"),
member.invoices.size,
@ -62,14 +63,14 @@ wb.add_worksheet(name: t('export_members.members')) do |sheet|
member.profile.facebook || '',
member.profile.twitter || '',
member.profile.echosciences || '',
member.invoicing_profile&.organization.name || '',
member.invoicing_profile&.organization&.name || '',
member.invoicing_profile&.organization&.address&.address || ''
]
styles = [nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
nil, nil, nil, date, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil]
types = %i[integer string string string boolean string integer string string string string string
string string string date string string integer boolean string string string string string string]
string string string date string string integer string string string string string string string]
sheet.add_row data, style: styles, types: types
end