Skip to content

Commit 40ec440

Browse files
committed
removes puts, fixes flags moderation error
1 parent b6ca8a6 commit 40ec440

File tree

6 files changed

+32
-39
lines changed

6 files changed

+32
-39
lines changed

app/controllers/rails_admin/main_controller.rb

+10-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ def redirect_to_on_success
112112
obj = @objects[session["index"]]
113113
@object.moderate= true
114114
redirect_to edit_path(:id => obj.id, :return_to => params[:return_to]), :flash => { :success => notice }
115+
elsif params[:_valid_another]
116+
@objects ||= list_entries(true)
117+
obj = @objects[session["index"]]
118+
@object.resolve true
119+
redirect_to edit_path(:id => obj.id, :return_to => params[:return_to]), :flash => { :success => notice }
120+
elsif params[:_invalid_another]
121+
@objects ||= list_entries(true)
122+
obj = @objects[session["index"]]
123+
@object.resolve false
124+
redirect_to edit_path(:id => obj.id, :return_to => params[:return_to]), :flash => { :success => notice }
115125
else
116126
redirect_to back_or_index, :flash => { :success => notice }
117127
end
@@ -160,9 +170,6 @@ def check_for_cancel
160170
end
161171

162172
def get_collection(is_edit, model_config, scope, pagination)
163-
puts "**" * 20
164-
puts "parameters"
165-
puts params[:f]
166173
or_filters = Hash.new
167174
if params[:f] != nil
168175
params[:f].each do |param|

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@
99
- if authorized? :new, @abstract_model
1010
%button.btn.btn-info{:type => "submit", :name => "_add_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
1111
= t("admin.form.save_and_add_another")
12-
- if authorized? :new, @abstract_model
12+
- if ((authorized? :new, @abstract_model) && (@abstract_model.pretty_name != "Flag"))
1313
%button.btn.btn-info{:type => "submit", :name => "_moderate_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
1414
= t("admin.form.moderate_and_moderate_another")
15+
- if ((authorized? :new, @abstract_model) && (@abstract_model.pretty_name == "Flag"))
16+
%button.btn.btn-info{:type => "submit", :name => "_valid_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
17+
= "Mark invalid and moderate another"
18+
- if ((authorized? :new, @abstract_model) && (@abstract_model.pretty_name == "Flag"))
19+
%button.btn.btn-info{:type => "submit", :name => "_invalid_another", :'data-disable-with' => t("admin.form.save_and_add_another")}
20+
= "Mark valid and moderate another"
1521
- if authorized? :edit, @abstract_model
1622
%button.btn.btn-info{:type => "submit", :name => "_moderate_another", :'data-disable-with' => t("admin.form.save_and_edit")}
1723
= t("admin.form.save_and_edit")
1824
%button.btn{:type => "submit", :name => "_continue", :'data-disable-with' => t("admin.form.cancel")}
1925
%i.icon-remove
2026
= t("admin.form.cancel")
27+
=@abstract_model.pretty_name

lib/rails_admin/adapters/mongoid.rb

+1-15
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ def all(options = {},scope=nil)
4444
fi = Hash.new
4545
fi["$gte"] = 3
4646
sc["popularity"] = fi
47-
#scope = scope.where(query_conditions(options[:query])) if options[:query]
48-
#scope = scope.where() if options[:filters]
49-
puts "--" * 20
5047

5148
y = filter_conditions(options[:filters]) if options[:filters]
52-
puts y
5349
mappings = {"created_on" => "created_at"}
5450
if options[:filters]
5551
if(y["$and"])
@@ -76,22 +72,16 @@ def all(options = {},scope=nil)
7672
if options[:filters]
7773
x["$and"] = ze if !ze.empty?
7874
end
79-
puts x
8075
or_filters = options[:or_filters]
81-
puts "or filters"
82-
puts or_filters
8376
or_hash = Hash.new
8477
or_conditions = Array.new
8578
second_filter = Hash.new
8679
second_filter["$and"] = Array.new
8780
if or_filters != nil
8881
i = 0
8982
or_filters.each do |o|
90-
puts o
9183
o[0] = o[0][3,o[0].length]
9284
condition = filter_conditions({o[0] => or_filters["OR " + o[0]]})
93-
puts "CONDITION"
94-
puts condition
9585
condition["$and"].each do |c|
9686
second_filter["$and"][i] = c
9787
i = i + 1
@@ -100,10 +90,7 @@ def all(options = {},scope=nil)
10090
#or_hash["$or"][i] = condition["$and"][0]
10191
end
10292
end
103-
puts "first filter"
104-
puts x
105-
puts "second filter"
106-
puts second_filter
93+
10794
full_filter = Array.new
10895
if x != nil
10996
full_filter[0] = x if x["$and"] != [] && options[:filters]
@@ -113,7 +100,6 @@ def all(options = {},scope=nil)
113100
end
114101
final = Hash.new
115102
final["$or"] = full_filter
116-
puts final
117103
scope = scope.where(final) if final["$or"] != []
118104
if options[:page] && options[:per]
119105
scope = scope.send(Kaminari.config.page_method_name, options[:page]).per(options[:per])

lib/rails_admin/config/actions/edit.rb

+13-9
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,23 @@ class Edit < RailsAdmin::Config::Actions::Base
3535
@authorization_adapter && @authorization_adapter.attributes_for(:update, @abstract_model).each do |name, value|
3636
@object.send("#{name}=", value)
3737
end
38-
39-
if @object.save
40-
@auditing_adapter && @auditing_adapter.update_object(@abstract_model, @object, @cached_assocations_hash, associations_hash, @modified_assoc, @old_object, _current_user)
41-
respond_to do |format|
42-
format.html { redirect_to_on_success }
43-
format.js { render :json => { :id => @object.id, :label => @model_config.with(:object => @object).object_label } }
38+
if !(params[:_invalid_another] || params[:_valid_another])
39+
if @object.save
40+
@auditing_adapter && @auditing_adapter.update_object(@abstract_model, @object, @cached_assocations_hash, associations_hash, @modified_assoc, @old_object, _current_user)
41+
respond_to do |format|
42+
format.html { redirect_to_on_success }
43+
format.js { render :json => { :id => @object.id, :label => @model_config.with(:object => @object).object_label } }
44+
end
45+
else
46+
handle_save_error :edit
4447
end
4548
else
46-
handle_save_error :edit
49+
respond_to do |format|
50+
format.html { redirect_to_on_success }
51+
format.js { render :json => { :id => @object.id, :label => @model_config.with(:object => @object).object_label } }
52+
end
4753
end
48-
4954
end
50-
5155
end
5256
end
5357

lib/rails_admin/config/actions/merge_items.rb

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ class MergeItems < RailsAdmin::Config::Actions::Base
2525
render @action.template_name
2626

2727
elsif request.delete? # BULK DESTROY
28-
puts "##" * 20
29-
puts "merge"
3028

3129
merge(@objects[0],@objects[1],{safe: false}) if params[:master] == @objects[0].to_s
3230
merge(@objects[1],@objects[0], {safe: false}) unless params[:master] == @objects[0].to_s

lib/rails_admin/config/has_fields.rb

-9
Original file line numberDiff line numberDiff line change
@@ -115,38 +115,29 @@ def visible_fields
115115
end
116116

117117
def extract_specs
118-
puts "**" * 10
119-
puts "EXTRACTING SPECS"
120118
fields = visible_fields
121119
specs = Array.new
122120
fields.each do |f|
123-
puts f.name.to_s
124121
splitted_specs = f.name.to_s.split("\/")
125122
specs << splitted_specs[0] if ((splitted_specs.count > 1) && (!specs.include? splitted_specs[0]))
126123
end
127-
puts specs.count
128124
specs
129125
end
130126

131127

132128
def spec_fields spec
133129
i = 0
134-
puts "*" * 200
135-
puts "SPEC FIELDS"
136130
specs = Array.new
137131
fields = all_fields.map {|f| f.with(bindings) }.select(&:visible?).sort_by{|f| [f.order, i += 1] } # stable sort, damn
138132
fields.each do |f|
139133
splitted_specs = f.name.to_s.split("\/")
140134
specs << f if splitted_specs[0].to_s == spec.to_s
141-
puts splitted_specs[1]
142135
end
143136
specs
144137
end
145138

146139
def new_fields
147140
i = 0
148-
puts "*" * 200
149-
puts "NEW FIELDS"
150141
fields = all_fields.map {|f| f.with(bindings) }.select(&:visible?).sort_by{|f| [f.order, i += 1] } # stable sort, damn
151142
end
152143

0 commit comments

Comments
 (0)