caboose-rets 0.0.29 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/caboose_rets/media.rb +51 -0
- data/lib/caboose_rets/version.rb +1 -1
- data/lib/tasks/caboose_rets.rake +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODgwYjM2ZTA5ZGEwYjM4NDk0ZDg4ODFmMjNkZGMxMjVkYmYwNjkzMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDIyMTQ3YzM5MTA1MTkzOGM4ZjMwYWIwZGRhMDhkYWNkYWI3ODJhMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmJiYjQyYTQ5MzcwMzAyOTY1ZjIwZGI1NDNjMjhhODY3MzIyMTBhMzkyOTUw
|
10
|
+
ZTIwNjk5ZmU5MTM4N2RjY2IxODMyYzQ1NzcwZWNlZTk1ZmI3ZDE4N2JkOGM3
|
11
|
+
ODE4YjM2NjE5MjQ4N2Y3MWJlNWFmN2Q2YjdiZWYwMDU5ZmZkOGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjAyMmFiNjAyMzEwMTg3NzAzODc0YmVhMDlhZTg4MGQ1NTJiY2Y3ZjMxMGQ2
|
14
|
+
Y2FkZTI2OGQ0ZjIxM2Q5YTA3YjllZGRmOWQ4OThjOGQyMTU5NzQxNGYwY2Jk
|
15
|
+
OWUzYTUxMDI5MjBjODYzYmNkNWMwYjMzZWM3OWM4ZjY3YmY0Nzc=
|
@@ -69,5 +69,56 @@ class CabooseRets::Media < ActiveRecord::Base
|
|
69
69
|
|
70
70
|
return true
|
71
71
|
end
|
72
|
+
|
73
|
+
def self.reorder(media_ids, bucket_name)
|
74
|
+
|
75
|
+
s3 = AWS::S3.new
|
76
|
+
b = s3.buckets[bucket_name]
|
77
|
+
|
78
|
+
# Rename the s3 assets to temp names
|
79
|
+
media_ids.each do |id|
|
80
|
+
m = CabooseRets::Media.find(id)
|
81
|
+
(m.image.styles.keys+[:original]).each { |style| b.objects[m.image.path(style)].rename_to "#{m.image.path(style)}.temp" } if m.media_type == 'Photo'
|
82
|
+
b.objects[m.file.path].rename_to "#{m.file.path}.temp" if m.media_type == 'File'
|
83
|
+
end
|
84
|
+
|
85
|
+
# Rename the assets to their new names
|
86
|
+
i = 1
|
87
|
+
j = 1
|
88
|
+
media_ids.each do |id|
|
89
|
+
m = CabooseRets::Media.find(id)
|
90
|
+
if m.media_type == 'Photo'
|
91
|
+
orig_name = "#{m.image.path}.temp"
|
92
|
+
m.media_order = i
|
93
|
+
(m.image.styles.keys+[:original]).each { |style| b.objects[orig_name.gsub("original", style.to_s)].rename_to m.image.path(style) }
|
94
|
+
m.save
|
95
|
+
i = i + 1
|
96
|
+
elsif m.media_type == 'File'
|
97
|
+
b.objects["#{m.file.path}.temp"].rename_to m.file.path
|
98
|
+
m.media_order = j
|
99
|
+
m.save
|
100
|
+
j = j + 1
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
return true
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.rename_media
|
108
|
+
s3 = AWS::S3.new
|
109
|
+
b = s3.buckets["advantagerealtygroup"]
|
110
|
+
|
111
|
+
CabooseRets::Media.where(:media_type => 'Photo').reorder("mls_acct, media_order").all.each do |m|
|
112
|
+
puts "Renaming #{m.mls_acct}_#{m.id}..."
|
113
|
+
if m.image_file_name && m.image
|
114
|
+
ext = File.extname(m.image_file_name)
|
115
|
+
(m.image.styles.keys+[:original]).each do |style|
|
116
|
+
b.objects[m.image.path(style)].copy_to "rets/media_new/#{m.id}_#{style}.#{ext}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
return true
|
122
|
+
end
|
72
123
|
|
73
124
|
end
|
data/lib/caboose_rets/version.rb
CHANGED
data/lib/tasks/caboose_rets.rake
CHANGED
@@ -2,6 +2,11 @@ require "caboose_rets/version"
|
|
2
2
|
|
3
3
|
namespace :caboose_rets do
|
4
4
|
|
5
|
+
desc "Initializes the database for a caboose installation"
|
6
|
+
task :rename_media => :environment do
|
7
|
+
CabooseRets::Media.rename_media
|
8
|
+
end
|
9
|
+
|
5
10
|
desc "Initializes the database for a caboose installation"
|
6
11
|
task :db => :environment do
|
7
12
|
CabooseRets::Schema.create_schema
|