From 0c705e2f04baa49e46d1296e437454816cb72e54 Mon Sep 17 00:00:00 2001 From: fosterfarrell9 <28628554+fosterfarrell9@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:05:39 +0200 Subject: [PATCH] Rename remaining occurences of sort attribute of voucher to role --- app/models/redemption.rb | 2 +- app/models/voucher.rb | 6 +++--- app/services/voucher_processor.rb | 2 +- app/views/vouchers/verify.js.erb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/redemption.rb b/app/models/redemption.rb index 18940376a..190a3aa94 100644 --- a/app/models/redemption.rb +++ b/app/models/redemption.rb @@ -11,7 +11,7 @@ class Redemption < ApplicationRecord source_type: "Talk" delegate :lecture, to: :voucher - delegate :sort, to: :voucher + delegate :role, to: :voucher delegate :tutor?, to: :voucher delegate :editor?, to: :voucher delegate :teacher?, to: :voucher diff --git a/app/models/voucher.rb b/app/models/voucher.rb index 813bf0862..45a7f9584 100644 --- a/app/models/voucher.rb +++ b/app/models/voucher.rb @@ -19,9 +19,9 @@ class Voucher < ApplicationRecord where("expires_at > ? AND invalidated_at IS NULL", Time.zone.now) } - scope :for_tutors, -> { where(sort: :tutor) } - scope :for_editors, -> { where(sort: :editor) } - scope :for_speakers, -> { where(sort: :speaker) } + scope :for_tutors, -> { where(role: :tutor) } + scope :for_editors, -> { where(role: :editor) } + scope :for_speakers, -> { where(role: :speaker) } self.implicit_order_column = "created_at" diff --git a/app/services/voucher_processor.rb b/app/services/voucher_processor.rb index 776fb11cb..2a428d42b 100644 --- a/app/services/voucher_processor.rb +++ b/app/services/voucher_processor.rb @@ -18,7 +18,7 @@ def call private def process_voucher - case @voucher.sort + case @voucher.role when "tutor" process_tutor_voucher when "editor" diff --git a/app/views/vouchers/verify.js.erb b/app/views/vouchers/verify.js.erb index 4558c8d90..9a8ef568b 100644 --- a/app/views/vouchers/verify.js.erb +++ b/app/views/vouchers/verify.js.erb @@ -1,5 +1,5 @@ $("#redeem-voucher").empty() - .append("<%= j render partial: 'vouchers/redeem_' + @voucher.sort + '_voucher', locals: { voucher: @voucher } %>"); + .append("<%= j render partial: 'vouchers/redeem_' + @voucher.role + '_voucher', locals: { voucher: @voucher } %>"); // activate selectize // @reviewer: This is used several times in our code base (in the coffeescript