Skip to content

Commit

Permalink
Merge pull request #1351 from SplitTime/oveson/use-entrant-service-de…
Browse files Browse the repository at this point in the history
…tail-for-service-completion-date

Use entrant service detail for service completion date
  • Loading branch information
moveson authored Dec 20, 2024
2 parents 7fe80e8 + 27f7c94 commit f65682b
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 67 deletions.
4 changes: 2 additions & 2 deletions app/controllers/lotteries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/lotteries/entrant_service_details_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
1 change: 0 additions & 1 deletion app/madmin/resources/lottery_entrant_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class LotteryEntrantResource < Madmin::Resource
attribute :pre_selected
attribute :external_id
attribute :withdrawn
attribute :service_completed_date

# Associations
attribute :division
Expand Down
6 changes: 6 additions & 0 deletions app/models/lottery_entrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/parameters/lottery_entrant_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def self.permitted
:lottery_division_id,
:number_of_tickets,
:pre_selected,
:service_completed_date,
:state_code,
:withdrawn,
]
Expand Down
2 changes: 1 addition & 1 deletion app/policies/lottery_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def setup?
new?
end

def withdraw_entrants?
def manage_entrants?
new?
end

Expand Down
4 changes: 2 additions & 2 deletions app/views/lotteries/_admin_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/lotteries/_entrant_for_results.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li><%= "#{entrant.name} (#{entrant.flexible_geolocation})" %>
<% if !entrant.withdrawn? && entrant.service_completed_date? %>
<% if !entrant.withdrawn? && entrant.service_completed? %>
<span class="text-success px-2"><%= fa_icon("circle-check", text: "Service Form Received", type: :solid, class: "text-success") %></span>
<% end %>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<th>Gender</th>
<th>From</th>
<th class="text-center">Withdrawn?</th>
<th class="text-center">Service Form Received</th>
<th class="text-center">Completed?</th>
<th class="text-center">Service Status</th>
</tr>
</thead>
<tbody>
Expand All @@ -20,8 +19,7 @@
<td><%= entrant.gender.titleize %></td>
<td><%= entrant.flexible_geolocation %></td>
<td class="text-center"><%= render partial: "lottery_entrants/withdrawn_form", locals: { organization: @presenter.organization, lottery: @presenter.lottery, entrant: entrant } %></td>
<td class="text-center"><%= render partial: "lottery_entrants/service_completed_form", locals: { organization: @presenter.organization, lottery: @presenter.lottery, entrant: entrant } %></td>
<td class="text-center"><%= render partial: "lottery_entrants/service_completed_indicator", locals: { entrant: entrant } %></td>
<td class="text-center"><%= render partial: "lottery_entrants/service_status_indicator", locals: { entrant: entrant } %></td>
</tr>
<% end %>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<div class="fs-3 fw-bold">Status</div>
</div>
<div class="col text-end pt-1">
<span class="fw-bold fs-5">
<%= service_form_status_with_icon(presenter.__getobj__) %>
</span>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% "OpenSplitTime: Withdraw Lottery Entrants - #{@presenter.name}" %>
<% end %>

<%= render "lotteries/header", presenter: @presenter, breadcrumbs: ["Withdraw Entrants"] %>
<%= render "lotteries/header", presenter: @presenter, breadcrumbs: ["Manage Entrants"] %>

<article class="ost-article container">
<% if @presenter.lottery_draws.present? %>
Expand All @@ -11,16 +11,16 @@
<h4 class="card-header fw-bold bg-primary text-white"><%= "#{division.name}" %></h4>
<div class="card-body">
<h5>Accepted</h5>
<%= render partial: "withdraw_entrants_table", locals: { entrants: division.accepted_entrants } %>
<%= render partial: "manage_entrants_table", locals: { entrants: division.accepted_entrants } %>

<% if division.wait_list_entrants.present? %>
<h5>Wait List</h5>
<%= render partial: "withdraw_entrants_table", locals: { entrants: division.wait_list_entrants } %>
<%= render partial: "manage_entrants_table", locals: { entrants: division.wait_list_entrants } %>
<% end %>

<% if division.withdrawn_entrants.present? %>
<h5>Withdrawn</h5>
<%= render partial: "withdraw_entrants_table", locals: { entrants: division.withdrawn_entrants } %>
<%= render partial: "manage_entrants_table", locals: { entrants: division.withdrawn_entrants } %>
<% end %>
</div>
</div>
Expand Down
7 changes: 0 additions & 7 deletions app/views/lottery_entrants/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@
</div>
</div>

