diff --git a/app/controllers/spree/admin/reports/enterprise_fee_summaries_controller.rb b/app/controllers/spree/admin/reports/enterprise_fee_summaries_controller.rb deleted file mode 100644 index e6b750b904..0000000000 --- a/app/controllers/spree/admin/reports/enterprise_fee_summaries_controller.rb +++ /dev/null @@ -1,66 +0,0 @@ -module Spree - module Admin - module Reports - class EnterpriseFeeSummariesController < BaseController - before_filter :load_report_parameters - before_filter :load_permissions - - def new; end - - def create - return respond_to_invalid_parameters unless @report_parameters.valid? - - @report_parameters.authorize!(@permissions) - - @report = report_klass::ReportService.new(@permissions, @report_parameters) - renderer.render(self) - rescue ::Reports::Authorizer::ParameterNotAllowedError => e - flash[:error] = e.message - render_report_form - end - - private - - def respond_to_invalid_parameters - flash[:error] = I18n.t("invalid_filter_parameters", scope: i18n_scope) - render_report_form - end - - def i18n_scope - "order_management.reports.enterprise_fee_summary" - end - - def render_report_form - render action: :new - end - - def report_klass - OrderManagement::Reports::EnterpriseFeeSummary - end - - def load_report_parameters - @report_parameters = report_klass::Parameters.new(params[:report] || {}) - end - - def load_permissions - @permissions = report_klass::Permissions.new(spree_current_user) - end - - def report_renderer_klass - case params[:report_format] - when "csv" - report_klass::Renderers::CsvRenderer - when nil, "", "html" - report_klass::Renderers::HtmlRenderer - else - raise Reports::UnsupportedReportFormatException - end - end - - def renderer - @renderer ||= report_renderer_klass.new(@report) - end - end - end - end -end diff --git a/engines/order_management/app/controllers/order_management/reports/enterprise_fee_summaries_controller.rb b/engines/order_management/app/controllers/order_management/reports/enterprise_fee_summaries_controller.rb new file mode 100644 index 0000000000..08b6c602c5 --- /dev/null +++ b/engines/order_management/app/controllers/order_management/reports/enterprise_fee_summaries_controller.rb @@ -0,0 +1,64 @@ +module OrderManagement + module Reports + class EnterpriseFeeSummariesController < Spree::Admin::BaseController + before_filter :load_report_parameters + before_filter :load_permissions + + def new; end + + def create + return respond_to_invalid_parameters unless @report_parameters.valid? + + @report_parameters.authorize!(@permissions) + + @report = report_klass::ReportService.new(@permissions, @report_parameters) + renderer.render(self) + rescue ::Reports::Authorizer::ParameterNotAllowedError => e + flash[:error] = e.message + render_report_form + end + + private + + def respond_to_invalid_parameters + flash[:error] = I18n.t("invalid_filter_parameters", scope: i18n_scope) + render_report_form + end + + def i18n_scope + "order_management.reports.enterprise_fee_summary" + end + + def render_report_form + render action: :new + end + + def report_klass + OrderManagement::Reports::EnterpriseFeeSummary + end + + def load_report_parameters + @report_parameters = report_klass::Parameters.new(params[:report] || {}) + end + + def load_permissions + @permissions = report_klass::Permissions.new(spree_current_user) + end + + def report_renderer_klass + case params[:report_format] + when "csv" + report_klass::Renderers::CsvRenderer + when nil, "", "html" + report_klass::Renderers::HtmlRenderer + else + raise Reports::UnsupportedReportFormatException + end + end + + def renderer + @renderer ||= report_renderer_klass.new(@report) + end + end + end +end diff --git a/app/views/spree/admin/reports/enterprise_fee_summaries/_filters.html.haml b/engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/_filters.html.haml similarity index 100% rename from app/views/spree/admin/reports/enterprise_fee_summaries/_filters.html.haml rename to engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/_filters.html.haml diff --git a/app/views/spree/admin/reports/enterprise_fee_summaries/_report.html.haml b/engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/_report.html.haml similarity index 100% rename from app/views/spree/admin/reports/enterprise_fee_summaries/_report.html.haml rename to engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/_report.html.haml diff --git a/app/views/spree/admin/reports/enterprise_fee_summaries/create.html.haml b/engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/create.html.haml similarity index 100% rename from app/views/spree/admin/reports/enterprise_fee_summaries/create.html.haml rename to engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/create.html.haml diff --git a/app/views/spree/admin/reports/enterprise_fee_summaries/new.html.haml b/engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/new.html.haml similarity index 100% rename from app/views/spree/admin/reports/enterprise_fee_summaries/new.html.haml rename to engines/order_management/app/views/order_management/reports/enterprise_fee_summaries/new.html.haml diff --git a/spec/controllers/spree/admin/reports/enterprise_fee_summaries_controller_spec.rb b/engines/order_management/spec/controllers/order_management/reports/enterprise_fee_summaries_controller_spec.rb similarity index 94% rename from spec/controllers/spree/admin/reports/enterprise_fee_summaries_controller_spec.rb rename to engines/order_management/spec/controllers/order_management/reports/enterprise_fee_summaries_controller_spec.rb index d9d8962f9b..3282bd7258 100644 --- a/spec/controllers/spree/admin/reports/enterprise_fee_summaries_controller_spec.rb +++ b/engines/order_management/spec/controllers/order_management/reports/enterprise_fee_summaries_controller_spec.rb @@ -1,6 +1,6 @@ require "spec_helper" -describe Spree::Admin::Reports::EnterpriseFeeSummariesController, type: :controller do +describe OrderManagement::Reports::EnterpriseFeeSummariesController, type: :controller do let(:report_klass) { OrderManagement::Reports::EnterpriseFeeSummary } let!(:distributor) { create(:distributor_enterprise) } @@ -76,6 +76,6 @@ describe Spree::Admin::Reports::EnterpriseFeeSummariesController, type: :control end def new_template_path - "spree/admin/reports/enterprise_fee_summaries/new" + "order_management/reports/enterprise_fee_summaries/new" end end