Class: Sunrise::ManagerController

Inherits:
ApplicationController show all
Includes:
Utils::SearchWrapper
Defined in:
app/controllers/sunrise/manager_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



39
40
41
42
# File 'app/controllers/sunrise/manager_controller.rb', line 39

def create
  @record.update(model_params)
  respond_with(@record, location: redirect_after_update(@record))
end

#destroy ⇒ Object



55
56
57
58
# File 'app/controllers/sunrise/manager_controller.rb', line 55

def destroy
  @record.destroy
  respond_with(@record, location: scoped_index_path)
end

#edit ⇒ Object



44
45
46
47
48
# File 'app/controllers/sunrise/manager_controller.rb', line 44

def edit
  respond_with(@record) do |format|
    format.html { render_with_scope }
  end
end

#export ⇒ Object



60
61
62
63
64
65
66
67
68
# File 'app/controllers/sunrise/manager_controller.rb', line 60

def export
  @records = abstract_model.apply_scopes(params, false)

  respond_to do |format|
    format.xml  { render xml: @records }
    format.json { render json: @records }
    format.csv  { render abstract_model.export_options.merge(csv: @records) }
  end
end

#import ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'app/controllers/sunrise/manager_controller.rb', line 70

def import
  return render plain: 'Unacceptable', status: 422 unless import_possible?

  @files = import_process_uploaded_files

  respond_to do |format|
    format.html { redirect_to scoped_index_path }
    format.json do
      render json: { files: @files }
    end
  end
end

#index ⇒ Object



17
18
19
20
21
22
23
# File 'app/controllers/sunrise/manager_controller.rb', line 17

def index
  @records = abstract_model.apply_scopes(params)

  respond_with(@records) do |format|
    format.html { render_with_scope(abstract_model.current_list) }
  end
end

#mass_destroy ⇒ Object



92
93
94
95
96
97
98
99
# File 'app/controllers/sunrise/manager_controller.rb', line 92

def mass_destroy
  abstract_model.destroy_all(params)

  respond_to do |format|
    format.html { redirect_to redirect_after_update }
    format.json { render json: params }
  end
end

#new ⇒ Object



31
32
33
34
35
36
37
# File 'app/controllers/sunrise/manager_controller.rb', line 31

def new
  @record.assign_attributes(abstract_model.permit_model_params)

  respond_with(@record) do |format|
    format.html { render_with_scope }
  end
end

#show ⇒ Object



25
26
27
28
29
# File 'app/controllers/sunrise/manager_controller.rb', line 25

def show
  respond_with(@record) do |format|
    format.html { render_with_scope }
  end
end

#sort ⇒ Object



83
84
85
86
87
88
89
90
# File 'app/controllers/sunrise/manager_controller.rb', line 83

def sort
  abstract_model.update_sort(params)

  respond_to do |format|
    format.html { redirect_to redirect_after_update }
    format.json { render json: params }
  end
end

#update ⇒ Object



50
51
52
53
# File 'app/controllers/sunrise/manager_controller.rb', line 50

def update
  @record.update(model_params)
  respond_with(@record, location: redirect_after_update(@record))
end