ecm_downloads2 3.0.0 → 4.0.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
  SHA1:
3
- metadata.gz: a011ee69e20f13fe57f0e51ca4cd34822c40c3b1
4
- data.tar.gz: a87b07226aec17fa1c0df0a85fcf34ef8e33c499
3
+ metadata.gz: 9984cf40411bae23b117593ec5d99859ef46e3e6
4
+ data.tar.gz: 190578856491b42f2f2fc064974ddda9ef6f13ec
5
5
  SHA512:
6
- metadata.gz: 3057fd1be45b82fefda43033c065f90a8526476cf6f0adff4469fea959e699e1d1c8589804f602c1d7f00e2d0e48e61de04b330b7319c94335fc21f93fae55b6
7
- data.tar.gz: 945db5099965448191c55258794af336a41883fe23b0b0004b4cec761ecd0bd5561bc79120254b4006a476d33f623c55eee45fc32e0ac59bd4f509358422efae
6
+ metadata.gz: ead4af186ef32494d85a6a2ec2c826148755be6a9e8d9b0398240e6492aa3ff03e22256080c0eb01105a3c0babad1eb959f5833581243e6b56a91713e027500a
7
+ data.tar.gz: 58333058281ee9c9fd269e6e6b298f38b671c4f5e4242107aaea61704fb7524d954e0372114eca5ca617181a7ee9de95d329edb4f51a847bfe3311565ee97e02
@@ -1,53 +1,53 @@
1
- class Ecm::Downloads::Download < ActiveRecord::Base
2
- # db settings
3
- self.table_name = 'ecm_downloads_downloads'
4
-
5
- # acts as list
6
- acts_as_list scope: :ecm_downloads_download_category
7
-
8
- # acts as published
9
- include ActsAsPublished::ActiveRecord
10
- acts_as_published
11
-
12
- # associations
13
- belongs_to :ecm_downloads_download_category,
14
- class_name: Ecm::Downloads::DownloadCategory,
15
- inverse_of: :ecm_downloads_downloads
16
-
17
- # attibutes
18
- attr_accessible :asset,
19
- :description,
20
- :ecm_downloads_download_category_id,
21
- :name if respond_to? :attr_accessible
22
-
23
- # callbacks
24
- before_update :fix_updated_position, if: proc { |d| !position.blank? && d.ecm_downloads_download_category_id_changed? }
25
-
26
- # friendly id
27
- extend FriendlyId
28
- friendly_id :name, use: [:slugged]
29
-
30
- # paperclip
31
- has_attached_file :asset, Ecm::Downloads::Configuration.paperclip_options
32
-
33
- # validations
34
- validates :ecm_downloads_download_category, presence: true
35
- validates :name, presence: true
36
- validates_attachment :asset, presence => true
37
- do_not_validate_attachment_file_type :asset
38
-
39
- def human
40
- name
41
- end
42
-
43
- def to_s
44
- human
45
- end
46
-
47
- private
48
-
49
- def fix_updated_position
50
- Rails.logger.debug "Fixing positions for #{self} (Moving to last)"
51
- add_to_list_bottom
1
+ module Ecm
2
+ module Downloads
3
+ class Download < ActiveRecord::Base
4
+ # acts as list
5
+ acts_as_list scope: :download_category
6
+
7
+ # acts as published
8
+ include ActsAsPublished::ActiveRecord
9
+ acts_as_published
10
+
11
+ # associations
12
+ belongs_to :download_category,
13
+ inverse_of: :downloads
14
+
15
+ # attibutes
16
+ attr_accessible :asset,
17
+ :description,
18
+ :download_category_id,
19
+ :name if respond_to? :attr_accessible
20
+
21
+ # callbacks
22
+ before_update :fix_updated_position, if: proc { |d| !position.blank? && d.category_id_changed? }
23
+
24
+ # friendly id
25
+ extend FriendlyId
26
+ friendly_id :name, use: [:slugged]
27
+
28
+ # paperclip
29
+ has_attached_file :asset, Ecm::Downloads::Configuration.paperclip_options
30
+
31
+ # validations
32
+ validates :download_category, presence: true
33
+ validates :name, presence: true
34
+ validates_attachment :asset, presence: true
35
+ do_not_validate_attachment_file_type :asset
36
+
37
+ def human
38
+ name
39
+ end
40
+
41
+ def to_s
42
+ human
43
+ end
44
+
45
+ private
46
+
47
+ def fix_updated_position
48
+ Rails.logger.debug "Fixing positions for #{self} (Moving to last)"
49
+ add_to_list_bottom
50
+ end
51
+ end
52
52
  end
