diff --git a/app/controllers/lotteries_controller.rb b/app/controllers/lotteries_controller.rb index 9f2285f52..c6a6340be 100644 --- a/app/controllers/lotteries_controller.rb +++ b/app/controllers/lotteries_controller.rb @@ -91,8 +91,8 @@ def setup @presenter = LotteryPresenter.new(@lottery, view_context) end - # GET /organizations/:organization_id/lotteries/:id/withdraw_entrants - def withdraw_entrants + # GET /organizations/:organization_id/lotteries/:id/manage_entrants + def manage_entrants @presenter = LotteryPresenter.new(@lottery, view_context) end diff --git a/app/helpers/lotteries/entrant_service_details_helper.rb b/app/helpers/lotteries/entrant_service_details_helper.rb index 70998cab5..56159b7fc 100644 --- a/app/helpers/lotteries/entrant_service_details_helper.rb +++ b/app/helpers/lotteries/entrant_service_details_helper.rb @@ -13,7 +13,7 @@ def button_to_remove_completed_service_form(presenter) def service_form_status_with_icon(entrant_service_detail) case - when entrant_service_detail.completed_form.blank? + when entrant_service_detail.nil? || entrant_service_detail.completed_form.blank? title = "Not received" icon = "file-slash" color = "warning" @@ -31,6 +31,6 @@ def service_form_status_with_icon(entrant_service_detail) color = "secondary" end - content_tag :span, fa_icon(icon, type: :regular, text: title, class: "fs-4 text-#{color}"), class: "fw-bold fs-5" + content_tag :span, fa_icon(icon, type: :regular, text: title, class: "text-#{color}") end end diff --git a/app/madmin/resources/lottery_entrant_resource.rb b/app/madmin/resources/lottery_entrant_resource.rb index 91589f6d6..6b4b84e26 100644 --- a/app/madmin/resources/lottery_entrant_resource.rb +++ b/app/madmin/resources/lottery_entrant_resource.rb @@ -17,7 +17,6 @@ class LotteryEntrantResource < Madmin::Resource attribute :pre_selected attribute :external_id attribute :withdrawn - attribute :service_completed_date # Associations attribute :division diff --git a/app/models/lottery_entrant.rb b/app/models/lottery_entrant.rb index a4cc540fe..6cee157fe 100644 --- a/app/models/lottery_entrant.rb +++ b/app/models/lottery_entrant.rb @@ -7,6 +7,8 @@ class LotteryEntrant < ApplicationRecord include Delegable include CapitalizeAttributes + self.ignored_columns = %w[service_completed_date] + belongs_to :person, optional: true belongs_to :division, class_name: "LotteryDivision", foreign_key: "lottery_division_id", touch: true has_many :tickets, class_name: "LotteryTicket", dependent: :destroy @@ -75,6 +77,10 @@ def drawn? tickets.joins(:draw).exists? end + def service_completed? + service_detail.present? && service_detail.completed_date? + end + def to_s full_name end diff --git a/app/parameters/lottery_entrant_parameters.rb b/app/parameters/lottery_entrant_parameters.rb index 962159c0b..1a009a8e9 100644 --- a/app/parameters/lottery_entrant_parameters.rb +++ b/app/parameters/lottery_entrant_parameters.rb @@ -42,7 +42,6 @@ def self.permitted :lottery_division_id, :number_of_tickets, :pre_selected, - :service_completed_date, :state_code, :withdrawn, ] diff --git a/app/policies/lottery_policy.rb b/app/policies/lottery_policy.rb index f8115792c..0a3ef66c8 100644 --- a/app/policies/lottery_policy.rb +++ b/app/policies/lottery_policy.rb @@ -49,7 +49,7 @@ def setup? new? end - def withdraw_entrants? + def manage_entrants? new? end diff --git a/app/views/lotteries/_admin_tabs.html.erb b/app/views/lotteries/_admin_tabs.html.erb index 0a10689bb..37e44913e 100644 --- a/app/views/lotteries/_admin_tabs.html.erb +++ b/app/views/lotteries/_admin_tabs.html.erb @@ -7,8 +7,8 @@ <%= content_tag :li, class: "nav-item #{'active' if presenter.action_name == 'draw_tickets'}" do %> <%= link_to "Draw Tickets", draw_tickets_organization_lottery_path(presenter.organization, presenter.lottery) %> <% end %> - <%= content_tag :li, class: "nav-item #{'active' if presenter.action_name == 'withdraw_entrants'}" do %> - <%= link_to "Withdraw Entrants", withdraw_entrants_organization_lottery_path(presenter.organization, presenter.lottery) %> + <%= content_tag :li, class: "nav-item #{'active' if presenter.action_name == 'manage_entrants'}" do %> + <%= link_to "Manage Entrants", manage_entrants_organization_lottery_path(presenter.organization, presenter.lottery) %> <% end %> <%= content_tag :li, class: "nav-item #{'active' if presenter.controller_name == 'partners'}" do %> <%= link_to "Partners", organization_lottery_partners_path(presenter.organization, presenter.lottery) %> diff --git a/app/views/lotteries/_entrant_for_results.html.erb b/app/views/lotteries/_entrant_for_results.html.erb index 085a8877a..10ac163ed 100644 --- a/app/views/lotteries/_entrant_for_results.html.erb +++ b/app/views/lotteries/_entrant_for_results.html.erb @@ -1,5 +1,5 @@