ecm_pictures 0.0.17 → 0.0.18
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.
@@ -8,7 +8,8 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
|
|
8
8
|
attr_accessible :description,
|
9
9
|
:image,
|
10
10
|
:name,
|
11
|
-
:picture_gallery_id
|
11
|
+
:picture_gallery_id,
|
12
|
+
:position
|
12
13
|
|
13
14
|
# acts as list
|
14
15
|
acts_as_list :scope => :picture_gallery
|
@@ -17,7 +18,7 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
|
|
17
18
|
before_validation :set_name_from_image_file_name, :if => Proc.new { |p| p.name.nil? }
|
18
19
|
|
19
20
|
# default scope
|
20
|
-
default_scope :order => "picture_gallery_id, position"
|
21
|
+
default_scope :order => "picture_gallery_id, position ASC"
|
21
22
|
|
22
23
|
# friendly id
|
23
24
|
extend FriendlyId
|
@@ -2,14 +2,17 @@ class Ecm::Pictures::PictureGallery < ActiveRecord::Base
|
|
2
2
|
self.table_name = 'ecm_pictures_picture_galleries'
|
3
3
|
|
4
4
|
# associations
|
5
|
-
has_many :pictures,
|
6
|
-
|
5
|
+
has_many :pictures,
|
6
|
+
:dependent => :destroy,
|
7
|
+
:order => 'position'
|
7
8
|
|
8
9
|
# attributes
|
9
10
|
attr_accessible :description,
|
10
11
|
:link_images,
|
11
12
|
:name,
|
12
|
-
:pictures_attributes
|
13
|
+
:pictures_attributes,
|
14
|
+
:position
|
15
|
+
accepts_nested_attributes_for :pictures, :allow_destroy => true
|
13
16
|
|
14
17
|
# acts as list
|
15
18
|
acts_as_list
|
data/lib/ecm/pictures/version.rb
CHANGED
@@ -1,4 +1,60 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :ecm do
|
2
|
+
namespace :pictures do
|
3
|
+
namespace :db do
|
4
|
+
desc "Purges and creates example data"
|
5
|
+
task :populate!, [] => [:environment] do |t, args|
|
6
|
+
Rake::Task["ecm:pictures:db:clear!"].execute
|
7
|
+
Rake::Task["ecm:pictures:db:populate"].execute
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Clears all data!"
|
11
|
+
task :clear!, [] => [:environment] do |t, args|
|
12
|
+
Rake::Task["ecm:pictures:db:clear_galleries!"].execute
|
13
|
+
Rake::Task["ecm:pictures:db:clear_pictures!"].execute
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Clears all gallery data!"
|
17
|
+
task :clear_galleries!, [] => [:environment] do |t, args|
|
18
|
+
Ecm::Pictures::PictureGallery.delete_all
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Clears all picture data!"
|
22
|
+
task :clear_pictures!, [] => [:environment] do |t, args|
|
23
|
+
Ecm::Pictures::Picture.delete_all
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "Creates example data"
|
27
|
+
task :populate, [] => [:environment] do |t, args|
|
28
|
+
Rake::Task["ecm:pictures:db:populate_galleries"].execute
|
29
|
+
Rake::Task["ecm:pictures:db:populate_pictures"].execute
|
30
|
+
end
|
31
|
+
|
32
|
+
desc "Creates example data for galleries"
|
33
|
+
task :populate_galleries, [] => [:environment] do |t, args|
|
34
|
+
5.times do |i|
|
35
|
+
Ecm::Pictures::PictureGallery.create! do |pg|
|
36
|
+
pg.name = "Picture Gallery #{i}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Creates example data for pictures"
|
42
|
+
task :populate_pictures, [] => [:environment] do |t, args|
|
43
|
+
require "ffaker"
|
44
|
+
require "forgery"
|
45
|
+
|
46
|
+
picture_galleries = Ecm::Pictures::PictureGallery.all
|
47
|
+
50.times do
|
48
|
+
Ecm::Pictures::Picture.create! do |p|
|
49
|
+
p.picture_gallery = picture_galleries.choice
|
50
|
+
p.image = File.open(File.join(Rails.root, 'spec/files', 'ecm/pictures/pictures', 'example.jpg'))
|
51
|
+
p.name = Faker::Product.brand if (rand(2) == 1)
|
52
|
+
p.description = Faker::Lorem.paragraph(rand(10))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecm_pictures
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 18
|
10
|
+
version: 0.0.18
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Roberto Vasquez Angel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|