53
53
  end
@@ -1,57 +1,57 @@
1
- class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
2
- # db settings
3
- self.table_name = 'ecm_downloads_download_categories'
4
-
5
- # associations
6
- has_many :ecm_downloads_downloads, -> { order(:position) },
7
- class_name: Ecm::Downloads::Download,
8
- dependent: :destroy,
9
- foreign_key: :ecm_downloads_download_category_id,
10
- inverse_of: :ecm_downloads_download_category
11
-
12
- accepts_nested_attributes_for :ecm_downloads_downloads,
13
- allow_destroy: true
14
-
15
- # attributes
16
- attr_accessible :description,
17
- :ecm_downloads_downloads_attributes,
18
- :ecm_downloads_downloads_count,
19
- :locale,
20
- :name,
21
- :parent_id,
22
- :position,
23
- :slug if respond_to? :attr_accessible
24
-
25
- # awesome nested set
26
- acts_as_nested_set
27
- default_scope { order('lft ASC') }
28
-
29
- # friendly id
30
- extend FriendlyId
31
- friendly_id :name, use: [:slugged]
32
-
33
- # validations
34
- validates :name, presence: true,
35
- uniqueness: { scope: [:parent_id] }
36
-
37
- validates :locale, presence: true,
38
- if: :root?
39
-
40
- validates :locale, inclusion: I18n.available_locales.map(&:to_s),
41
- if: proc { |cc| cc.locale.present? }
42
-
43
- validates :locale, absence: true,
44
- unless: :root?
45
-
46
- def ecm_downloads_downloads_count
47
- ecm_downloads_downloads.count
48
- end
49
-
50
- def human
51
- name
52
- end
53
-
54
- def to_s
55
- name
1
+ module Ecm
2
+ module Downloads
3
+ class DownloadCategory < ActiveRecord::Base
4
+ # associations
5
+ has_many :downloads, -> { order(:position) },
6
+ dependent: :destroy,
7
+ foreign_key: :download_category_id,
8
+ inverse_of: :download_category
9
+
10
+ accepts_nested_attributes_for :downloads,
11
+ allow_destroy: true
12
+
13
+ # attributes
14
+ attr_accessible :description,
15
+ :downloads_attributes,
16
+ :downloads_count,
17
+ :locale,
18
+ :name,
19
+ :parent_id,
20
+ :position,
21
+ :slug if respond_to? :attr_accessible
22
+
23
+ # awesome nested set
24
+ acts_as_nested_set
25
+ default_scope { order('lft ASC') }
26
+
27
+ # friendly id
28
+ extend FriendlyId
29
+ friendly_id :name, use: [:slugged]
30
+
31
+ # validations
32
+ validates :name, presence: true,
33
+ uniqueness: { scope: [:parent_id] }
34
+
35
+ validates :locale, presence: true,
36
+ if: :root?
37
+
38
+ validates :locale, inclusion: I18n.available_locales.map(&:to_s),
39
+ if: proc { |cc| cc.locale.present? }
40
+
41
+ validates :locale, absence: true,
42
+ unless: :root?
43
+
44
+ def downloads_count
45
+ downloads.count
46
+ end
47
+
48
+ def human
49
+ name
50
+ end
51
+
52
+ def to_s
53
+ name
54
+ end
55
+ end
56
56
  end
57
57
  end
