show username

This commit is contained in:
Rimian Perkins 2019-09-14 16:34:51 +10:00
parent 9631ddc7e5
commit cf46065635
2 changed files with 22 additions and 4 deletions

View File

@ -1,7 +1,13 @@
# frozen_string_literal: true
class PaymentSerializer < ApplicationSerializer
attributes :payment_intent_id, :receipt_email, :url, :created_at_age, :amount, :amount_currency
attributes :payment_intent_id,
:receipt_email,
:url,
:created_at_age,
:amount,
:amount_currency,
:username
def created_at_age
Time.now - object.created_at
@ -9,14 +15,26 @@ class PaymentSerializer < ApplicationSerializer
def amount_currency
ActiveSupport::NumberHelper.number_to_currency(
object.amount/100,
object.amount / 100,
precision: 2,
unit: currency_unit
)
end
def username
user&.username
end
private
def user
begin
User.find(object.user_id)
rescue
nil
end
end
def currency_unit
case object.currency
when "eur"

View File

@ -1,5 +1,5 @@
<h3>{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}</h3>
<h2>{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}</h2>
<table class="table discourse_patrons_admin">
<thead>
@ -13,7 +13,7 @@
</thead>
{{#each model as |payment|}}
<tr>
<td>{{payment.user_id}}</td>
<td>{{payment.username}}</td>
<td>{{{stripe-payment-link payment}}}</td>
<td>{{payment.receipt_email}}</td>
<td>{{{format-duration payment.created_at_age}}}</td>