remove subscribe index

This commit is contained in:
Rimian Perkins 2019-12-13 11:54:32 +11:00
parent 57fb508514
commit 4b334a69b5
24 changed files with 43 additions and 80 deletions

View File

@ -1,24 +1 @@
import { ajax } from "discourse/lib/ajax";
export default Ember.Controller.extend({
actions: {
stripePaymentHandler(data) {
return ajax("/s/patrons", {
data,
method: "post"
}).catch(() => {
return { error: "An error occured while submitting the form." };
});
},
paymentSuccessHandler(/* paymentIntentId */) {
bootbox.alert(
I18n.t("discourse_subscriptions.transactions.payment.success")
);
this.transitionToRoute(
"user.billing",
Discourse.User.current().username.toLowerCase()
);
}
}
});
export default Ember.Controller.extend({});

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import { ajax } from "discourse/lib/ajax";
export default Discourse.Route.extend({
export default Route.extend({
queryParams: {
order: {
refreshModel: true

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return AdminPlan.findAll();
}

View File

@ -1 +1,3 @@
export default Discourse.Route.extend({});
import Route from "@ember/routing/route";
export default Route.extend({});

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return AdminProduct.findAll();
},

View File

@ -1,7 +1,8 @@
import Route from "@ember/routing/route";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
import Group from "discourse/models/group";
export default Discourse.Route.extend({
export default Route.extend({
model(params) {
const id = params["plan-id"];
const product = this.modelFor(

View File

@ -1,7 +1,8 @@
import Route from "@ember/routing/route";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
export default Discourse.Route.extend({
export default Route.extend({
model(params) {
const product_id = params["product-id"];
let product;

View File

@ -1 +1,3 @@
export default Discourse.Route.extend({});
import Route from "@ember/routing/route";
export default Route.extend({});

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import AdminSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/admin-subscription";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return AdminSubscription.find();
},

View File

@ -1 +1,3 @@
export default Discourse.Route.extend({});
import Route from "@ember/routing/route";
export default Route.extend({});

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return Product.findAll();
}

View File

@ -1,7 +1,8 @@
import Route from "@ember/routing/route";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
export default Discourse.Route.extend({
export default Route.extend({
model(params) {
const product_id = params["subscription-id"];

View File

@ -1,22 +1,3 @@
import { ajax } from "discourse/lib/ajax";
import Route from "@ember/routing/route";
export default Discourse.Route.extend({
model() {
const user = Ember.Object.create({
name: "",
email: "",
phone: ""
});
return ajax("/s", {
method: "get"
})
.then(result => {
user.set("email", result.email);
return user;
})
.catch(() => {
return user;
});
}
});
export default Route.extend();

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import Invoice from "discourse/plugins/discourse-subscriptions/discourse/models/invoice";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return Invoice.findAll();
},

View File

@ -1,6 +1,7 @@
import Route from "@ember/routing/route";
import UserSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/user-subscription";
export default Discourse.Route.extend({
export default Route.extend({
model() {
return UserSubscription.findAll();
},

View File

@ -1,7 +1,5 @@
export default function() {
this.route("s", function() {
this.route("subscribe", function() {
this.route("show", { path: "/:subscription-id" });
});
this.route("show", { path: "/:subscription-id" });
});
}

View File

@ -9,7 +9,7 @@
{{#if currentUser}}
<div class="pull-right">
{{#link-to "s.subscribe.show" product.id disabled=product.subscribed class="btn btn-primary"}}
{{#link-to "s.show" product.id disabled=product.subscribed class="btn btn-primary"}}
{{i18n 'discourse_subscriptions.subscribe.title'}}
{{/link-to}}
</div>

View File

@ -1,5 +1,5 @@
{{#if (show-extra-nav)}}
{{#link-to 's.subscribe' class='discourse-patrons-subscribe'}}
{{#link-to 's' class='discourse-patrons-subscribe'}}
{{i18n 'discourse_subscriptions.navigation.subscribe'}}
{{/link-to}}
{{/if}}

View File

@ -1,14 +1,4 @@
<h3>{{i18n 'discourse_subscriptions.one_time.heading.payment' site_name=siteSettings.title}}</h3>
<p>
{{cook-text siteSettings.discourse_subscriptions_payment_page}}
</p>
<div class="donations-page-payment">
{{donation-form
billing=model
paymentSuccessHandler=(action "paymentSuccessHandler")
stripePaymentHandler=(action "stripePaymentHandler")
}}
<div id="product-list">
{{product-list products=model}}
</div>

View File

@ -1,4 +0,0 @@
<div id="product-list">
{{product-list products=model}}
</div>

View File

@ -7,7 +7,12 @@ module DiscourseSubscriptions
context "not authenticated" do
it "does not create a payment intent" do
::Stripe::PaymentIntent.expects(:create).never
post "/s/payments.json", params: { }
post "/s/payments.json", params: {
payment_method: 'pm_123',
amount: 999,
currency: 'gdp'
}
end
end