Class: CabooseRets::OfficesController

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

Instance Method Summary collapse

Instance Method Details

#admin_editObject

GET /admin/offices/:mls_number/edit



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

def admin_edit
  return if !user_is_allowed('offices', 'edit')    
  @office = Office.find(params[:id])      
  render :layout => 'caboose/admin'
end

#admin_indexObject

GET /admin/offices



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/caboose_rets/offices_controller.rb', line 10

def admin_index
  return if !user_is_allowed('offices', 'view')
    
  @gen = Caboose::PageBarGenerator.new(params, {
      'lo_mls_id'    => '',               
      'lo_name_like' => ''      	  
    },{
  	  'model'       => 'CabooseRets::Office',
      'sort'			  => 'lo_name',
  	  'desc'			  => false,
  	  'base_url'		=> '/admin/offices',
  	  'use_url_params'  => false
  })
  @offices = @gen.items    
  render :layout => 'caboose/admin'
end

#admin_optionsObject

GET /admin/offices/options



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/controllers/caboose_rets/offices_controller.rb', line 42

def admin_options
  options = [{
    'value' => '',
    'text' => '-- No Office --'
  }]
  Office.reorder('lo_name').all.each do |office|
    options << { 
      'value' => office.lo_code,
      'text'  => office.lo_name
    }
  end
  render :json => options 
end

#admin_refreshObject

GET /admin/offices/:mls_number/refresh



35
36
37
38
39
# File 'app/controllers/caboose_rets/offices_controller.rb', line 35

def admin_refresh
  office = Office.find(params[:id])        
  RetsImporter.import('Office', "(Matrix_Unique_ID=#{office.matrix_unique_id})")
  render :json => Caboose::StdClass.new({ 'success' => "The office's info has been updated from MLS." })                
end