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 # frozen_string_literal: true
class PaymentSerializer < ApplicationSerializer 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 def created_at_age
Time.now - object.created_at Time.now - object.created_at
@ -15,8 +21,20 @@ class PaymentSerializer < ApplicationSerializer
) )
end end
def username
user&.username
end
private private
def user
begin
User.find(object.user_id)
rescue
nil
end
end
def currency_unit def currency_unit
case object.currency case object.currency
when "eur" 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"> <table class="table discourse_patrons_admin">
<thead> <thead>
@ -13,7 +13,7 @@
</thead> </thead>
{{#each model as |payment|}} {{#each model as |payment|}}
<tr> <tr>
<td>{{payment.user_id}}</td> <td>{{payment.username}}</td>
<td>{{{stripe-payment-link payment}}}</td> <td>{{{stripe-payment-link payment}}}</td>
<td>{{payment.receipt_email}}</td> <td>{{payment.receipt_email}}</td>
<td>{{{format-duration payment.created_at_age}}}</td> <td>{{{format-duration payment.created_at_age}}}</td>