caboose-rets 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzA4YzA0OGM3N2I2MDlkNmVhZmIyYzc3OGY5NWVkMTFkYzUwOTg1Nw==
4
+ NGI3MmM1MmE3NzJjMzkxNzhiNmQwMDIyYTA0ZmE2MTk5ZTk5MjE4ZA==
5
5
  data.tar.gz: !binary |-
6
- ZTdlN2M4YTMwZWQ5OWUwNzM5ZDEyYmViMDIwZjI0ZjMzYjU1YWI5Mg==
6
+ NTZmNDhmMjUwNDQ3OGM2MTk1MmNiMzViYzlkZWQ1M2Y4YTcxNDllZA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjhhYWQ2MTY4MWIyNWE0NjM5MjI1YWMwYjViNzg5M2Q0ZjQyYjIxYzQ4YjNm
10
- NTllMDJmMDE5OTQzNzRlOGI0YjFjNzMzNTYwMmU2NGE4ZDkxYjYxOGFjZDc2
11
- ZWU4MGUyMTJhZjBkNGUwOGFjMmEyMDliY2I4N2E5NGMyMGU0MGM=
9
+ ZWZlNTkxNmMxNzQyZjkwYzk5MDc1NGMzYTAwMzdlZGZkOGVjYTQwYmU2ZGI3
10
+ NGRiMmMzMWNiNjVmMjdhNTMzMjJmMGY1MTE5ZDI4MTcxOTJhYWRkZGU5YmI5
11
+ MzQ0NjEzMDEyOTQ2YmZhNWQ5OWQzMTBmY2Q3OTY5NjQ3MTdiMmM=
12
12
  data.tar.gz: !binary |-
