tramway-export 0.1.0.3 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f762c44112f573bb2586837328ce4313e5f8ba59569390214c4e4cecfd0a307
4
- data.tar.gz: 3fb3789acf11d50a91bf94d6d308c236ee528f62c588c115245b7a2f22fc86b0
3
+ metadata.gz: e9ff476d80bb0e6c0d3169ae79cc36a8310eab02aff7f59ac66a54efaa2c4497
4
+ data.tar.gz: 98a38ab02ee16f7bd30305e4adedbc4dfbe956d496ade6f0176a425b682b819b
5
5
  SHA512:
6
- metadata.gz: ec558f40e74173d2c0e72ea63f71c78f39b2c2341b8eae2cf4821c4990a61592636a5ac7fb1c1d107e717178937581c9372bae69055da32d2b562a6812d189b3
7
- data.tar.gz: 2178181b0f5933d2302bcedc3ad47619a123876d4eeaf631c61f758c965e1bca51b97bcb8e9888b7dbd2277e9f0373e3f629e86fee7b0c126b96937973a259ee
6
+ metadata.gz: 054f373a769da7f602a92ff1f9ece42e52628f083b5e969ff71df9201c9e16b2fe3f9fad8e992acb2b635394f1d10b6206232d8c8c95810fb9285d07b5c224f0
7
+ data.tar.gz: 2ac3d9481e935acf14cb13b22f57d54e20428b9ba3f5bf141869680d02c0df9dd394128dda9382c26ecbb2352c3f35281e2ac8d681389cfb8fa82ab2428d7e0a
@@ -2,26 +2,28 @@
2
2
 
3
3
  require 'xls_exporter'
4
4
 
5
- class Tramway::Export::ExportsController < Tramway::Export::ApplicationController
5
+ class Tramway::Export::ExportsController < Tramway::Admin::ApplicationController
6
6
  def show
7
7
  scope = params[:scope].present? ? params[:scope] : :all
8
8
  model_class = model_class_name(params[:model])
9
- xlsx_decorator_class = xlsx_decorator_class_name(params[:model])
10
- records = xlsx_decorator_class.decorate model_class.active.order(id: :desc).send scope
9
+ xls_decorator_class = xls_decorator_class_name(params[:model])
10
+ records = model_class.active.order(id: :desc).send scope
11
+ records = records.send "#{current_user.role}_scope", current_user.id
12
+ records = xls_decorator_class.decorate records
11
13
 
12
14
  book = ::XlsExporter.export do
13
15
  add_sheet 'List'
14
16
 
15
- export_models records, *xlsx_decorator_class.columns
17
+ export_models records, *xls_decorator_class.columns
16
18
  end
17
19
  stream = StringIO.new
18
20
  book.write stream
19
- send_data stream.string, content_type: 'application/xlsx', filename: xlsx_decorator_class.filename
21
+ send_data stream.string, content_type: 'application/xls', filename: xls_decorator_class.filename
20
22
  end
21
23
 
22
24
  private
23
25
 
24
- def xlsx_decorator_class_name(model_name)
25
- "#{model_name}XlsxDecorator".constantize
26
+ def xls_decorator_class_name(model_name)
27
+ "#{model_name}XlsDecorator".constantize
26
28
  end
27
29
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Tramway
4
4
  module Export
5
- module Xlsx
5
+ module Xls
6
6
  class ApplicationDecorator < Tramway::Export::ApplicationDecorator
7
7
  end
8
8
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Export
5
- VERSION = '0.1.0.3'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-export
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xls_exporter
@@ -37,10 +37,9 @@ files:
37
37
  - app/assets/config/tramway_export_manifest.js
38
38
  - app/assets/javascripts/tramway/export/application.js
39
39
  - app/assets/stylesheets/tramway/export/application.css
40
- - app/controllers/tramway/export/application_controller.rb
41
40
  - app/controllers/tramway/export/exports_controller.rb
42
41
  - app/decorators/tramway/export/application_decorator.rb
43
- - app/decorators/tramway/export/xlsx/application_decorator.rb
42
+ - app/decorators/tramway/export/xls/application_decorator.rb
44
43
  - app/helpers/tramway/export/application_helper.rb
45
44
  - app/jobs/tramway/export/application_job.rb
46
45
  - app/mailers/tramway/export/application_mailer.rb
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Tramway
4
- module Export
5
- class ApplicationController < Tramway::Core::ApplicationController
6
- protect_from_forgery with: :exception
7
-
8
- include Tramway::ClassNameHelpers
9
- end
10
- end
11
- end