adjust folder query
This commit is contained in:
@@ -112,9 +112,9 @@ module Api
|
|||||||
submissions = submissions.where(slug: params[:slug]) if params[:slug].present?
|
submissions = submissions.where(slug: params[:slug]) if params[:slug].present?
|
||||||
|
|
||||||
if params[:template_folder].present?
|
if params[:template_folder].present?
|
||||||
folder = TemplateFolder.accessible_by(current_ability).find_by(name: params[:template_folder])
|
folder_ids = TemplateFolder.accessible_by(current_ability).where(name: params[:template_folder]).pluck(:id)
|
||||||
|
|
||||||
submissions = folder ? submissions.joins(:template).where(template: { folder_id: folder.id }) : submissions.none
|
submissions = submissions.joins(:template).where(template: { folder_id: folder_ids })
|
||||||
end
|
end
|
||||||
|
|
||||||
if params.key?(:archived)
|
if params.key?(:archived)
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ module Api
|
|||||||
templates = templates.where(slug: params[:slug]) if params[:slug].present?
|
templates = templates.where(slug: params[:slug]) if params[:slug].present?
|
||||||
|
|
||||||
if params[:folder].present?
|
if params[:folder].present?
|
||||||
folder = TemplateFolder.accessible_by(current_ability).find_by(name: params[:folder])
|
folder_ids = TemplateFolder.accessible_by(current_ability).where(name: params[:folder]).pluck(:id)
|
||||||
|
|
||||||
templates = folder ? templates.where(folder:) : templates.none
|
templates = templates.where(folder_id: folder_ids)
|
||||||
end
|
end
|
||||||
|
|
||||||
templates
|
templates
|
||||||
|
|||||||
Reference in New Issue
Block a user