13
- YzA2ZmVjZTdkZTBiOWM0ZDk4NThiNGJkMDA2OGM5MzM4NjRhMWY1YzRhNTFj
14
- NzMxM2RkNjU5ZjBkNDBkOGVlYjViZDI5ZTYxMGM4ZWRiYTdjNjUxOTIwYzll
15
- MDFkYzliOTgxYTIyNjAzYTRjYjNhY2U1M2RiOTVkOWRjMTBkYmE=
13
+ ZjQ0ODQ1MDY1MDU3MmM1YWYwZjFiYjRkMjg5ZTk3NTExODRjYWZlMDYyY2Iw
14
+ Y2JmZTI3ZmU1M2NkMDBhYzZlNDQxNTUwYmNiYWVlNDFkYTk0OTRmMDAxMWM5
15
+ MTkzZTQ1NjViOTJjYjgzNjE4ODNkMjE4MGRkYjczNzAwYmI1MGQ=
@@ -0,0 +1,197 @@
1
+
2
+ var MediaController = function(mls_acct) { this.init(mls_acct); };
3
+
4
+ MediaController.prototype = {
5
+
6
+ mls_acct: false,
7
+
8
+ s3_url: function(url)
9
+ {
10
+ return url.replace("d19w6hbyh7z79c.cloudfront.net/", "s3.amazonaws.com/advantagerealtygroup/");
11
+ },
12
+
13
+ init: function(mls_acct)
14
+ {
15
+ this.mls_acct = mls_acct;
16
+ var that = this;
17
+ this.image_add_form();
18
+ this.render_images(function() { that.sortable_images(); });
19
+ this.render_files(function() { that.sortable_files(); });
20
+ },
21
+
22
+ sortable_images: function()
23
+ {
24
+ var that = this;
25
+ $('#images').sortable({
26
+ placeholder: 'sortable-placeholder',
27
+ handle: '.sort_handle',
28
+ update: function(e, ui) {
29
+ $.ajax({
30
+ url: '/admin/media/' + that.mls_acct + '/order',
31
+ type: 'put',
32
+ data: $('#images').sortable('serialize', { key: 'sort[]' }),
33
+ success: function(resp) {}
34
+ });
35
+ }
36
+ });
37
+ },
38
+
39
+ sortable_files: function()
40
+ {
41
+ $('#files').sortable({
42
+ placeholder: 'sortable-placeholder',
43
+ handle: '.sort_handle',
44
+ update: function(e, ui) {
45
+ $.ajax({
46
+ url: '/admin/media/' + that.mls_acct + '/order',
47
+ type: 'put',
48
+ data: $('#files').sortable('serialize', { key: 'sort[]' }),
49
+ success: function(resp) {}
50
+ });
51
+ }
52
+ });
53
+ },
54
+
55
+ delete_image: function(media_id, confirm)
56
+ {
57
+ var that = this;
58
+ if (!confirm)
59
+ {
60
+ var p = $('<p/>')
61
+ .addClass('note warning')
62
+ .append("Are you sure you want to delete the image? ")
63
+ .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_image(media_id, true); })).append(" ")
64
+ .append($('<input/>').attr('type', 'button').val('No').click(function() { that.render_image(media_id); }));
65
+ $('#image_' + media_id).attr('onclick','').unbind('click');
66
+ $('#image_' + media_id).empty().append(p);
67
+ return;
68
+ }
69
+ $.ajax({
70
+ url: '/admin/media/' + media_id,
71
+ type: 'delete',
72
+ success: function(resp) {
73
+ that.render_images();
74
+ }
75
+ });
76
+ },
77
+
78
+ delete_file: function(media_id, confirm)
79
+ {
80
+ var that = this;
81
+ if (!confirm)
82
+ {
83
+ var p = $('<p/>')
84
+ .addClass('note warning')
85
+ .append("Are you sure you want to delete the file? ")
86
+ .append($('<input/>').attr('type', 'button').val('Yes').click(function() { that.delete_file(media_id, true); })).append(" ")
87
+ .append($('<input/>').attr('type', 'button').val('No').click(function() { that.render_file(media_id); }));
88
+ $('#image_' + media_id).attr('onclick','').unbind('click');
89
+ $('#image_' + media_id).empty().append(p);
90
+ return;
91
+ }
92
+ $.ajax({
93
+ url: '/admin/media/' + media_id,
94
+ type: 'delete',
95
+ success: function(resp) {
96
+ that.render_files();
97
+ }
98
+ });
99
+ },
100
+
101
+ /*****************************************************************************
102
+ Block Rendering
103
+ *****************************************************************************/
104
+
105
+ render_images: function(after)
106
+ {
107
+ $('#images').empty();
108
+ var that = this;
109
+ $.ajax({
110
+ url: '/admin/media/' + this.mls_acct + '/photos',
111
+ success: function(media) {
112
+ $(media).each(function(i,m) {
113
+ $('#images')
114
+ .append($('<li/>')
115
+ .attr('id', 'image_container_' + m.id)
116
+ .append($('<a/>').attr('id', 'image_' + m.id + '_sort_handle' ).addClass('sort_handle' ).append($('<span/>').addClass('ui-icon ui-icon-arrow-2-n-s')))
117
+ .append($('<a/>').attr('id', 'image_' + m.id + '_delete_handle').addClass('delete_handle').append($('<span/>').addClass('ui-icon ui-icon-close')).click(function(e) { e.preventDefault(); that.delete_image(m.id); }))
118
+ .append($('<div/>').attr('id', 'image_' + m.id).append($('<img/>').attr('src', that.s3_url(m.image.tiny_url) + '?' + Math.random()).attr('title', m.id + ' ' + m.image.file_name)))
119
+ );
120
+ });
121
+ if (after) after();
122
+ }
123
+ });
124
+ },
125
+
126
+ render_image: function(media_id, after)
127
+ {
128
+ var that = this;
129
+ $.ajax({
130
+ url: '/admin/media/' + media_id,
131
+ success: function(m) {
132
+ $('#image_' + m.id).empty().append($('<img/>').attr('src', that.s3_url(m.image.tiny_url) + '?' + Math.random()).attr('title', m.id));
133
+ if (after) after();
134
+ }
135
+ });
136
+ },
137
+
138
+ render_files: function(after)
139
+ {
140
+ $('#files').empty();
141
+ var that = this;
142
+ $.ajax({
143
+ url: '/admin/media/' + this.mls_acct + '/files',
144
+ success: function(media) {
145
+ $(media).each(function(i,m) {
146
+ $('#files')
147
+ .append($('<li/>')
148
+ .attr('id', 'file_container_' + m.id)
149
+ .append($('<a/>').attr('id', 'file_' + m.id + '_sort_handle' ).addClass('sort_handle' ).append($('<span/>').addClass('ui-icon ui-icon-arrow-2-n-s')))
150
+ .append($('<a/>').attr('id', 'file_' + m.id + '_delete_handle').addClass('delete_handle').append($('<span/>').addClass('ui-icon ui-icon-close')).click(function(e) { e.preventDefault(); that.delete_file(m.id); }))
151
+ .append($('<a/>').attr('id', 'file_' + m.id).attr('href', m.file.url).html(m.file.file_name))
152
+ );
153
+ });
154
+ if (after) after();
155
+ }
156
+ });
157
+ },
158
+
159
+ render_file: function(media_id, after)
160
+ {
161
+ var that = this;
162
+ $.ajax({
163
+ url: '/admin/media/' + media_id,
164
+ success: function(m) {
165
+ $('#file_' + m.id).attr('href', m.file.url).html(m.file.file_name);
166
+ if (after) after();
167
+ }
168
+ });
169
+ },
170
+
171
+ image_add_form: function()
172
+ {
173
+ var that = this;
174
+ var form = $('<form/>')
175
+ .attr('id', 'new_image_form')
176
+ .attr('action', '/admin/media/' + this.mls_acct +'/photos')
177
+ .attr('method', 'post')
178
+ .attr('target', 'image_upload_iframe')
179
+ .attr('enctype', 'multipart/form-data')
180
+ .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.auth_token))
181
+ .append($('<input/>').attr('type', 'file').attr('name', 'image').change(function() {
182
+ $('#new_image_form').submit();
183
+ $('#new_image_form').hide();
184
+ $('#new_image').append($('<p/>').addClass('loading').html("Adding image..."));
185
+ }));
186
+ $('#new_image').empty()
187
+ .append(form)
188
+ .append($('<iframe/>').attr('name', 'image_upload_iframe').css('display', 'none'));
189
+ },
190
+
191
+ after_image_upload: function()
192
+ {
193
+ this.image_add_form();
194
+ this.render_images();
195
+ },
196
+
197
+ };
@@ -0,0 +1,66 @@
1
+
2
+ var CabooseRets = function() {};
3
+
4
+ CabooseRets.search_params = {
5
+ uri: window.location.pathname,
6
+ property_type: "residential",
7
+ params: false
8
+ };
9
+
10
+ CabooseRets.save_search = function(uri, property_type, params)
11
+ {
12
+ $.ajax({
13
+ url: '/saved-searches',
14
+ type: 'post',
15
+ data: CabooseRets.search_params,
16
+ success: function(resp) {
17
+ caboose_modal_url(resp.redirect);
18
+ }
19
+ });
20
+ };
21
+
22
+ CabooseRets.get_save_property = function(mls_acct, el)
23
+ {
24
+ $.ajax({
25
+ url: '/saved-properties/' + mls_acct + '/status',
26
+ type: 'get',
27
+ success: function(resp) {
28
+ if (resp.saved == true) el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9733;</span> Saved");
29
+ else el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9734;</span> Save Listing");
30
+ }
31
+ });
32
+ }
33
+
34
+ CabooseRets.toggle_save_property = function(mls_acct, el)
35
+ {
36
+ $.ajax({
37
+ url: '/saved-properties/' + mls_acct + '/toggle',
38
+ type: 'get',
39
+ success: function(resp) {
40
+ if (resp.saved == true) el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9733;</span> Saved");
41
+ else el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9734;</span> Save Listing");
42
+ }
43
+ });
44
+ }
45
+
46
+ $(document).ready(function() {
47
+ caboose_modal('login');
48
+ caboose_modal('saved_searches_button');
49
+
50
+ $('#save_search').click(function(e) {
51
+ e.preventDefault();
52
+ CabooseRets.save_search();
53
+ });
54
+
55
+ $('.toggle_save_property').click(function(e) {
56
+ e.preventDefault();
57
+ var mls_acct = $(e.target).data('mls_acct');
58
+ CabooseRets.toggle_save_property(mls_acct, $(e.target));
59
+ });
60
+
61
+ $('.toggle_save_property').each(function(i, el) {
62
+ var mls_acct = $(el).data('mls_acct');
63
+ CabooseRets.get_save_property(mls_acct, $(el));
64
+ });
65
+
66
+ });
@@ -17,7 +17,7 @@ module CabooseRets
17
17
  # 'added_by_advantage' => '',
