Add pending donations to admin donations index
And add more info to the details page
This commit is contained in:
parent
fff7527694
commit
71352d13d2
@ -5,6 +5,7 @@ class Admin::DonationsController < Admin::BaseController
|
|||||||
# GET /donations
|
# GET /donations
|
||||||
def index
|
def index
|
||||||
@pagy, @donations = pagy(Donation.completed.order('paid_at desc'))
|
@pagy, @donations = pagy(Donation.completed.order('paid_at desc'))
|
||||||
|
@pending_donations = Donation.incomplete.order('paid_at desc')
|
||||||
|
|
||||||
@stats = {
|
@stats = {
|
||||||
overall_sats: @donations.sum("amount_sats"),
|
overall_sats: @donations.sum("amount_sats"),
|
||||||
|
@ -17,6 +17,7 @@ class Donation < ApplicationRecord
|
|||||||
scope :pending, -> { where(payment_status: "pending") }
|
scope :pending, -> { where(payment_status: "pending") }
|
||||||
scope :processing, -> { where(payment_status: "processing") }
|
scope :processing, -> { where(payment_status: "processing") }
|
||||||
scope :completed, -> { where(payment_status: "settled") }
|
scope :completed, -> { where(payment_status: "settled") }
|
||||||
|
scope :incomplete, -> { where.not(payment_status: "settled") }
|
||||||
|
|
||||||
aasm column: :payment_status do
|
aasm column: :payment_status do
|
||||||
state :pending, initial: true
|
state :pending, initial: true
|
||||||
|
32
app/views/admin/donations/_list.html.erb
Normal file
32
app/views/admin/donations/_list.html.erb
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<table class="divided mb-8">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>User</th>
|
||||||
|
<th class="text-right">Sats</th>
|
||||||
|
<th class="text-right">Fiat Amount</th>
|
||||||
|
<th class="pl-2">Public name</th>
|
||||||
|
<th>Date</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% donations.each do |donation| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to donation.user.cn, admin_user_path(donation.user.cn), class: 'ks-text-link' %></td>
|
||||||
|
<td class="text-right"><% if donation.amount_sats.present? %><%= number_with_delimiter donation.amount_sats %><% end %></td>
|
||||||
|
<td class="text-right"><% if donation.fiat_amount.present? %><%= number_to_currency donation.fiat_amount.to_f / 100, unit: "" %> <%= donation.fiat_currency %><% end %></td>
|
||||||
|
<td class="pl-2"><%= donation.public_name %></td>
|
||||||
|
<td><%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d (%H:%M UTC)") : donation.created_at.strftime("%Y-%m-%d (%H:%M UTC)") %></td>
|
||||||
|
<td class="text-right">
|
||||||
|
<%= link_to 'Show', admin_donation_path(donation), class: 'btn btn-sm btn-gray' %>
|
||||||
|
<%= link_to 'Edit', edit_admin_donation_path(donation), class: 'btn btn-sm btn-gray' %>
|
||||||
|
<%= link_to 'Destroy', admin_donation_path(donation), class: 'btn btn-sm btn-red',
|
||||||
|
data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% if defined?(pagy) %>
|
||||||
|
<%== pagy_nav pagy %>
|
||||||
|
<% end %>
|
@ -18,42 +18,24 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<% if @pending_donations.any? %>
|
||||||
|
<section>
|
||||||
|
<h3>Pending</h3>
|
||||||
|
<%= render partial: "admin/donations/list", locals: {
|
||||||
|
donations: @pending_donations
|
||||||
|
} %>
|
||||||
|
</section>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<% if @donations.any? %>
|
<% if @donations.any? %>
|
||||||
<h3>Recent Donations</h3>
|
<h3>Recent</h3>
|
||||||
<table class="divided mb-8">
|
<%= render partial: "admin/donations/list", locals: {
|
||||||
<thead>
|
donations: @donations, pagy: @pagy
|
||||||
<tr>
|
} %>
|
||||||
<th>User</th>
|
|
||||||
<th class="text-right">Sats</th>
|
|
||||||
<th class="text-right">Fiat Amount</th>
|
|
||||||
<th class="pl-2">Public name</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @donations.each do |donation| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= link_to donation.user.cn, admin_user_path(donation.user.cn), class: 'ks-text-link' %></td>
|
|
||||||
<td class="text-right"><% if donation.amount_sats.present? %><%= number_with_delimiter donation.amount_sats %><% end %></td>
|
|
||||||
<td class="text-right"><% if donation.fiat_amount.present? %><%= number_to_currency donation.fiat_amount.to_f / 100, unit: "" %> <%= donation.fiat_currency %><% end %></td>
|
|
||||||
<td class="pl-2"><%= donation.public_name %></td>
|
|
||||||
<td><%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d (%H:%M UTC)") : "" %></td>
|
|
||||||
<td class="text-right">
|
|
||||||
<%= link_to 'Show', admin_donation_path(donation), class: 'btn btn-sm btn-gray' %>
|
|
||||||
<%= link_to 'Edit', edit_admin_donation_path(donation), class: 'btn btn-sm btn-gray' %>
|
|
||||||
<%= link_to 'Destroy', admin_donation_path(donation), class: 'btn btn-sm btn-red',
|
|
||||||
data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' } %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<%== pagy_nav @pagy %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<p>
|
<p>
|
||||||
No donations yet.
|
No donations received yet.
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
@ -25,7 +25,15 @@
|
|||||||
<td><%= @donation.public_name %></td>
|
<td><%= @donation.public_name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Payment status</th>
|
||||||
|
<td><%= @donation.payment_status %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Created at</th>
|
||||||
|
<td><%= @donation.created_at&.strftime("%Y-%m-%d (%H:%M UTC)") %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Paid at</th>
|
||||||
<td><%= @donation.paid_at&.strftime("%Y-%m-%d (%H:%M UTC)") %></td>
|
<td><%= @donation.paid_at&.strftime("%Y-%m-%d (%H:%M UTC)") %></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user