Plans, subscriptions
* Plans controller * Subscription controller * Clean admin controller * Ember Plans route * Index page * New Plans * Translations
This commit is contained in:
parent
dfef3c49cf
commit
0d82bcf37e
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiscoursePatrons
|
||||
class PlansController < ::Admin::AdminController
|
||||
def index
|
||||
head 204
|
||||
end
|
||||
|
||||
def show
|
||||
head 204
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,7 +3,11 @@
|
|||
module DiscoursePatrons
|
||||
class SubscriptionsController < ::Admin::AdminController
|
||||
def index
|
||||
head 200
|
||||
::Stripe.api_key = SiteSetting.discourse_patrons_secret_key
|
||||
|
||||
subscriptions = ::Stripe::Subscription.list
|
||||
|
||||
subscriptions.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,10 +8,6 @@ module DiscoursePatrons
|
|||
render_serialized(payments, PaymentSerializer)
|
||||
end
|
||||
|
||||
def subscriptions
|
||||
head 200
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def payments_order
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export default Discourse.Route.extend({});
|
|
@ -1,15 +1,16 @@
|
|||
<h3>Payments</h3>
|
||||
|
||||
<h3>{{i18n 'discourse_patrons.admin.dashboard.title'}}</h3>
|
||||
|
||||
{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}}
|
||||
{{#if model}}
|
||||
<table class="table discourse-patrons-admin">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.receipt_email'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.dashboard.table.head.user'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.dashboard.table.head.payment_intent'}}</th>
|
||||
<th>{{i18n 'discourse_patrons.admin.dashboard.table.head.receipt_email'}}</th>
|
||||
<th onclick={{action "orderPayments" "created_at"}} class="sortable">{{i18n 'created'}}</th>
|
||||
<th class="amount" onclick={{action "orderPayments" "amount"}} class="sortable amount">{{i18n 'discourse_patrons.admin.payment_history.table.head.amount'}}</th>
|
||||
<th class="amount" onclick={{action "orderPayments" "amount"}} class="sortable amount">{{i18n 'discourse_patrons.admin.dashboard.table.head.amount'}}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{#each model as |payment|}}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
<h3>Plans.</h3>
|
||||
<h3>{{i18n 'discourse_patrons.admin.plans.title'}}</h3>
|
||||
|
||||
{{#link-to 'adminPlugins.discourse-patrons.plans.show' 'new' class="btn btn-primary"}}
|
||||
New
|
||||
{{d-icon "plus"}}
|
||||
<span>{{i18n 'discourse_patrons.admin.plans.new'}}</span>
|
||||
{{/link-to}}
|
||||
|
||||
{{outlet}}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<th>Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{#each model as |payment|}}
|
||||
{{#each model as |plan|}}
|
||||
<tr>
|
||||
|
||||
</tr>
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
<ul class="nav nav-pills">
|
||||
<li>
|
||||
{{#link-to 'adminPlugins.discourse-patrons'}}
|
||||
Payments
|
||||
{{i18n 'discourse_patrons.admin.dashboard.title'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to 'adminPlugins.discourse-patrons.plans'}}
|
||||
Plans
|
||||
{{i18n 'discourse_patrons.admin.plans.title'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to 'adminPlugins.discourse-patrons.subscriptions'}}
|
||||
Subscriptions
|
||||
{{i18n 'discourse_patrons.admin.subscriptions.title'}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -38,10 +38,19 @@ en:
|
|||
confirm_payment: Confirm payment
|
||||
success: Go back
|
||||
admin:
|
||||
payment_history:
|
||||
dashboard:
|
||||
title: Dashboard
|
||||
table:
|
||||
head:
|
||||
user: User
|
||||
payment_intent: Payment ID
|
||||
receipt_email: Receipt Email
|
||||
amount: Amount
|
||||
plans:
|
||||
title: Plans
|
||||
new: New
|
||||
table:
|
||||
head:
|
||||
plan: Plan
|
||||
subscriptions:
|
||||
title: Subscriptions
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
DiscoursePatrons::Engine.routes.draw do
|
||||
get '/admin' => 'admin#index'
|
||||
get '/admin/subscriptions' => 'subscriptions#index'
|
||||
get '/admin/plans/:plan_id' => 'plans#show'
|
||||
get '/' => 'patrons#index'
|
||||
get '/:pid' => 'patrons#show'
|
||||
resources :patrons, only: [:index, :create]
|
||||
|
|
|
@ -38,6 +38,7 @@ after_initialize do
|
|||
"../lib/discourse_patrons/engine",
|
||||
"../config/routes",
|
||||
"../app/controllers/admin_controller",
|
||||
"../app/controllers/admin/plans_controller",
|
||||
"../app/controllers/admin/subscriptions_controller",
|
||||
"../app/controllers/patrons_controller",
|
||||
"../app/models/payment",
|
||||
|
|
|
@ -13,9 +13,10 @@ module DiscoursePatrons
|
|||
expect(DiscoursePatrons::SubscriptionsController < Admin::AdminController).to eq(true)
|
||||
end
|
||||
|
||||
it "is ok" do
|
||||
it "gets the empty subscriptions" do
|
||||
::Stripe::Subscription.expects(:list)
|
||||
get "/patrons/admin/subscriptions.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.status).to eq(204)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue