mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Base filter options from initial authorizer object
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
11
lib/open_food_network/reports/report_authorizer.rb
Normal file
11
lib/open_food_network/reports/report_authorizer.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
module OpenFoodNetwork
|
||||
module Reports
|
||||
class ReportAuthorizer
|
||||
attr_accessor :user
|
||||
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user