mirror of
https://github.com/System-End/theseus.git
synced 2026-04-19 19:55:10 +00:00
i dunno, can you?
This commit is contained in:
parent
e5132db647
commit
0f8b36f7de
4 changed files with 14 additions and 2 deletions
|
|
@ -95,6 +95,8 @@ class Letter::BatchesController < BaseBatchesController
|
|||
|
||||
# Only require payment account if indicia is selected
|
||||
if letter_batch_params[:us_postage_type] == "indicia" || letter_batch_params[:intl_postage_type] == "indicia"
|
||||
authorize @batch, :process_batch_with_indicia?, policy_class: Letter::BatchPolicy
|
||||
|
||||
payment_account = USPS::PaymentAccount.find_by(id: letter_batch_params[:usps_payment_account_id])
|
||||
|
||||
if payment_account.nil?
|
||||
|
|
|
|||
|
|
@ -17,7 +17,13 @@ class Letter::BatchPolicy < ApplicationPolicy
|
|||
|
||||
alias_method :set_mapping?, :map_fields?
|
||||
alias_method :process_form?, :map_fields?
|
||||
|
||||
alias_method :process_batch?, :map_fields?
|
||||
|
||||
def process_batch_with_indicia?
|
||||
user.present? && user.can_use_indicia?
|
||||
end
|
||||
|
||||
alias_method :mark_printed?, :update?
|
||||
alias_method :mark_mailed?, :mark_printed?
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ class Letter::QueuePolicy < ApplicationPolicy
|
|||
user.present?
|
||||
end
|
||||
|
||||
alias_method :create_instant_letter?, :create_letter?
|
||||
def create_instant_letter?
|
||||
return false unless user.present?
|
||||
return true unless record.indicia?
|
||||
user.can_use_indicia?
|
||||
end
|
||||
|
||||
def batch?
|
||||
record_belongs_to_user || user_is_admin
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LetterPolicy < ApplicationPolicy
|
|||
end
|
||||
|
||||
def buy_indicia?
|
||||
record_belongs_to_user || user_is_admin
|
||||
user&.can_use_indicia? && (record_belongs_to_user || user_is_admin)
|
||||
end
|
||||
|
||||
def mark_printed?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue