diff --git a/app/controllers/spree/admin/reports/enterprise_fee_summary_report_controller.rb b/app/controllers/spree/admin/reports/enterprise_fee_summary_report_controller.rb index c990a5199d..cd443f8b23 100644 --- a/app/controllers/spree/admin/reports/enterprise_fee_summary_report_controller.rb +++ b/app/controllers/spree/admin/reports/enterprise_fee_summary_report_controller.rb @@ -1,5 +1,6 @@ require "open_food_network/reports" require "order_management/reports/enterprise_fee_summary/parameters" +require "order_management/reports/enterprise_fee_summary/report_authorizer" require "order_management/reports/enterprise_fee_summary/report_service" require "order_management/reports/enterprise_fee_summary/renderers/csv_renderer" @@ -8,6 +9,7 @@ module Spree module Reports class EnterpriseFeeSummaryReportController < BaseController before_filter :load_report_parameters, only: [:index] + before_filter :load_report_authorizer, only: [:index] def index return render_report_form if params[:report].blank? @@ -40,6 +42,10 @@ module Spree @report_parameters = report_klass::Parameters.new(params[:report] || {}) end + def load_report_authorizer + @report_authorizer = report_klass::ReportAuthorizer.new(spree_current_user) + end + def report_renderer_klass case params[:report_format] when "csv" diff --git a/app/views/spree/admin/reports/enterprise_fee_summary_report/_filters.html.haml b/app/views/spree/admin/reports/enterprise_fee_summary_report/_filters.html.haml index f4c5db1f56..25c9a2eed4 100644 --- a/app/views/spree/admin/reports/enterprise_fee_summary_report/_filters.html.haml +++ b/app/views/spree/admin/reports/enterprise_fee_summary_report/_filters.html.haml @@ -16,31 +16,31 @@ .row .sixteen.columns.alpha = f.label :distributor_ids - = f.collection_select(:distributor_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:distributor_ids, @report_authorizer.allowed_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row .sixteen.columns.alpha = f.label :producer_ids - = f.collection_select(:producer_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:producer_ids, @report_authorizer.allowed_producers, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row .sixteen.columns.alpha = f.label :order_cycle_ids - = f.collection_select(:order_cycle_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:order_cycle_ids, @report_authorizer.allowed_order_cycles, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row .eight.columns.alpha = f.label :enterprise_fee_ids - = f.collection_select(:enterprise_fee_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:enterprise_fee_ids, @report_authorizer.allowed_enterprise_fees, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .eight.columns.omega = f.label :shipping_method_ids - = f.collection_select(:shipping_method_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:shipping_method_ids, @report_authorizer.allowed_shipping_methods, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row .eight.columns.alpha   .eight.columns.omega = f.label :payment_method_ids - = f.collection_select(:payment_method_ids, [], :id, :name, {}, {class: "select2 fullwidth", multiple: true}) + = f.collection_select(:payment_method_ids, @report_authorizer.allowed_payment_methods, :id, :name, {}, {class: "select2 fullwidth", multiple: true}) .row .sixteen.columns.alpha diff --git a/lib/open_food_network/reports/report_authorizer.rb b/lib/open_food_network/reports/report_authorizer.rb new file mode 100644 index 0000000000..88225a26f5 --- /dev/null +++ b/lib/open_food_network/reports/report_authorizer.rb @@ -0,0 +1,11 @@ +module OpenFoodNetwork + module Reports + class ReportAuthorizer + attr_accessor :user + + def initialize(user) + @user = user + end + end + end +end diff --git a/lib/order_management/reports/enterprise_fee_summary/report_authorizer.rb b/lib/order_management/reports/enterprise_fee_summary/report_authorizer.rb new file mode 100644 index 0000000000..74ce7288b9 --- /dev/null +++ b/lib/order_management/reports/enterprise_fee_summary/report_authorizer.rb @@ -0,0 +1,33 @@ +require "open_food_network/reports/report_authorizer" + +module OrderManagement + module Reports + module EnterpriseFeeSummary + class ReportAuthorizer < OpenFoodNetwork::Reports::ReportAuthorizer + def allowed_distributors + [] + end + + def allowed_producers + [] + end + + def allowed_order_cycles + [] + end + + def allowed_enterprise_fees + [] + end + + def allowed_shipping_methods + [] + end + + def allowed_payment_methods + [] + end + end + end + end +end