ecm_downloads2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +57 -0
- data/Rakefile +34 -0
- data/app/assets/images/ecm_downloads/download_categories/last_node.png +0 -0
- data/app/assets/images/ecm_downloads/download_categories/node.png +0 -0
- data/app/assets/images/ecm_downloads/download_categories/vertical_line.png +0 -0
- data/app/assets/stylesheets/ecm_downloads/downloads_categories.css.erb +30 -0
- data/app/assets/stylesheets/ecm_downloads.css +1 -0
- data/app/controllers/ecm/downloads/download_categories_controller.rb +9 -0
- data/app/controllers/ecm/downloads/downloads_controller.rb +15 -0
- data/app/decorators/ecm/downloads/download_category_decorator.rb +18 -0
- data/app/decorators/ecm/downloads/download_decorator.rb +21 -0
- data/app/helpers/ecm/downloads/download_category_helper.rb +12 -0
- data/app/helpers/ecm/downloads/download_helper.rb +12 -0
- data/app/models/ecm/downloads/download.rb +89 -0
- data/app/models/ecm/downloads/download_category.rb +79 -0
- data/app/views/ecm/downloads/download_categories/_download_category.html.erb +22 -0
- data/app/views/ecm/downloads/download_categories/_download_category_in_index.html.erb +5 -0
- data/app/views/ecm/downloads/download_categories/index.html.erb +5 -0
- data/app/views/ecm/downloads/download_categories/show.html.erb +9 -0
- data/app/views/ecm/downloads/downloads/_download.html.erb +11 -0
- data/app/views/ecm/downloads/downloads/_download_in_table.html.erb +10 -0
- data/app/views/ecm/downloads/downloads/_table.html.erb +7 -0
- data/app/views/ecm/downloads/downloads/index.html.erb +3 -0
- data/app/views/ecm/downloads/downloads/show.html.erb +7 -0
- data/config/locales/active_admin.patch.de.yml +29 -0
- data/config/locales/ecm.downloads.de.yml +16 -0
- data/config/locales/ecm.downloads.download.de.yml +28 -0
- data/config/locales/ecm.downloads.download.en.yml +28 -0
- data/config/locales/ecm.downloads.download_category.de.yml +27 -0
- data/config/locales/ecm.downloads.download_category.en.yml +27 -0
- data/config/locales/ecm.downloads.en.yml +16 -0
- data/config/routes.rb +5 -0
- data/db/migrate/001_create_ecm_downloads_download_categories.rb +24 -0
- data/db/migrate/002_create_ecm_downloads_downloads.rb +31 -0
- data/lib/ecm/downloads/active_admin/ecm_downloads_download_categories.rb +138 -0
- data/lib/ecm/downloads/active_admin/ecm_downloads_downloads.rb +49 -0
- data/lib/ecm/downloads/configuration.rb +22 -0
- data/lib/ecm/downloads/engine.rb +21 -0
- data/lib/ecm/downloads/routing.rb +26 -0
- data/lib/ecm/downloads/version.rb +6 -0
- data/lib/ecm_downloads2.rb +20 -0
- data/lib/generators/ecm/downloads/install/install_generator.rb +16 -0
- data/lib/generators/ecm/downloads/install/templates/ecm_downloads.rb +15 -0
- data/lib/generators/ecm/downloads/locales/locales_generator.rb +24 -0
- data/lib/tasks/ecm_downloads_tasks.rake +52 -0
- metadata +488 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
activerecord:
|
4
|
+
attributes:
|
5
|
+
ecm/downloads/download_category:
|
6
|
+
children: children
|
7
|
+
created_at: created at
|
8
|
+
depth: depth
|
9
|
+
description: description
|
10
|
+
ecm_downloads_downloads: downloads
|
11
|
+
ecm_downloads_downloads_count: downloads
|
12
|
+
lft: left
|
13
|
+
locale: locale
|
14
|
+
name: name
|
15
|
+
parent: parent
|
16
|
+
parent_id: parent
|
17
|
+
position: position
|
18
|
+
rgt: right
|
19
|
+
slug: friendly id
|
20
|
+
updated_at: updated at
|
21
|
+
models:
|
22
|
+
ecm/downloads/download_category:
|
23
|
+
one: download category
|
24
|
+
other: download categories
|
25
|
+
routes:
|
26
|
+
ecm_downloads_download_categories: download-categories
|
27
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
en:
|
2
|
+
ecm:
|
3
|
+
downloads:
|
4
|
+
active_admin:
|
5
|
+
menu: "Downloads"
|
6
|
+
download:
|
7
|
+
actions:
|
8
|
+
start_download: "Download now"
|
9
|
+
messages:
|
10
|
+
not_found: "Download \"%{name}\" not found."
|
11
|
+
download_category:
|
12
|
+
actions:
|
13
|
+
back_to_index: "Back to the index"
|
14
|
+
messages:
|
15
|
+
not_found: "Download category \"%{name}\" not found."
|
16
|
+
no_downloads_available: "There are now downloads in this category."
|
data/config/routes.rb
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
## Rails.application.routes.draw do
|
2
|
+
#Ecm::Downloads::Engine.routes.draw do
|
3
|
+
# resources :ecm_downloads_download_categories, :only => [ :index, :show ], :controller => 'ecm/downloads/download_categories'
|
4
|
+
# resources :ecm_downloads_downloads, :only => [ :index, :show ], :controller => 'ecm/downloads/downloads'
|
5
|
+
#end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateEcmDownloadsDownloadCategories < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_downloads_download_categories do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
t.string :locale
|
7
|
+
t.integer :position
|
8
|
+
|
9
|
+
# references
|
10
|
+
t.integer :ecm_downloads_downloads_count, :default => 0, :null => false
|
11
|
+
|
12
|
+
# awesome nested set
|
13
|
+
t.integer :parent_id
|
14
|
+
t.integer :lft
|
15
|
+
t.integer :rgt
|
16
|
+
t.integer :depth
|
17
|
+
|
18
|
+
# frienldy id
|
19
|
+
t.string :slug
|
20
|
+
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class CreateEcmDownloadsDownloads < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :ecm_downloads_downloads do |t|
|
4
|
+
t.string :name
|
5
|
+
t.text :description
|
6
|
+
t.timestamp :published_at
|
7
|
+
|
8
|
+
# references
|
9
|
+
t.references :ecm_downloads_download_category
|
10
|
+
|
11
|
+
# acts as list
|
12
|
+
t.integer :position
|
13
|
+
|
14
|
+
# friendly id
|
15
|
+
t.string :slug
|
16
|
+
|
17
|
+
# paperclip
|
18
|
+
# t.attachment :asset
|
19
|
+
t.string :asset_file_name
|
20
|
+
t.integer :asset_file_size
|
21
|
+
t.string :asset_content_type
|
22
|
+
t.timestamp :asset_updated_at
|
23
|
+
t.string :asset_fingerprint
|
24
|
+
|
25
|
+
t.timestamps
|
26
|
+
end
|
27
|
+
add_index :ecm_downloads_downloads,
|
28
|
+
:ecm_downloads_download_category_id,
|
29
|
+
:name => 'index_ecm_downloads_downloads_on_download_category_id'
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
if defined?(ActiveAdmin)
|
2
|
+
include ActiveAdmin::ActsAsList::Helper
|
3
|
+
include ActiveAdmin::AwesomeNestedSet::Helper
|
4
|
+
|
5
|
+
ActiveAdmin.register Ecm::Downloads::DownloadCategory do
|
6
|
+
# menu entry settings
|
7
|
+
menu :parent => I18n.t('ecm.downloads.active_admin.menu')
|
8
|
+
|
9
|
+
permit_params :description,
|
10
|
+
:ecm_downloads_downloads_count,
|
11
|
+
:locale,
|
12
|
+
:name,
|
13
|
+
:parent_id,
|
14
|
+
:position,
|
15
|
+
:slug,
|
16
|
+
ecm_downloads_downloads_attributes: [
|
17
|
+
:asset,
|
18
|
+
:description,
|
19
|
+
:ecm_downloads_download_category_id,
|
20
|
+
:name,
|
21
|
+
:published
|
22
|
+
]
|
23
|
+
|
24
|
+
# sorting
|
25
|
+
config.sort_order = 'lft_asc'
|
26
|
+
|
27
|
+
# awesome nested set
|
28
|
+
sortable_tree_member_actions
|
29
|
+
|
30
|
+
# scopes
|
31
|
+
scope :all
|
32
|
+
scope :roots
|
33
|
+
I18n.available_locales.each do |locale|
|
34
|
+
self.send(:scope, locale.to_s) do |klass|
|
35
|
+
klass.where(:locale => locale)
|
36
|
+
# klass.where(klass.arel_table[:locale].eq(locale).or(klass.arel_table[:locale].eq(nil)))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
form do |f|
|
41
|
+
f.inputs do
|
42
|
+
f.semantic_errors *f.object.errors.keys
|
43
|
+
end
|
44
|
+
|
45
|
+
f.inputs do
|
46
|
+
f.input :parent, :as => :select,
|
47
|
+
:collection => nested_set_options(Ecm::Downloads::DownloadCategory, f.object) { |dc| "#{'-' * dc.depth} #{dc.name}" }
|
48
|
+
f.input :locale, :as => :select,
|
49
|
+
:collection => I18n.available_locales.map(&:to_s)
|
50
|
+
f.input :name
|
51
|
+
f.input :description
|
52
|
+
end
|
53
|
+
|
54
|
+
f.inputs do
|
55
|
+
f.has_many :ecm_downloads_downloads do |d|
|
56
|
+
if d.object.persisted?
|
57
|
+
d.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
|
58
|
+
end
|
59
|
+
d.input :asset, :as => :file
|
60
|
+
d.input :name
|
61
|
+
d.input :published, :as => :boolean
|
62
|
+
d.input :description
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
f.actions
|
67
|
+
end
|
68
|
+
|
69
|
+
index do
|
70
|
+
selectable_column
|
71
|
+
sortable_tree_columns
|
72
|
+
column :locale
|
73
|
+
column :name do |dc|
|
74
|
+
span(:style => "margin-left: #{25 * dc.level}px") { dc.name }
|
75
|
+
end
|
76
|
+
column(:description) do |dc|
|
77
|
+
truncate(dc.description, :length => 100 , :separator => ' ')
|
78
|
+
end
|
79
|
+
column :ecm_downloads_downloads_count
|
80
|
+
actions
|
81
|
+
end
|
82
|
+
|
83
|
+
show :title => :to_s do
|
84
|
+
attributes_table do
|
85
|
+
row :parent
|
86
|
+
row :locale
|
87
|
+
row :name
|
88
|
+
row :ecm_downloads_downloads_count
|
89
|
+
row :created_at
|
90
|
+
row :updated_at
|
91
|
+
end
|
92
|
+
|
93
|
+
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:description) do
|
94
|
+
div do
|
95
|
+
ecm_downloads_download_category.description
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:display_code) do
|
100
|
+
div do
|
101
|
+
ecm_downloads_download_category.display_code
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:link) do
|
106
|
+
div do
|
107
|
+
ecm_downloads_download_category_path(I18n.locale, ecm_downloads_download_category)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:children) do
|
112
|
+
table_for ecm_downloads_download_category.children, :i18n => Ecm::Downloads::DownloadCategory do
|
113
|
+
sortable_tree_columns
|
114
|
+
column(:index_name) do |ecm_downloads_download_category|
|
115
|
+
link_to ecm_downloads_download_category, [:admin, ecm_downloads_download_category]
|
116
|
+
end
|
117
|
+
column :description
|
118
|
+
column :ecm_downloads_downloads_count
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:ecm_downloads_downloads) do
|
123
|
+
table_for ecm_downloads_download_category.ecm_downloads_downloads, :i18n => Ecm::Downloads::Download do
|
124
|
+
sortable_columns
|
125
|
+
column(:name) do |ecm_downloads_download|
|
126
|
+
link_to ecm_downloads_download, [:admin, ecm_downloads_download]
|
127
|
+
end
|
128
|
+
acts_as_published_columns
|
129
|
+
column :asset_file_name
|
130
|
+
column :asset_file_size, :sortable => :asset_file_size do |download|
|
131
|
+
number_to_human_size(download.asset_file_size)
|
132
|
+
end
|
133
|
+
column :created_at
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
include ActiveAdmin::ActsAsList::Helper
|
2
|
+
include ActsAsPublished::ActiveAdminHelper
|
3
|
+
|
4
|
+
ActiveAdmin.register Ecm::Downloads::Download do
|
5
|
+
# acts as list
|
6
|
+
sortable_member_actions
|
7
|
+
|
8
|
+
# acts as published
|
9
|
+
acts_as_published_actions
|
10
|
+
|
11
|
+
# config
|
12
|
+
menu :parent => I18n.t('ecm.downloads.active_admin.menu')
|
13
|
+
|
14
|
+
permit_params :asset,
|
15
|
+
:description,
|
16
|
+
:ecm_downloads_download_category_id,
|
17
|
+
:name
|
18
|
+
|
19
|
+
# scopes
|
20
|
+
scope :all
|
21
|
+
scope :published
|
22
|
+
scope :unpublished
|
23
|
+
|
24
|
+
form :html => { :enctype => "multipart/form-data" } do |f|
|
25
|
+
f.inputs do
|
26
|
+
f.input :ecm_downloads_download_category, :as => :select,
|
27
|
+
:collection => nested_set_options(Ecm::Downloads::DownloadCategory) { |dc| "#{'-' * dc.level} #{dc.name}" }
|
28
|
+
f.input :asset, :as => :file
|
29
|
+
f.input :name
|
30
|
+
f.input :published, :as => :boolean
|
31
|
+
f.input :description
|
32
|
+
end
|
33
|
+
|
34
|
+
f.actions
|
35
|
+
end
|
36
|
+
|
37
|
+
index do
|
38
|
+
selectable_column
|
39
|
+
column :ecm_downloads_download_category
|
40
|
+
column :name
|
41
|
+
acts_as_published_columns
|
42
|
+
column :asset_file_name
|
43
|
+
column :asset_file_size, :sortable => :asset_file_size do |download|
|
44
|
+
number_to_human_size(download.asset_file_size)
|
45
|
+
end
|
46
|
+
column :created_at
|
47
|
+
actions
|
48
|
+
end
|
49
|
+
end if defined?(ActiveAdmin)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'active_support/core_ext/module/delegation'
|
2
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
|
5
|
+
module Ecm
|
6
|
+
module Downloads
|
7
|
+
module Configuration
|
8
|
+
def configure
|
9
|
+
yield self
|
10
|
+
end
|
11
|
+
|
12
|
+
mattr_accessor :paperclip_options do
|
13
|
+
{}
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
mattr_accessor :base_controller do
|
18
|
+
'ApplicationController'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Downloads
|
3
|
+
class Engine < Rails::Engine
|
4
|
+
# active admin
|
5
|
+
initializer :ecm_courses_engine do
|
6
|
+
::ActiveAdmin.setup do |active_admin_config|
|
7
|
+
active_admin_config.load_paths += Dir[File.dirname(__FILE__) + '/active_admin']
|
8
|
+
end
|
9
|
+
end if defined?(::ActiveAdmin)
|
10
|
+
|
11
|
+
# helpers
|
12
|
+
config.to_prepare do
|
13
|
+
ApplicationController.helper(Ecm::Downloads::DownloadCategoryHelper)
|
14
|
+
ApplicationController.helper(Ecm::Downloads::DownloadHelper)
|
15
|
+
end
|
16
|
+
|
17
|
+
# locales
|
18
|
+
paths["config/locales"] << File.dirname(__FILE__) + '/../../../config/locales'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
|
18
|
+
router.resources :ecm_downloads_download_categories, :only => options[:download_category_actions], :controller => 'ecm/downloads/download_categories'
|
19
|
+
router.resources :ecm_downloads_downloads, :only => options[:download_actions], :controller => 'ecm/downloads/downloads' do
|
20
|
+
router.get :download, :on => :member, :if => options[:add_download_member_action]
|
21
|
+
end # router.resources :ecm_downloads_downloads
|
22
|
+
end # def
|
23
|
+
end # class Routing
|
24
|
+
end # module Downloads
|
25
|
+
end # module Ecm
|
26
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'active_admin-acts_as_list'
|
2
|
+
require 'active_admin-awesome_nested_set'
|
3
|
+
require 'acts_as_list'
|
4
|
+
require 'acts_as_published'
|
5
|
+
require 'awesome_nested_set'
|
6
|
+
require 'awesome_nested_set-tools'
|
7
|
+
require 'friendly_id'
|
8
|
+
require 'paperclip'
|
9
|
+
require 'draper'
|
10
|
+
|
11
|
+
require 'ecm/downloads/engine'
|
12
|
+
require 'ecm/downloads/configuration'
|
13
|
+
require 'ecm/downloads/routing'
|
14
|
+
|
15
|
+
module Ecm
|
16
|
+
module Downloads
|
17
|
+
extend Configuration
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Downloads
|
3
|
+
module Generators
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Generates the intializer"
|
6
|
+
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def generate_intializer
|
10
|
+
copy_file "ecm_downloads.rb", "config/initializers/ecm_downloads.rb"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Ecm::Downloads.configure do |config|
|
2
|
+
# Paperclip options
|
3
|
+
#
|
4
|
+
# default: config.paperclip_options = {
|
5
|
+
# }
|
6
|
+
config.paperclip_options = {
|
7
|
+
}
|
8
|
+
|
9
|
+
# Set the base controller for the contact form
|
10
|
+
#
|
11
|
+
# Default: config.base_controller = 'ApplicationController'
|
12
|
+
#
|
13
|
+
config.base_controller = 'ApplicationController'
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ecm
|
2
|
+
module Downloads
|
3
|
+
module Generators
|
4
|
+
class LocalesGenerator < Rails::Generators::Base
|
5
|
+
desc "Copies the locale files to your application"
|
6
|
+
|
7
|
+
source_root File.expand_path('../../../../../../config/locales', __FILE__)
|
8
|
+
|
9
|
+
def generate_locales
|
10
|
+
copy_file "ecm.downloads.en.yml", "config/locales/ecm.downloads.en.yml"
|
11
|
+
copy_file "ecm.downloads.de.yml", "config/locales/ecm.downloads.de.yml"
|
12
|
+
|
13
|
+
copy_file "ecm.downloads.download_category.en.yml", "config/locales/ecm.downloads.download_category.en.yml"
|
14
|
+
copy_file "ecm.downloads.download_category.de.yml", "config/locales/ecm.downloads.download_category.de.yml"
|
15
|
+
|
16
|
+
|
17
|
+
copy_file "ecm.downloads.download.en.yml", "config/locales/ecm.downloads.download.en.yml"
|
18
|
+
copy_file "ecm.downloads.download.de.yml", "config/locales/ecm.downloads.download.de.yml"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
namespace :ecm_downloads do
|
2
|
+
namespace :db do
|
3
|
+
desc "Purges and creates example data"
|
4
|
+
task :populate!, [] => [:environment] do |t, args|
|
5
|
+
|
6
|
+
Rake::Task["ecm_downloads:db:clear!"].execute
|
7
|
+
Rake::Task["ecm_downloads:db:populate"].execute
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Clears all data!"
|
11
|
+
task :clear!, [] => [:environment] do |t, args|
|
12
|
+
Ecm::Downloads::DownloadCategory.delete_all
|
13
|
+
Ecm::Downloads::Download.delete_all
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Creates example_data"
|
17
|
+
task :populate, [] => [:environment] do |t, args|
|
18
|
+
require "ffaker"
|
19
|
+
require "forgery"
|
20
|
+
|
21
|
+
# Create example download category roots
|
22
|
+
10.times do
|
23
|
+
Ecm::Downloads::DownloadCategory.create! do |dc|
|
24
|
+
dc.locale = I18n.available_locales.choice.to_s
|
25
|
+
dc.name = Faker::Product.brand
|
26
|
+
dc.description = Faker::Lorem.paragraph(rand(10))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create example download sub-categories
|
31
|
+
10.times do
|
32
|
+
Ecm::Downloads::DownloadCategory.create! do |dc|
|
33
|
+
dc.parent = Ecm::Downloads::DownloadCategory.all.choice
|
34
|
+
dc.name = Faker::Product.brand
|
35
|
+
dc.description = Faker::Lorem.paragraph(rand(10))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Create example downloads
|
40
|
+
download_categories = Ecm::Downloads::DownloadCategory.all
|
41
|
+
100.times do
|
42
|
+
Ecm::Downloads::Download.create! do |d|
|
43
|
+
d.ecm_downloads_download_category = download_categories.choice
|
44
|
+
d.name = Faker::Product.product_name
|
45
|
+
d.asset = File.open(Ecm::Downloads::Engine.root + "spec/fixtures/download/example.txt")
|
46
|
+
d.published = [true, false].choice
|
47
|
+
d.description = Faker::Lorem.paragraph(rand(10))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|