18
18
  'lo_code' => '',
19
19
  'address' => '',
20
- 'status' => ['Active', 'Pending']
20
+ 'status' => 'Active'
21
21
  },{
22
22
  'model' => 'CabooseRets::CommercialProperty',
23
23
  'sort' => 'mls_acct',
@@ -30,7 +30,9 @@ module CabooseRets
30
30
 
31
31
  # GET /commercial/:mls_acct/details
32
32
  def details
33
- @property = CommercialProperty.where(:mls_acct => params[:mls_acct]).first
33
+ @property = CommercialProperty.where(:mls_acct => params[:mls_acct]).first
34
+ #@agent = Agent.where(:la_code => @property.la_code).first ? Agent.where(:la_code => @property.la_code).exists? : nil
35
+ @saved = logged_in? && SavedProperty.where(:user_id => logged_in_user.id, :mls_acct => params[:mls_acct]).exists?
34
36
  end
35
37
 
36
38
  #=============================================================================
@@ -94,11 +96,21 @@ module CabooseRets
94
96
  return if !user_is_allowed('properties', 'edit')
95
97
 
96
98
  resp = Caboose::StdClass.new({'attributes' => {}})
97
- property = CommercialProperty.find(params[:id])
99
+ property = CommercialProperty.find(params[:mls_acct])
98
100
 
99
101
  save = true
100
102
  params.each do |name,value|
101
103
  case name
104
+ when 'la_code'
105
+ property.la_code = value
106
+ a = Agent.where(:la_code => value).first
107
+ resp.attributes['la_code'] = { 'text' => "#{a.first_name} #{a.last_name}" }
108
+ break
109
+ when 'lo_code'
110
+ property.lo_code = value
111
+ o = Office.where(:lo_code => value).first
112
+ resp.attributes['lo_code'] = { 'text' => o.lo_name }
113
+ break
102
114
  when 'acreage',
103
115
  'adjoining_land_use',
104
116
  'agent_notes',
@@ -107,6 +119,7 @@ module CabooseRets
107
119
  'annual_taxes',
108
120
  'approx_age',
109
121
  'area',
122
+ 'banner',
110
123
  'baths',
111
124
  'baths_full',
112
125
  'baths_half',
@@ -186,7 +199,7 @@ module CabooseRets
186
199
  'income_other',
187
200
  'income_rental',
188
201
  'internet_yn',
189
- 'la_code',
202
+ #'la_code',
190
203
  'leased_through',
191
204
  'legal_block',
192
205
  'legal_lot',
@@ -202,6 +215,7 @@ module CabooseRets
202
215
  'middle_school',
203
216
  'mls_acct',
204
217
  'municipality',
218
+ 'negotiable_price',
205
219
  'num_units',
206
220
  'num_units_occupied',
207
221
  'off_mkt_date',
@@ -302,7 +316,6 @@ module CabooseRets
302
316
  RetsImporter.import("(MLS_ACCT=#{p.mls_acct})", 'Property', 'COM')
303
317
  RetsImporter.download_property_images(p)
304
318
  render :json => Caboose::StdClass.new({ 'success' => "The property's info has been updated from MLS." })
305
- end
306
-
319
+ end
307
320
  end
308
321
  end
@@ -48,8 +48,8 @@ module CabooseRets
48
48
  'remarks_like' => '',
49
49
  'sa_code' => '',
50
50
  'so_code' => '',
51
- 'state' => '',
52
- 'status' => ['Active', 'Pending'],
51
+ 'state' => '',
52
+ 'status' => 'Active',
53
53
  'street_name_like' => '',
54
54
  'street_num_like' => '',
55
55
  'subdivision' => '',
@@ -72,6 +72,7 @@ module CabooseRets
72
72
  # GET /land/:mls_acct/details
73
73
  def details
74
74
  @property = CabooseRets::LandProperty.where(:mls_acct => params[:mls_acct]).first
75
+ @saved = logged_in? && SavedProperty.where(:user_id => logged_in_user.id, :mls_acct => params[:mls_acct]).exists?
75
76
  if @property.nil?
76
77
  @mls_acct = params[:mls_acct]
77
78
  render 'land/not_exists'
@@ -0,0 +1,146 @@
1
+
2
+ module CabooseRets
3
+ class MediaController < ApplicationController
4
+
5
+ # GET /admin/media/:mls_acct
6
+ def admin_index
7
+ return if !user_is_allowed('media', 'view')
8
+ @property = CabooseRets.get_property(params[:mls_acct])
9
+ render :layout => 'caboose/admin'
10
+ end
11
+
12
+ # GET /admin/media/:mls_acct/photos
13
+ def admin_photos
14
+ return if !user_is_allowed('media', 'view')
15
+ media = Media.where(:mls_acct => params[:mls_acct], :media_type => 'Photo').reorder(:media_order).all
16
+ media2 = media.collect do |m|
17
+ {
18
+ :id => m.id,
19
+ :date_modified => m.date_modified,
20
+ :file_name => m.file_name,
21
+ :media_id => m.media_id,
22
+ :media_order => m.media_order,
23
+ :media_remarks => m.media_remarks,
24
+ :media_type => m.media_type,
25
+ :mls_acct => m.mls_acct,
26
+ :url => m.url,
27
+ :image => {
28
+ :file_name => m.image_file_name,
29
+ :content_type => m.image_content_type,
30
+ :file_size => m.image_file_size,
31
+ :update_at => m.image_updated_at,
32
+ :tiny_url => m.image.url(:tiny),
33
+ :thumb_url => m.image.url(:thumb),
34
+ :large_url => m.image.url(:large)
35
+ },
36
+ :file => {
37
+ :file_name => m.file_file_name,
38
+ :content_type => m.file_content_type,
39
+ :file_size => m.file_file_size,
40
+ :update_at => m.file_updated_at,
41
+ :url => m.file.url
42
+ }
43
+ }
44
+ end
45
+ render :json => media2
46
+ end
47
+
48
+ # GET /admin/media/:mls_acct/files
49
+ def admin_files
50
+ return if !user_is_allowed('media', 'view')
51
+ media = Media.where(:mls_acct => params[:mls_acct], :media_type => 'File').reorder(:media_order).all
52
+ media2 = media.collect do |m|
53
+ {
54
+ :id => m.id,
55
+ :date_modified => m.date_modified,
56
+ :file_name => m.file_name,
57
+ :media_id => m.media_id,
58
+ :media_order => m.media_order,
59
+ :media_remarks => m.media_remarks,
60
+ :media_type => m.media_type,
61
+ :mls_acct => m.mls_acct,
62
+ :url => m.url,
63
+ :image => {
64
+ :file_name => m.image_file_name,
65
+ :content_type => m.image_content_type,
66
+ :file_size => m.image_file_size,
67
+ :update_at => m.image_updated_at,
68
+ :tiny_url => m.image.url(:tiny),
69
+ :thumb_url => m.image.url(:thumb),
70
+ :large_url => m.image.url(:large)
71
+ },
72
+ :file => {
73
+ :file_name => m.file_file_name,
74
+ :content_type => m.file_content_type,
75
+ :file_size => m.file_file_size,
76
+ :update_at => m.file_updated_at,
77
+ :url => m.file.url
78
+ }
79
+ }
80
+ end
81
+ render :json => media2
82
+ end
83
+
84
+ # GET /admin/media/:mls_acct/photos/new
85
+ def admin_new_photo
86
+ return if !user_is_allowed('media', 'edit')
87
+ render :layout => 'caboose/admin'
88
+ end
89
+
90
+ # GET /admin/media/:mls_acct/files/new
91
+ def admin_new_file
92
+ return if !user_is_allowed('media', 'edit')
93
+ render :layout => 'caboose/admin'
94
+ end
95
+
96
+ # POST /admin/media/:mls_acct/photos
97
+ def admin_add_photo
98
+ return if !user_is_allowed('media', 'edit')
99
+
100
+ x = Media.maximum(:media_order, :conditions => {:mls_acct => params[:mls_acct]})
101
+ x = 0 if x.nil?
102
+
103
+ m = Media.new
104
+ m.id = Media.maximum(:id) + 1
105
+ m.mls_acct = params[:mls_acct]
106
+ m.date_modified = DateTime.now
107
+ m.media_order = x + 1
108
+ m.media_type = 'Photo'
109
+ m.image = params[:image]
110
+ m.save
111
+
112
+ render :text => "<script type='text/javascript'>parent.controller.after_image_upload();</script>"
113
+ end
114
+
115
+ # POST /admin/media/:msl_acct/files
116
+ def admin_add_file
117
+ return if !user_is_allowed('media', 'edit')
118
+
119
+ m = Media.new
120
+ m.id = Media.maximum(:id) + 1
121
+ m.mls_acct = params[:mls_acct]
122
+ m.date_modified = DateTime.now
123
+ m.media_order = Media.maximum(:media_order, :conditions => [:mls_acct => params[:mls_acct]]) + 1
124
+ m.media_type = 'File'
125
+ m.file = params[:file]
126
+ m.save
127
+
128
+ render :text => "<script type='text/javascript'>parent.controller.after_file_upload();</script>"
129
+ end
130
+
131
+ # DELETE /admin/media/:id
132
+ def admin_delete
133
+ return if !user_is_allowed('media', 'delete')
134
+ Media.find(params[:id]).destroy
135
+ render :json => true
136
+ end
137
+
138
+ # PUT /admin/media/:mls_acct/order
139
+ def admin_update_order
140
+ return if !user_is_allowed('media', 'delete')
141
+ Media.reorder(params[:sort], "advantagerealtygroup")
142
+ render :json => true
143
+ end
144
+
145
+ end
146
+ end