list plans in admin
This commit is contained in:
parent
4e615908f4
commit
16513e29ea
|
@ -9,7 +9,7 @@ module DiscoursePatrons
|
||||||
|
|
||||||
def index
|
def index
|
||||||
plans = ::Stripe::Plan.list
|
plans = ::Stripe::Plan.list
|
||||||
render json: plans.data
|
render_json_dump plans.data
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
@ -32,7 +32,7 @@ module DiscoursePatrons
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
plan = ::Stripe::Plan.delete(params[:id])
|
plan = ::Stripe::Plan.delete(params[:id])
|
||||||
render json: plan
|
render_json_dump plan
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -9,7 +9,7 @@ module DiscoursePatrons
|
||||||
|
|
||||||
def index
|
def index
|
||||||
subscriptions = ::Stripe::Subscription.list
|
subscriptions = ::Stripe::Subscription.list
|
||||||
subscriptions.to_json
|
render_json_dump subscriptions
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default Ember.Controller.extend({
|
||||||
return ajax("/patrons/customers", { method: "post", data: customerData }).then(
|
return ajax("/patrons/customers", { method: "post", data: customerData }).then(
|
||||||
customer => {
|
customer => {
|
||||||
// TODO move default plan into settings
|
// TODO move default plan into settings
|
||||||
if(this.get('model.selectedPlan') == undefined) {
|
if(this.get('model.selectedPlan') === undefined) {
|
||||||
this.set('model.selectedPlan', this.get('model.plans.firstObject'));
|
this.set('model.selectedPlan', this.get('model.plans.firstObject'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ const AdminPlan = Discourse.Model.extend({
|
||||||
AdminPlan.reopenClass({
|
AdminPlan.reopenClass({
|
||||||
find() {
|
find() {
|
||||||
return ajax("/patrons/admin/plans", { method: "get" }).then(result =>
|
return ajax("/patrons/admin/plans", { method: "get" }).then(result =>
|
||||||
result.plans.map(plan => AdminPlan.create(plan))
|
result.map(plan => AdminPlan.create(plan))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
|
||||||
|
const AdminSubscription = Discourse.Model.extend({});
|
||||||
|
|
||||||
|
AdminSubscription.reopenClass({
|
||||||
|
find() {
|
||||||
|
return ajax("/patrons/admin/subscriptions", { method: "get" }).then(result =>
|
||||||
|
result.data.map(subscription => AdminSubscription.create(subscription))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default AdminSubscription;
|
|
@ -1,7 +1,7 @@
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import AdminSubscription from "discourse/plugins/discourse-patrons/discourse/models/admin-subscription";
|
||||||
|
|
||||||
export default Discourse.Route.extend({
|
export default Discourse.Route.extend({
|
||||||
model() {
|
model() {
|
||||||
return ajax("/patrons/admin/subscriptions", { method: "get" });
|
return AdminSubscription.find();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,21 @@
|
||||||
|
|
||||||
<h3>{{i18n 'discourse_patrons.admin.subscriptions.title'}}</h3>
|
|
||||||
|
|
||||||
<table class="table discourse-patrons-admin">
|
<table class="table discourse-patrons-admin">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{{#each model as |subscription|}}
|
{{#each model as |subscription|}}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{{subscription.id}}</td>
|
||||||
|
<td>
|
||||||
|
{{#link-to 'adminPlugins.discourse-patrons.plans.show' subscription.plan.id}}
|
||||||
|
{{subscription.plan.id}}
|
||||||
|
{{/link-to}}
|
||||||
|
</td>
|
||||||
|
<td>{{subscription.status}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in New Issue