From c94a0e34d1a446aa0491b894c9e7dd6c6ef9933f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Tue, 27 May 2025 19:04:35 +0400 Subject: [PATCH] Add donations to user details, link to filtered list --- app/controllers/admin/donations_controller.rb | 4 ++-- app/views/admin/donations/index.html.erb | 2 +- app/views/admin/invitations/index.html.erb | 2 +- app/views/admin/users/show.html.erb | 23 +++++++++++++++---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/donations_controller.rb b/app/controllers/admin/donations_controller.rb index ca394e0..466fd44 100644 --- a/app/controllers/admin/donations_controller.rb +++ b/app/controllers/admin/donations_controller.rb @@ -18,8 +18,8 @@ class Admin::DonationsController < Admin::BaseController @pagy, @donations = pagy(completed_scope) @stats = { - overall_sats: Donation.completed.sum("amount_sats"), - donor_count: Donation.completed.count(:user_id) + overall_sats: completed_scope.sum("amount_sats"), + donor_count: completed_scope.count(:user_id) } end diff --git a/app/views/admin/donations/index.html.erb b/app/views/admin/donations/index.html.erb index 8003568..ca1acc1 100644 --- a/app/views/admin/donations/index.html.erb +++ b/app/views/admin/donations/index.html.erb @@ -5,7 +5,7 @@ <%= render QuickstatsContainerComponent.new do %> <%= render QuickstatsItemComponent.new( type: :number, - title: 'Overall', + title: 'Received', value: @stats[:overall_sats], unit: 'sats' ) %> diff --git a/app/views/admin/invitations/index.html.erb b/app/views/admin/invitations/index.html.erb index 7c2cd43..f18555f 100644 --- a/app/views/admin/invitations/index.html.erb +++ b/app/views/admin/invitations/index.html.erb @@ -23,7 +23,7 @@ <% if @invitations_used.any? %>
-

Recently Accepted

+

Accepted

diff --git a/app/views/admin/users/show.html.erb b/app/views/admin/users/show.html.erb index 101a360..6147850 100644 --- a/app/views/admin/users/show.html.erb +++ b/app/views/admin/users/show.html.erb @@ -35,12 +35,25 @@ + + + +
Status - <% if @user.is_contributing_member? || @user.is_paying_member? %> - <%= @user.is_contributing_member? ? badge("contributor", :green) : "" %> - <%= @user.is_paying_member? ? badge("sustainer", :green) : "" %> - <% else %> - — + <% if @user.is_contributing_member? || @user.is_paying_member? %> + <%= @user.is_contributing_member? ? badge("contributor", :green) : "" %> + <%= @user.is_paying_member? ? badge("sustainer", :green) : "" %> + <% else %> + — + <% end %> +
Donations + <% if @user.donations.any? %> + <%= link_to admin_donations_path(username: @user.cn), class: "ks-text-link" do %> + <%= @user.donations.completed.count %> for + <%= number_with_delimiter @user.donations.completed.sum("amount_sats") %> sats <% end %> + <% else %> + — + <% end %>