[#3477] Extract helper method
This commit is contained in:
parent
656f0df377
commit
e8747f7c38
1 changed files with 11 additions and 15 deletions
|
@ -160,20 +160,12 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
|
|
||||||
def check_allowed_displayed_fields
|
def check_allowed_displayed_fields
|
||||||
displayed_fields.each do |field|
|
displayed_fields.each do |field|
|
||||||
table = field['table']
|
check_allowed_field(:displayed_fields, field)
|
||||||
column = field['column']
|
|
||||||
if !valid_column?(table, column)
|
|
||||||
errors.add(:displayed_fields, "#{table}.#{column} n’est pas une colonne permise")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_allowed_sort_column
|
def check_allowed_sort_column
|
||||||
table = sort['table']
|
check_allowed_field(:sort, sort, EXTRA_SORT_COLUMNS)
|
||||||
column = sort['column']
|
|
||||||
if !valid_column?(table, column, EXTRA_SORT_COLUMNS)
|
|
||||||
errors.add(:sort, "#{table}.#{column} n’est pas une colonne permise")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_allowed_sort_order
|
def check_allowed_sort_order
|
||||||
|
@ -186,15 +178,19 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
def check_allowed_filter_columns
|
def check_allowed_filter_columns
|
||||||
filters.each do |_, columns|
|
filters.each do |_, columns|
|
||||||
columns.each do |column|
|
columns.each do |column|
|
||||||
table = column['table']
|
check_allowed_field(:filters, column)
|
||||||
column = column['column']
|
|
||||||
if !valid_column?(table, column)
|
|
||||||
errors.add(:filters, "#{table}.#{column} n’est pas une colonne permise")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_allowed_field(kind, field, extra_columns = {})
|
||||||
|
table = field['table']
|
||||||
|
column = field['column']
|
||||||
|
if !valid_column?(table, column, extra_columns)
|
||||||
|
errors.add(kind, "#{table}.#{column} n’est pas une colonne permise")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def assert_matching_procedure(dossier)
|
def assert_matching_procedure(dossier)
|
||||||
if dossier.procedure != procedure
|
if dossier.procedure != procedure
|
||||||
raise "Procedure mismatch (expected #{procedure.id}, got #{dossier.procedure.id})"
|
raise "Procedure mismatch (expected #{procedure.id}, got #{dossier.procedure.id})"
|
||||||
|
|
Loading…
Reference in a new issue