mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
fixed ruby style
This commit is contained in:
parent
4be597ba9d
commit
0f622d1aec
@ -1,27 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Will generate an excel file containing all the users.
|
||||
# This file will be asynchronously generated by sidekiq and a notification will be sent to the requesting user when it's done.
|
||||
class UsersExportWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(export_id)
|
||||
export = Export.find(export_id)
|
||||
|
||||
unless export.user.admin?
|
||||
raise SecurityError, 'Not allowed to export'
|
||||
end
|
||||
|
||||
unless export.category == 'users'
|
||||
raise KeyError, 'Wrong worker called'
|
||||
end
|
||||
raise SecurityError, 'Not allowed to export' unless export.user.admin?
|
||||
raise KeyError, 'Wrong worker called' unless export.category == 'users'
|
||||
|
||||
service = UsersExportService.new
|
||||
method_name = "export_#{export.export_type}"
|
||||
|
||||
if %w(members subscriptions reservations).include?(export.export_type) and service.respond_to?(method_name)
|
||||
service.public_send(method_name, export)
|
||||
return unless %w[members subscriptions reservations].include?(export.export_type) && service.respond_to?(method_name)
|
||||
|
||||
NotificationCenter.call type: :notify_admin_export_complete,
|
||||
receiver: export.user,
|
||||
attached_object: export
|
||||
end
|
||||
service.public_send(method_name, export)
|
||||
|
||||
NotificationCenter.call type: :notify_admin_export_complete,
|
||||
receiver: export.user,
|
||||
attached_object: export
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user