mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-01 20:12:12 +00:00
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
13
app/controllers/admin/plans_controller.rb
Normal file
13
app/controllers/admin/plans_controller.rb
Normal file
@ -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
|
module DiscoursePatrons
|
||||||
class SubscriptionsController < ::Admin::AdminController
|
class SubscriptionsController < ::Admin::AdminController
|
||||||
def index
|
def index
|
||||||
head 200
|
::Stripe.api_key = SiteSetting.discourse_patrons_secret_key
|
||||||
|
|
||||||
|
subscriptions = ::Stripe::Subscription.list
|
||||||
|
|
||||||
|
subscriptions.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -8,10 +8,6 @@ module DiscoursePatrons
|
|||||||
render_serialized(payments, PaymentSerializer)
|
render_serialized(payments, PaymentSerializer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscriptions
|
|
||||||
head 200
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def payments_order
|
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")}}
|
{{#load-more selector=".discourse-patrons-admin tr" action=(action "loadMore")}}
|
||||||
{{#if model}}
|
{{#if model}}
|
||||||
<table class="table discourse-patrons-admin">
|
<table class="table discourse-patrons-admin">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.user'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.dashboard.table.head.user'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.payment_history.table.head.payment_intent'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.dashboard.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.receipt_email'}}</th>
|
||||||
<th onclick={{action "orderPayments" "created_at"}} class="sortable">{{i18n 'created'}}</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{{#each model as |payment|}}
|
{{#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"}}
|
{{#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}}
|
{{/link-to}}
|
||||||
|
|
||||||
{{outlet}}
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<th>Amount</th>
|
<th>Amount</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{{#each model as |payment|}}
|
{{#each model as |plan|}}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -4,17 +4,17 @@
|
|||||||
<ul class="nav nav-pills">
|
<ul class="nav nav-pills">
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'adminPlugins.discourse-patrons'}}
|
{{#link-to 'adminPlugins.discourse-patrons'}}
|
||||||
Payments
|
{{i18n 'discourse_patrons.admin.dashboard.title'}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'adminPlugins.discourse-patrons.plans'}}
|
{{#link-to 'adminPlugins.discourse-patrons.plans'}}
|
||||||
Plans
|
{{i18n 'discourse_patrons.admin.plans.title'}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
{{#link-to 'adminPlugins.discourse-patrons.subscriptions'}}
|
{{#link-to 'adminPlugins.discourse-patrons.subscriptions'}}
|
||||||
Subscriptions
|
{{i18n 'discourse_patrons.admin.subscriptions.title'}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -38,10 +38,19 @@ en:
|
|||||||
confirm_payment: Confirm payment
|
confirm_payment: Confirm payment
|
||||||
success: Go back
|
success: Go back
|
||||||
admin:
|
admin:
|
||||||
payment_history:
|
dashboard:
|
||||||
|
title: Dashboard
|
||||||
table:
|
table:
|
||||||
head:
|
head:
|
||||||
user: User
|
user: User
|
||||||
payment_intent: Payment ID
|
payment_intent: Payment ID
|
||||||
receipt_email: Receipt Email
|
receipt_email: Receipt Email
|
||||||
amount: Amount
|
amount: Amount
|
||||||
|
plans:
|
||||||
|
title: Plans
|
||||||
|
new: New
|
||||||
|
table:
|
||||||
|
head:
|
||||||
|
plan: Plan
|
||||||
|
subscriptions:
|
||||||
|
title: Subscriptions
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
DiscoursePatrons::Engine.routes.draw do
|
DiscoursePatrons::Engine.routes.draw do
|
||||||
get '/admin' => 'admin#index'
|
get '/admin' => 'admin#index'
|
||||||
get '/admin/subscriptions' => 'subscriptions#index'
|
get '/admin/subscriptions' => 'subscriptions#index'
|
||||||
|
get '/admin/plans/:plan_id' => 'plans#show'
|
||||||
get '/' => 'patrons#index'
|
get '/' => 'patrons#index'
|
||||||
get '/:pid' => 'patrons#show'
|
get '/:pid' => 'patrons#show'
|
||||||
resources :patrons, only: [:index, :create]
|
resources :patrons, only: [:index, :create]
|
||||||
|
@ -38,6 +38,7 @@ after_initialize do
|
|||||||
"../lib/discourse_patrons/engine",
|
"../lib/discourse_patrons/engine",
|
||||||
"../config/routes",
|
"../config/routes",
|
||||||
"../app/controllers/admin_controller",
|
"../app/controllers/admin_controller",
|
||||||
|
"../app/controllers/admin/plans_controller",
|
||||||
"../app/controllers/admin/subscriptions_controller",
|
"../app/controllers/admin/subscriptions_controller",
|
||||||
"../app/controllers/patrons_controller",
|
"../app/controllers/patrons_controller",
|
||||||
"../app/models/payment",
|
"../app/models/payment",
|
||||||
|
0
spec/requests/plans_controller_spec.rb
Normal file
0
spec/requests/plans_controller_spec.rb
Normal file
@ -13,9 +13,10 @@ module DiscoursePatrons
|
|||||||
expect(DiscoursePatrons::SubscriptionsController < Admin::AdminController).to eq(true)
|
expect(DiscoursePatrons::SubscriptionsController < Admin::AdminController).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is ok" do
|
it "gets the empty subscriptions" do
|
||||||
|
::Stripe::Subscription.expects(:list)
|
||||||
get "/patrons/admin/subscriptions.json"
|
get "/patrons/admin/subscriptions.json"
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(204)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user