[#2750] Make ProcedurePresentation checks private

This commit is contained in:
Frederic Merizen 2018-10-10 06:04:29 +02:00
parent 40a5ff0266
commit 026c322fce

View file

@ -12,36 +12,6 @@ class ProcedurePresentation < ApplicationRecord
validate :check_allowed_sort_column validate :check_allowed_sort_column
validate :check_allowed_filter_columns validate :check_allowed_filter_columns
def check_allowed_displayed_fields
displayed_fields.each do |field|
table = field['table']
column = field['column']
if !valid_column?(table, column)
errors.add(:filters, "#{table}.#{column} nest pas une colonne permise")
end
end
end
def check_allowed_sort_column
table = sort['table']
column = sort['column']
if !valid_sort_column?(table, column)
errors.add(:sort, "#{table}.#{column} nest pas une colonne permise")
end
end
def check_allowed_filter_columns
filters.each do |_, columns|
columns.each do |column|
table = column['table']
column = column['column']
if !valid_column?(table, column)
errors.add(:filters, "#{table}.#{column} nest pas une colonne permise")
end
end
end
end
def fields def fields
fields = [ fields = [
field_hash('Créé le', 'self', 'created_at'), field_hash('Créé le', 'self', 'created_at'),
@ -163,6 +133,36 @@ class ProcedurePresentation < ApplicationRecord
private private
def check_allowed_displayed_fields
displayed_fields.each do |field|
table = field['table']
column = field['column']
if !valid_column?(table, column)
errors.add(:filters, "#{table}.#{column} nest pas une colonne permise")
end
end
end
def check_allowed_sort_column
table = sort['table']
column = sort['column']
if !valid_sort_column?(table, column)
errors.add(:sort, "#{table}.#{column} nest pas une colonne permise")
end
end
def check_allowed_filter_columns
filters.each do |_, columns|
columns.each do |column|
table = column['table']
column = column['column']
if !valid_column?(table, column)
errors.add(:filters, "#{table}.#{column} nest pas une colonne permise")
end
end
end
end
def get_value(dossier, table, column) def get_value(dossier, table, column)
assert_valid_column(table, column) assert_valid_column(table, column)