Class: CabooseRets::RetsMediaController

Inherits:
ApplicationController show all
Defined in:
app/controllers/caboose_rets/rets_media_controller.rb

Instance Method Summary collapse

Instance Method Details

#admin_add_fileObject

POST /admin/properties/:msl_acct/files



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 55

def admin_add_file
  return if !user_is_allowed('media', 'edit')

  x = Media.maximum(:media_order, :conditions => {:mls => params[:mls], :media_type => 'File'})
  x = 0 if x.nil?      
              
  m = Media.new
  m.id            = Media.maximum(:id) + 1
  m.mls 		  = params[:mls]
  m.date_modified = DateTime.now                  
  m.media_order   = x + 1
  m.media_type 		= 'File'
  m.file          = params[:file]
  m.save
  
  render :text => "<script type='text/javascript'>parent.controller.after_file_upload();</script>"        
end

#admin_add_photoObject

POST /admin/properties/:mls/photos



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 36

def admin_add_photo
  return if !user_is_allowed('media', 'edit')      
        
  x = Media.maximum(:media_order, :conditions => {:mls => params[:mls], :media_type => 'Photo'})
  x = 0 if x.nil?
  
  m = Media.new
  m.id            = Media.maximum(:id) + 1
  m.mls 		  = params[:mls]
  m.date_modified = DateTime.now                  
  m.media_order   = x + 1
  m.media_type 		= 'Photo'
  m.image         = params[:image]
  m.save
  
  render :text => "<script type='text/javascript'>parent.controller.after_image_upload();</script>"                        
end

#admin_deleteObject

DELETE /admin/media/:id



74
75
76
77
78
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 74

def admin_delete
  return if !user_is_allowed('media', 'delete')
  Media.find(params[:id]).destroy            
  render :json => true
end

#admin_filesObject

GET /admin/properties/:mls/files



28
29
30
31
32
33
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 28

def admin_files
  return if !user_is_allowed('media', 'view')      
  media = Media.where(:mls => params[:mls], :media_type => 'File').reorder(:media_order).all
  media2 = media.collect { |m| media_hash(m) }      	      
  render :json => media2
end

#admin_indexObject

GET /admin/media/:id



6
7
8
9
10
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 6

def admin_index
  return if !user_is_allowed('media', 'view')
  m = Media.find(params[:id])
  render :json => media_hash(m)
end

#admin_photosObject

GET /admin/properties/:mls/photos



20
21
22
23
24
25
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 20

def admin_photos
  return if !user_is_allowed('media', 'view')      
  media = Media.where(:mls => params[:mls], :media_type => 'Photo').reorder(:media_order).all
  media2 = media.collect { |m| media_hash(m) }      	      
  render :json => media2
end

#admin_property_mediaObject

GET /admin/properties/:mls/media



13
14
15
16
17
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 13

def admin_property_media
  return if !user_is_allowed('media', 'view')      
  @property = CabooseRets.get_property(params[:mls])
  render :layout => 'caboose/admin'
end

#admin_update_orderObject

PUT /admin/properties/:mls/media/order



81
82
83
84
85
# File 'app/controllers/caboose_rets/rets_media_controller.rb', line 81

def admin_update_order
  return if !user_is_allowed('media', 'delete')      
  Media.reorder(params[:sort], "advantagerealtygroup")            
  render :json => true
end