2023-10-19 17:33:40 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class LowStockNotification < BaseNotification
|
2023-11-24 21:58:46 +08:00
|
|
|
def self.subtype
|
2023-10-19 17:33:40 +08:00
|
|
|
:item_low_stock_reminder
|
|
|
|
end
|
|
|
|
|
2023-11-21 21:21:55 +08:00
|
|
|
def title
|
2023-12-11 20:18:08 +08:00
|
|
|
I18n.t(
|
|
|
|
'notifications.content.item_low_stock_reminder.message_html',
|
|
|
|
repository_row_name: subject.name,
|
|
|
|
repository: repository.name
|
|
|
|
)
|
2023-11-21 21:21:55 +08:00
|
|
|
end
|
2023-10-19 17:33:40 +08:00
|
|
|
|
|
|
|
def subject
|
|
|
|
RepositoryRow.find(params[:repository_row_id])
|
2023-12-11 18:28:24 +08:00
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
NonExistantRecord.new(params[:repository_row_name])
|
2023-10-19 17:33:40 +08:00
|
|
|
end
|
2023-12-04 21:13:16 +08:00
|
|
|
|
|
|
|
def repository
|
2023-12-11 18:28:24 +08:00
|
|
|
Repository.find(params[:repository_id])
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
NonExistantRecord.new(params[:repository_name])
|
2023-12-04 21:13:16 +08:00
|
|
|
end
|
2023-10-19 17:33:40 +08:00
|
|
|
end
|