Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin/raffles/participants_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def participants_scope

term = "%#{ActiveRecord::Base.sanitize_sql_like(@query)}%"
participants.left_outer_joins(:user)
.where("users.display_name ILIKE :term OR raffle_participants.code ILIKE :term OR raffle_participants.github_login ILIKE :term", term: term)
.where("users.display_name ILIKE :term OR raffle_participants.code ILIKE :term OR raffle_participants.github_login ILIKE :term OR raffle_participants.github_email ILIKE :term", term: term)
end

def query_param
Expand Down
5 changes: 3 additions & 2 deletions app/views/admin/raffles/participants/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
<h1>Participants</h1>

<%= form_with url: admin_raffles_participants_path, method: :get do %>
<%= text_field_tag :query, @query, placeholder: "display name or code", autocomplete: "off" %>
<%= text_field_tag :query, @query, placeholder: "name, code, or email", autocomplete: "off" %>
<%= submit_tag "Search" %>
<% end %>

<table class="table-data">
<thead>
<tr><th>User</th><th>Code</th><th>Type</th><th>Country</th><th>Eligible</th><th>Referrals</th><th>Joined</th></tr>
<tr><th>User</th><th>Code</th><th>Type</th><th>Email</th><th>Country</th><th>Eligible</th><th>Referrals</th><th>Joined</th></tr>
</thead>
<tbody>
<% @participants.each do |participant| %>
<tr>
<td><%= link_to participant.display_name, admin_raffles_participant_path(participant) %></td>
<td><code><%= participant.code %></code></td>
<td><%= participant.age_group %></td>
<td><code><%= participant.github_email || participant.user&.email || "—" %></code></td>
<td><%= participant.user&.geocoded_country || "—" %></td>
<td><%= participant.eligible? ? "Yes" : "No" %></td>
<td><%= @referral_counts[participant.id].to_i %></td>
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/raffles/participants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<li>Signed up: <%= @participant.user.created_at.strftime("%Y-%m-%d %H:%M UTC") %></li>
<% else %>
<li>GitHub: <%= @participant.github_login %></li>
<li>GitHub email: <code><%= @participant.github_email || "—" %></code></li>
<% end %>
<li>Eligible: <%= @participant.eligible? ? "Yes" : "No" %></li>
<% if @participant.fraud_cleared? %>
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def callback_url
ENV["RAFFLE_GITHUB_CLIENT_ID"] || Rails.application.credentials.dig(:github_raffle, :client_id),
ENV["RAFFLE_GITHUB_CLIENT_SECRET"] || Rails.application.credentials.dig(:github_raffle, :client_secret),
{
scope: "read:user",
scope: "read:user user:email",
callback_path: "/auth/github/callback"
}
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddGithubEmailToRaffleParticipants < ActiveRecord::Migration[8.0]
def change
add_column :raffle_participants, :github_email, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def dev_login
handle = params[:handle].presence&.parameterize(separator: "_")&.first(40) || "dev-adult"
participant = Raffle::Participant.find_or_create_by!(github_uid: "dev-#{handle}") do |p|
p.github_login = handle
p.github_email = "#{handle}@example.com"
p.age_group = :adult
end
session[:raffle_participant_id] = participant.id
Expand Down
1 change: 1 addition & 0 deletions engines/raffle/app/models/raffle/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def self.from_github(auth)
participant = find_or_initialize_by(github_uid: uid)
participant.github_login = login
participant.github_avatar_url = info&.image
participant.github_email = info&.email
participant.age_group = :adult
participant.save!
participant
Expand Down
3 changes: 3 additions & 0 deletions engines/raffle/app/views/raffle/shared/_dev_panel.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
</form>

<% if enrolled? %>
<div class="raffle-dev__addrefs">
<span class="raffle-dev__presets-label">GitHub email: <code><%= current_participant.github_email || "(none)" %></code></span>
</div>
<div class="raffle-dev__addrefs">
<span class="raffle-dev__presets-label">Add demo referrals (to you)</span>
<%= form_with url: dev_referrals_path, method: :post, class: "raffle-dev__refform" do %>
Expand Down