mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Rename report authorizers to reflect permissions
This commit is contained in:
@@ -1,6 +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/permissions"
|
||||
require "order_management/reports/enterprise_fee_summary/report_service"
|
||||
require "order_management/reports/enterprise_fee_summary/renderers/csv_renderer"
|
||||
require "order_management/reports/enterprise_fee_summary/renderers/html_renderer"
|
||||
@@ -10,7 +10,7 @@ module Spree
|
||||
module Reports
|
||||
class EnterpriseFeeSummaryReportController < BaseController
|
||||
before_filter :load_report_parameters, only: [:index]
|
||||
before_filter :load_report_authorizer, only: [:index]
|
||||
before_filter :load_permissions, only: [:index]
|
||||
|
||||
def index
|
||||
return render_report_form if params[:report].blank?
|
||||
@@ -43,8 +43,8 @@ module Spree
|
||||
@report_parameters = report_klass::Parameters.new(params[:report] || {})
|
||||
end
|
||||
|
||||
def load_report_authorizer
|
||||
@report_authorizer = report_klass::ReportAuthorizer.new(spree_current_user)
|
||||
def load_permissions
|
||||
@permissions = report_klass::Permissions.new(spree_current_user)
|
||||
end
|
||||
|
||||
def render_report
|
||||
|
||||
@@ -16,31 +16,31 @@
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :distributor_ids
|
||||
= f.collection_select(:distributor_ids, @report_authorizer.allowed_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:distributor_ids, @permissions.allowed_distributors, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :producer_ids
|
||||
= f.collection_select(:producer_ids, @report_authorizer.allowed_producers, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:producer_ids, @permissions.allowed_producers, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
= f.label :order_cycle_ids
|
||||
= f.collection_select(:order_cycle_ids, @report_authorizer.allowed_order_cycles, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:order_cycle_ids, @permissions.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, @report_authorizer.allowed_enterprise_fees, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:enterprise_fee_ids, @permissions.allowed_enterprise_fees, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
.eight.columns.omega
|
||||
= f.label :shipping_method_ids
|
||||
= f.collection_select(:shipping_method_ids, @report_authorizer.allowed_shipping_methods, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:shipping_method_ids, @permissions.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, @report_authorizer.allowed_payment_methods, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
= f.collection_select(:payment_method_ids, @permissions.allowed_payment_methods, :id, :name, {}, {class: "select2 fullwidth", multiple: true})
|
||||
|
||||
.row
|
||||
.sixteen.columns.alpha
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module OpenFoodNetwork
|
||||
module Reports
|
||||
class ReportAuthorizer
|
||||
class Permissions
|
||||
attr_accessor :user
|
||||
|
||||
def initialize(user)
|
||||
@@ -1,9 +1,9 @@
|
||||
require "open_food_network/reports/report_authorizer"
|
||||
require "open_food_network/reports/permissions"
|
||||
|
||||
module OrderManagement
|
||||
module Reports
|
||||
module EnterpriseFeeSummary
|
||||
class ReportAuthorizer < OpenFoodNetwork::Reports::ReportAuthorizer
|
||||
class Permissions < OpenFoodNetwork::Reports::Permissions
|
||||
def allowed_order_cycles
|
||||
@allowed_order_cycles ||= OrderCycle.accessible_by(user)
|
||||
end
|
||||
@@ -1,8 +1,8 @@
|
||||
require "spec_helper"
|
||||
|
||||
require "order_management/reports/enterprise_fee_summary/report_authorizer"
|
||||
require "order_management/reports/enterprise_fee_summary/permissions"
|
||||
|
||||
describe OrderManagement::Reports::EnterpriseFeeSummary::ReportAuthorizer do
|
||||
describe OrderManagement::Reports::EnterpriseFeeSummary::Permissions do
|
||||
let!(:order_cycle) { create(:simple_order_cycle) }
|
||||
let!(:incoming_exchange) { create(:exchange, incoming: true, order_cycle: order_cycle) }
|
||||
let!(:outgoing_exchange) { create(:exchange, incoming: false, order_cycle: order_cycle) }
|
||||
Reference in New Issue
Block a user