<div class="row">
<div class="mb-3 col-md-2">
<%= f.label :service_completed_date, class: "mb-1" %>
<%= f.text_field :service_completed_date, class: "form-control", placeholder: "mm/dd/yyyy" %>
</div>
</div>

<br/>
<div class="row">
<div class="col">
Expand Down
8 changes: 0 additions & 8 deletions app/views/lottery_entrants/_service_completed_form.html.erb

This file was deleted.

This file was deleted.

7 changes: 7 additions & 0 deletions app/views/lottery_entrants/_service_status_indicator.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<%# locals: (entrant:) %>

<%= content_tag(:div, id: dom_id(entrant, :service_status_indicator)) do %>
<% unless entrant.withdrawn? %>
<%= service_form_status_with_icon(entrant.service_detail) %>
<% end %>
<% end %>
4 changes: 2 additions & 2 deletions app/views/lottery_entrants/update.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= turbo_stream.replace dom_id(@lottery_entrant, :service_completed_indicator),
partial: "service_completed_indicator",
<%= turbo_stream.replace dom_id(@lottery_entrant, :service_status_indicator),
partial: "service_status_indicator",
locals: { entrant: @lottery_entrant } %>

<%= turbo_stream.replace dom_id(@lottery_entrant),
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
member { get :draw_tickets }
member { get :export_entrants }
member { get :setup }
member { get :withdraw_entrants }
member { get :manage_entrants }
member { post :sync_calculations }
member { post :draw }
member { post :generate_entrants }
Expand Down
18 changes: 0 additions & 18 deletions spec/fixtures/lottery_entrants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ lottery_entrant_0001:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0002:
id: 5
lottery_division_id: 1
Expand All @@ -32,7 +31,6 @@ lottery_entrant_0002:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0003:
id: 6
lottery_division_id: 2
Expand All @@ -49,7 +47,6 @@ lottery_entrant_0003:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0004:
id: 7
lottery_division_id: 1
Expand All @@ -66,7 +63,6 @@ lottery_entrant_0004:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0005:
id: 8
lottery_division_id: 2
Expand All @@ -83,7 +79,6 @@ lottery_entrant_0005:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0006:
id: 9
lottery_division_id: 1
Expand All @@ -100,7 +95,6 @@ lottery_entrant_0006:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0007:
id: 10
lottery_division_id: 2
Expand All @@ -117,7 +111,6 @@ lottery_entrant_0007:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0008:
id: 11
lottery_division_id: 1
Expand All @@ -134,7 +127,6 @@ lottery_entrant_0008:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0009:
id: 12
lottery_division_id: 2
Expand All @@ -151,7 +143,6 @@ lottery_entrant_0009:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0010:
id: 13
lottery_division_id: 1
Expand All @@ -168,7 +159,6 @@ lottery_entrant_0010:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0011:
id: 21
lottery_division_id: 6
Expand All @@ -185,7 +175,6 @@ lottery_entrant_0011:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0012:
id: 22
lottery_division_id: 7
Expand All @@ -202,7 +191,6 @@ lottery_entrant_0012:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0013:
id: 23
lottery_division_id: 7
Expand All @@ -219,7 +207,6 @@ lottery_entrant_0013:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0014:
id: 24
lottery_division_id: 8
Expand All @@ -236,7 +223,6 @@ lottery_entrant_0014:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0015:
id: 25
lottery_division_id: 8
Expand All @@ -253,7 +239,6 @@ lottery_entrant_0015:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0016:
id: 26
lottery_division_id: 8
Expand All @@ -270,7 +255,6 @@ lottery_entrant_0016:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0017:
id: 27
lottery_division_id: 8
Expand All @@ -287,7 +271,6 @@ lottery_entrant_0017:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
lottery_entrant_0018:
id: 28
lottery_division_id: 8
Expand All @@ -304,4 +287,3 @@ lottery_entrant_0018:
pre_selected: false
external_id:
withdrawn:
service_completed_date:
4 changes: 2 additions & 2 deletions spec/system/lotteries/visit_withdraw_entrants_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rails_helper"

RSpec.describe "visit a lottery withdraw entrants page" do
RSpec.describe "visit a lottery manage entrants page" do
let(:user) { users(:third_user) }
let(:owner) { users(:fourth_user) }
let(:steward) { users(:fifth_user) }
Expand Down Expand Up @@ -55,7 +55,7 @@
end

def visit_page
visit withdraw_entrants_organization_lottery_path(organization, lottery)
visit manage_entrants_organization_lottery_path(organization, lottery)
end

def verify_all_content_present
Expand Down
Loading

0 comments on commit f65682b

Please sign in to comment.