Skip to content

Commit 216539b

Browse files
committed
adds moderate another action
1 parent 1bb8d05 commit 216539b

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

app/controllers/rails_admin/main_controller.rb

+16
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,26 @@ def redirect_to_on_success
9696
redirect_to new_path(:return_to => params[:return_to]), :flash => { :success => notice }
9797
elsif params[:_add_edit]
9898
redirect_to edit_path(:id => @object.id, :return_to => params[:return_to]), :flash => { :success => notice }
99+
elsif params[:_moderate_another]
100+
@object.mark_moderated
101+
@objects ||= list_entries
102+
obj = get_object_index(@objects,@object)
103+
redirect_to edit_path(:id => obj.id, :return_to => params[:return_to]), :flash => { :success => notice }
99104
else
100105
redirect_to back_or_index, :flash => { :success => notice }
101106
end
102107
end
108+
def get_object_index my_objects, object
109+
i = 0
110+
index = -1
111+
@objects.each do |obj|
112+
if obj.id == object.id
113+
index = i + 1
114+
end
115+
i = i + 1
116+
end
117+
@objects[index]
118+
end
103119

104120
def sanitize_params_for!(action, model_config = @model_config, _params = params[@abstract_model.param_key])
105121
return unless _params.present?

app/views/rails_admin/main/_submit_buttons.html.haml

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
- if authorized? :new, @abstract_model
88
%button.btn.btn-info{:type => "submit", :name => "_add_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
99
= t("admin.form.save_and_add_another")
10+
- if authorized? :new, @abstract_model
11+
%button.btn.btn-info{:type => "submit", :name => "_moderate_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
12+
= t("admin.form.moderate_and_moderate_another")
1013
- if authorized? :edit, @abstract_model
11-
%button.btn.btn-info{:type => "submit", :name => "_add_edit", :'data-disable-with' => t("admin.form.save_and_edit")}
14+
%button.btn.btn-info{:type => "submit", :name => "_moderate_another", :'data-disable-with' => t("admin.form.save_and_edit")}
1215
= t("admin.form.save_and_edit")
1316
%button.btn{:type => "submit", :name => "_continue", :'data-disable-with' => t("admin.form.cancel")}
1417
%i.icon-remove

config/locales/rails_admin.en.yml

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ en:
113113
char_length_of: "length of"
114114
save: "Save"
115115
save_and_add_another: "Save and add another"
116+
moderate_and_moderate_another: "Mark moderated and moderate another"
116117
save_and_edit: "Save and edit"
117118
all_of_the_following_related_items_will_be_deleted: "? The following related items may be deleted or orphaned:"
118119
are_you_sure_you_want_to_delete_the_object: "Are you sure you want to delete this %{model_name}"

lib/rails_admin/config/actions/index.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ class Index < RailsAdmin::Config::Actions::Base
2727

2828
register_instance_option :controller do
2929
Proc.new do
30+
puts "INDEX called "
31+
puts "*" * 100
3032
@objects ||= list_entries
31-
@omzey = "ana hena"
3233

3334
respond_to do |format|
3435

0 commit comments

Comments
 (0)