Class: Carnival::BaseAdminController
- Inherits:
-
InheritedResources::Base
- Object
- InheritedResources::Base
- Carnival::BaseAdminController
show all
- Defined in:
- app/controllers/carnival/base_admin_controller.rb
Instance Method Summary
collapse
Instance Method Details
#create ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 81
def create
@model_presenter = instantiate_presenter
create! do |success, failure|
success.html{ redirect_to @model_presenter.model_path(:index), :notice => I18n.t("messages.created") }
failure.html do |render|
@model = instance_variable_get("@#{controller_name.classify.underscore}")
render '/carnival/shared/form/new'
end
end
end
|
#current_user ⇒ Object
116
117
118
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 116
def current_user
current_admin_user
end
|
#edit ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 67
def edit
@model_presenter = instantiate_presenter
edit! do |format|
@model = instance_variable_get("@#{controller_name.classify.underscore}")
format.html do |render|
render '/carnival/shared/form/edit'
end
end
end
|
#generate_datatable ⇒ Object
6
7
8
9
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 6
def generate_datatable
model_presenter = instantiate_presenter
Carnival::GenericDatatable.new(view_context, instantiate_model(model_presenter), self, model_presenter)
end
|
#index ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 11
def index
@datatable = generate_datatable
@advanced_search = params["advanced_search"] if params["advanced_search"].present?
if params[:special_scope].present?
presenter = @datatable.presenter
presenter.parse_special_scope params[:special_scope]
end
respond_to do |format|
format.html do |render|
render '/carnival/index'
end
format.json do |render|
render(json: @datatable)
end
format.csv do
render text: @datatable.as_csv.encode("utf-16le")
end
format.pdf do
render :pdf => t("#{@datatable.model.to_s.underscore}.lista") , :template => 'carnival/index.pdf.haml', :show_as_html => params[:debug].present?
end
end
end
|
#new ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 53
def new
@model_presenter = instantiate_presenter
new! do |format|
@model = instance_variable_get("@#{controller_name.classify.underscore}")
format.html do |render|
render '/carnival/shared/form/new'
end
end
end
|
111
112
113
114
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 111
def partial
@application_popup = partial
render 'layouts/shared/render_popup' and return
end
|
#show ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 40
def show
@model_presenter = instantiate_presenter
show! do |format|
format.html do |render|
render '/carnival/shared/form/show'
end
end
end
|
#update ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'app/controllers/carnival/base_admin_controller.rb', line 96
def update
@model_presenter = instantiate_presenter
update! do |success, failure|
success.html{ redirect_to @model_presenter.model_path(:index), :notice => I18n.t("messages.updated") }
failure.html do |render|
@model = instance_variable_get("@#{controller_name.classify.underscore}")
render '/carnival/shared/form/edit'
end
end
end
|