@@ -2,4 +2,4 @@
2
2
 
3
3
  %p= download_category.description
4
4
 
5
- = render download_category.ecm_downloads_downloads.decorate
5
+ = render download_category.downloads.decorate
@@ -5,5 +5,5 @@
5
5
 
6
6
  = render @collection
7
7
 
8
- = bootstrap_button(to: root_path, context: :default) do
8
+ = bootstrap_button(to: main_app.root_path, context: :default) do
9
9
  = t('.back')
@@ -5,7 +5,7 @@
5
5
 
6
6
  %p= @resource.description
7
7
 
8
- = render @resource.ecm_downloads_downloads.decorate
8
+ = render @resource.downloads.decorate
9
9
 
10
10
  = bootstrap_button(to: :back, context: :default) do
11
11
  = t('.back')
@@ -3,7 +3,7 @@
3
3
 
4
4
  %h1= Ecm::Downloads::Download.model_name.human(count: :other)
5
5
 
6
- - @collection.group_by{|d| d.ecm_downloads_download_category}.each do |category, collection|
6
+ - @collection.group_by{|d| d.download_category}.each do |category, collection|
7
7
  %h2= category.name
8
8
  = render collection
9
9
 
@@ -11,8 +11,8 @@ de:
11
11
  asset_updated_at: Datei aktualisiert am
12
12
  created_at: Erstellt am
13
13
  description: Beschreibung
14
- ecm_downloads_download_category: Download Kategorie
15
- ecm_downloads_download_category_id: Download Kategorie
14
+ download_category: Download Kategorie
15
+ download_category_id: Download Kategorie
16
16
  filesize: Dateigröße
17
17
  link: Link
18
18
  locale: Sprache
@@ -26,5 +26,5 @@ de:
26
26
  one: Download
27
27
  other: Downloads
28
28
  routes:
29
- ecm_downloads_downloads: downloads
29
+ downloads: downloads
30
30
 
@@ -11,8 +11,8 @@ en:
11
11
  asset_updated_at: file updated at
12
12
  created_at: created at
13
13
  description: description
14
- ecm_downloads_download_category: download category
15
- ecm_downloads_download_category_id: download category
14
+ download_category: download category
15
+ download_category_id: download category
16
16
  filesize: filesize
17
17
  link: link
18
18
  locale: locale
@@ -26,5 +26,5 @@ en:
26
26
  one: download
27
27
  other: downloads
28
28
  routes:
29
- ecm_downloads_downloads: downloads
29
+ downloads: downloads
30
30
 
@@ -7,8 +7,8 @@ de:
7
7
  created_at: Erstellt am
8
8
  depth: Baumtiefe
9
9
  description: Beschreibung
10
- ecm_downloads_downloads: Downloads
11
- ecm_downloads_downloads_count: Downloads
10
+ downloads: Downloads
11
+ downloads_count: Downloads
12
12
  lft: Links
13
13
  link: Link
14
14
  locale: Sprache
@@ -24,5 +24,5 @@ de:
24
24
  one: Download Kategorie
25
25
  other: Download Kategorien
26
26
  routes:
27
- ecm_downloads_download_categories: download-kategorien
27
+ download_categories: download-kategorien
28
28
 
@@ -7,8 +7,8 @@ en:
7
7
  created_at: created at
8
8
  depth: depth
9
9
  description: description
10
- ecm_downloads_downloads: downloads
11
- ecm_downloads_downloads_count: downloads
10
+ downloads: downloads
11
+ downloads_count: downloads
12
12
  lft: left
13
13
  link: link
14
14
  locale: locale
@@ -24,5 +24,5 @@ en:
24
24
  one: download category
25
25
  other: download categories
26
26
  routes:
27
- ecm_downloads_download_categories: download-categories
27
+ download_categories: download-categories
28
28
 
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Ecm::Downloads::Engine.routes.draw do
2
+ localized do
3
+ resources :download_categories, only: [:index, :show]
4
+ resources :downloads, only: [:index, :show] do
5
+ get :download, on: :member
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ class RenameEcmDownloadsDownloadCategoryIdToDownloadCategoryId < ActiveRecord::Migration[4.2]
2
+ def change
3
+ rename_column :ecm_downloads_downloads, :ecm_downloads_download_category_id, :download_category_id
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveEcmDownloadsDownloadsCount < ActiveRecord::Migration[4.2]
2
+ def change
3
+ remove_column :ecm_downloads_download_categories, :ecm_downloads_downloads_count
4
+ end
5
+ end
@@ -1,13 +1,7 @@
1
1
  module Ecm
2
2
  module Downloads
3
3
  class Engine < Rails::Engine
4
- initializer :ecm_downloads_engine do
5
- ::ActiveAdmin.setup do |config|
6
- config.load_paths += Dir[root.join(*%(app admin))]
7
- config.register_stylesheet 'ecm_downloads.css'
8
- # config.register_javascript 'ecm_downloads.js'
9
- end
10
- end if Gem::Specification.find_all_by_name('activeadmin').any?
4
+ isolate_namespace Ecm::Downloads
11
5
  end
12
6
  end
13
7
  end
@@ -1,5 +1,5 @@
1
1
  module Ecm
2
2
  module Downloads
3
- VERSION = '3.0.0'
3
+ VERSION = '4.0.1'
4
4
  end
5
5
  end
@@ -8,7 +8,6 @@ require 'draper'
8
8
 
9
9
  require 'ecm/downloads/engine'
10
10
  require 'ecm/downloads/configuration'
11
- require 'ecm/downloads/routing'
12
11
 
13
12
  module Ecm
14
13
  module Downloads
@@ -1,5 +1,3 @@
1
1
 
2
2
  # ECM Downloads Frontend Routing
3
- localized do
4
- Ecm::Downloads::Routing.routes(self)
5
- end
3
+ mount Ecm::Downloads::Engine, at: '/'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_downloads2
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-04 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -493,11 +493,13 @@ files:
493
493
  - config/locales/ecm.downloads.download_category.de.yml
494
494
  - config/locales/ecm.downloads.download_category.en.yml
495
495
  - config/locales/ecm.downloads.en.yml
496
+ - config/routes.rb
496
497
  - db/migrate/001_create_ecm_downloads_download_categories.rb
497
498
  - db/migrate/002_create_ecm_downloads_downloads.rb
499
+ - db/migrate/20170505182738_rename_ecm_downloads_download_category_id_to_download_category_id.rb
500
+ - db/migrate/20170505183226_remove_ecm_downloads_downloads_count.rb
498
501
  - lib/ecm/downloads/configuration.rb
499
502
  - lib/ecm/downloads/engine.rb
500
- - lib/ecm/downloads/routing.rb
501
503
  - lib/ecm/downloads/version.rb
502
504
  - lib/ecm_downloads2.rb
503
505
  - lib/generators/ecm/downloads/install/install_generator.rb
@@ -1,24 +0,0 @@
1
- module Ecm
2
- module Downloads
3
- class Routing
4
- # Creates the routes for downloads and categories. You can pass options to
5
- # specify the actions for both downloads and/or categories.
6
- #
7
- # Ecm::Downloads::Routing.routes(self, { :download_category_actions => [ :show ]})
8
- #
9
- # This will only create the show action for download categories, but omit the index action.
10
- def self.routes(router, options = {})
11
- options.reverse_merge!(
12
- download_category_actions: [:index, :show],
13
- download_actions: [:index, :show],
14
- add_download_member_action: false
15
- )
16
-
17
- router.resources :ecm_downloads_download_categories, only: options[:download_category_actions], controller: 'ecm/downloads/download_categories'
18
- router.resources :ecm_downloads_downloads, only: options[:download_actions], controller: 'ecm/downloads/downloads' do
19
- router.get :download, on: :member, if: options[:add_download_member_action]
20
- end
21
- end
22
- end
23
- end
24
- end