Merge pull request #7119 from opf/fix/parent-sort

Return error on invalid query in work packages export

[ci skip]
pull/7128/head
Oliver Günther 6 years ago committed by GitHub
commit 969b0fbf80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      app/controllers/work_packages_controller.rb

@ -40,7 +40,7 @@ class WorkPackagesController < ApplicationController
before_action :find_optional_project,
:protect_from_unauthorized_export, only: :index
before_action :load_query, only: :index, unless: ->() { request.format.html? }
before_action :load_and_validate_query, only: :index, unless: ->() { request.format.html? }
before_action :load_work_packages, only: :index, if: ->() { request.format.atom? }
before_action :set_gon_settings
@ -143,8 +143,15 @@ class WorkPackagesController < ApplicationController
%w[atom rss] + WorkPackage::Exporter.list_formats.map(&:to_s)
end
def load_query
def load_and_validate_query
@query ||= retrieve_query
unless @query.valid?
# Ensure outputting a html response
request.format = 'html'
return render_400(message: @query.errors.full_messages.join(". "))
end
rescue ActiveRecord::RecordNotFound
render_404
end

Loading…
Cancel
Save