mr_common 1.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -9
- data/app/controllers/mr_common/dashboard_controller.rb +1 -0
- data/app/controllers/mr_common/pre_registrations/import_controller.rb +26 -0
- data/app/controllers/mr_common/pre_registrations/pre_registrations_controller.rb +48 -0
- data/app/controllers/mr_common/registrations/confirmations_controller.rb +54 -0
- data/app/controllers/mr_common/registrations/export_controller.rb +35 -4
- data/app/controllers/mr_common/registrations/public_controller.rb +24 -1
- data/app/controllers/mr_common/registrations/registrations_controller.rb +2 -0
- data/app/controllers/mr_common/registrations/resend_notifications_controller.rb +27 -0
- data/app/controllers/mr_common/registrations/success_controller.rb +1 -0
- data/app/mailers/mr_common/registration_mailer.rb +13 -3
- data/app/models/concerns/mr_common/csv_exportable.rb +6 -2
- data/app/models/mr_common/country.rb +9 -0
- data/app/models/mr_common/csv_renderer.rb +38 -0
- data/app/models/mr_common/pattern.rb +10 -0
- data/app/models/mr_common/pre_registration.rb +52 -0
- data/app/models/mr_common/pre_registration_importer.rb +91 -0
- data/app/models/mr_common/registration.rb +11 -2
- data/app/models/mr_common/registration_decorator.rb +20 -0
- data/app/models/mr_common/reminder.rb +6 -0
- data/app/models/mr_common/timezone.rb +5 -0
- data/app/views/layouts/mr_common/_navigation.html.erb +7 -0
- data/app/views/mr_common/pre_registrations/import/new.html.erb +27 -0
- data/app/views/mr_common/pre_registrations/pre_registrations/_form.html.erb +29 -0
- data/app/views/mr_common/pre_registrations/pre_registrations/index.html.erb +32 -0
- data/{lib/generators/mr_common/views/templates/mr_common/registrations/public → app/views/mr_common/pre_registrations/pre_registrations}/new.html.erb +2 -1
- data/{lib/generators/mr_common/views/templates/mr_common/registration_mailer/confirmation.html.erb → app/views/mr_common/registration_mailer/confirmed_registration.html.erb} +3 -0
- data/app/views/mr_common/registration_mailer/{confirmation.text.erb → confirmed_registration.text.erb} +2 -0
- data/app/views/mr_common/registration_mailer/revoked_registration.html.erb +5 -0
- data/app/views/mr_common/registration_mailer/revoked_registration.text.erb +6 -0
- data/app/views/mr_common/registration_mailer/unconfirmed_registration.html.erb +3 -0
- data/app/views/mr_common/registration_mailer/unconfirmed_registration.text.erb +4 -0
- data/app/views/mr_common/registrations/registrations/_form.html.erb +6 -0
- data/app/views/mr_common/registrations/registrations/index.html.erb +4 -0
- data/app/views/mr_common/registrations/registrations/show.html.erb +34 -3
- data/config/routes.rb +13 -1
- data/db/migrate/20190522151523_create_pre_registrations.rb +12 -0
- data/db/migrate/20190530220614_add_confirmed_to_registrations.rb +5 -0
- data/lib/generators/mr_common/controllers/USAGE +9 -0
- data/lib/generators/mr_common/controllers/controllers_generator.rb +24 -0
- data/lib/generators/mr_common/mailers/USAGE +16 -0
- data/lib/generators/mr_common/mailers/mailers_generator.rb +31 -0
- data/lib/generators/mr_common/models/USAGE +8 -0
- data/lib/generators/mr_common/models/models_generator.rb +23 -0
- data/lib/generators/mr_common/views/USAGE +1 -4
- data/lib/generators/mr_common/views/views_generator.rb +7 -8
- data/lib/mr_common.rb +14 -2
- data/lib/mr_common/version.rb +1 -1
- data/spec/dummy/config/initializers/mr_common.rb +10 -0
- data/spec/dummy/db/schema.rb +14 -4
- data/spec/dummy/log/development.log +1969 -50958
- data/spec/dummy/log/test.log +647 -14437
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-G/-gyHBJNssgJVEwk7sD1F9nK_dT1D1R5NjlAvcESJxME.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3d/3DI5adLgOKj6Q76fFxrLy_hKYkrlht0MEWksNkYgoXk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3n/3NK03OBfUwDPKVYV6_11AOo3IGNUQPed4dqB-Ddv6-Q.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7d/7DbSMErmkAd0cL6q_WyLMfx7gLYQB0h9smKZ0xGjOjY.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9m/9MK1AG2zx0HVFVRULpQQnQQY0HiNroKnYEz2FUBzw6k.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/CO/cojbSP1f9tYoCyycggqXgW3OYb3atOkOpf-h-Axn36o.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/H6/h6GO-mL-rzWHmoiFw-uuwdny5zj_zSb1Xzun5jkza5k.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LG/LG2fyButWQgZoNvH4qD2dBMQhl35dSysUbxsvw_2PA0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LZ/lZ_yNthdvXeWexZW9TZuMWs6lZBLMEF5rp7aA5Bl9uU.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lh/LhBzrZLgp6fzHcgWFt_B-TqHzHaPyKv9Uk67brUycZE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/N-/N-7bXt4Ck0q2VWzHHuRPKL0a0CH_1W_eyAU59tZraxE.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Pi/PI3-Xhs-TBYEqgGeCf3hWGn6vj1qCdqBqgYRY2jNr4Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QQ/qqtvJX4CrLCTv4jjIg0LwoNxJUyDpLus0RIbg6D6muk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Se/setx2SgK-JX4zwjgbekiVnvWJnbp0-2XnO0TQJfCOHU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Ue/UecY7KKAHkP6oiqpx1zkXAL9WWGqWdhgqhixQyJ82is.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VF/VfH7y0fTeHy8aLBK_bu5OKprS0c1-GCHUzrMzp-O0_I.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WC/WCV-7lpbJsFHZueodYuN5542p56UPNtby1LVPUjvuJU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WV/wvfl97Gci1mpw00EFHWc0Q9x0DLBar03PTd9BrZ7MF0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eP/ePjuIgA1bwfnJWATz7q6EjGfNnpvYEaKW_2aozCJFBQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ge/GegLYwRNBYKvfYR1-WWnx3ssHerCO6M94VPxwUTYHtM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/h9/H95rpLdUakuAt6lpkUhlZvxsYlSb-VrfpiznZYmWnGo.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p_/P_kWJKPROj6qDVkyzNQgx8wZmba8YaTqtWMQyGHFtuY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/w3/w34qFl6hbbodwCEAr9Px_jzso7svjewL5BaOf6QMIN4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wi/wi_OyVKzMxj9CcM3e2Bhab5PQSg4wh0nD-7QJQ3SVPw.cache +1 -0
- data/spec/dummy/tmp/pids/server.pid +1 -1
- data/spec/factories/registrations.rb +5 -5
- data/spec/models/registration_spec.rb +40 -0
- metadata +80 -11
- data/app/helpers/mr_common/form_helper.rb +0 -11
- data/app/models/mr_common/csv_exporter.rb +0 -35
- data/app/models/mr_common/default_csv_export_adapter.rb +0 -23
- data/app/views/mr_common/registration_mailer/confirmation.html.erb +0 -4
- data/lib/generators/mr_common/views/templates/mr_common/registration_mailer/confirmation.text.erb +0 -6
- data/lib/generators/mr_common/views/templates/mr_common/registrations/success/index.html.erb +0 -2
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module MrCommon
|
4
|
-
class CSVExporter
|
5
|
-
attr_reader :exportable
|
6
|
-
attr_reader :adapter
|
7
|
-
attr_reader :format_rules
|
8
|
-
|
9
|
-
def initialize(exportable, adapter: nil, format_rules: nil)
|
10
|
-
@exportable = exportable
|
11
|
-
@adapter = adapter ? adapter.new(exportable) : DefaultCSVExportAdapter.new(exportable)
|
12
|
-
@format_rules = format_rules || {}
|
13
|
-
end
|
14
|
-
|
15
|
-
def generate_csv
|
16
|
-
CSV.generate do |csv|
|
17
|
-
csv << adapter.headers
|
18
|
-
|
19
|
-
adapter.collection.each do |item|
|
20
|
-
row = adapter.row_from_item(item)
|
21
|
-
csv << format_row(row)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def format_row(row)
|
27
|
-
format_rules.each do |column_name, proc|
|
28
|
-
idx = adapter.headers.index(column_name.to_s)
|
29
|
-
row[idx] = proc.call(row[idx])
|
30
|
-
end
|
31
|
-
|
32
|
-
row
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module MrCommon
|
4
|
-
class DefaultCSVExportAdapter
|
5
|
-
attr_reader :exportable
|
6
|
-
|
7
|
-
def initialize(exportable)
|
8
|
-
@exportable = exportable
|
9
|
-
end
|
10
|
-
|
11
|
-
def collection
|
12
|
-
exportable.all
|
13
|
-
end
|
14
|
-
|
15
|
-
def row_from_item(item)
|
16
|
-
item.attributes.values_at(*headers)
|
17
|
-
end
|
18
|
-
|
19
|
-
def headers
|
20
|
-
exportable.column_names
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|