[#3477] Remove clunky extra method

This commit is contained in:
Frederic Merizen 2019-03-04 17:21:48 +01:00
parent f64ade355f
commit 656f0df377

View file

@ -171,7 +171,7 @@ class ProcedurePresentation < ApplicationRecord
def check_allowed_sort_column
table = sort['table']
column = sort['column']
if !valid_sort_column?(table, column)
if !valid_column?(table, column, EXTRA_SORT_COLUMNS)
errors.add(:sort, "#{table}.#{column} nest pas une colonne permise")
end
end
@ -222,8 +222,9 @@ class ProcedurePresentation < ApplicationRecord
}
end
def valid_column?(table, column)
valid_columns_for_table(table).include?(column)
def valid_column?(table, column, extra_columns = {})
valid_columns_for_table(table).include?(column) ||
extra_columns[table]&.include?(column)
end
def valid_columns_for_table(table)
@ -244,8 +245,4 @@ class ProcedurePresentation < ApplicationRecord
def dossier_field_service
@dossier_field_service ||= DossierFieldService.new
end
def valid_sort_column?(table, column)
valid_column?(table, column) || EXTRA_SORT_COLUMNS[table]&.include?(column)
end
end