name space the js admin

This commit is contained in:
Rimian Perkins 2019-12-02 18:58:14 +11:00
parent 274fd0c518
commit 382fd4ac41
37 changed files with 79 additions and 74 deletions

View File

@ -1,8 +1,8 @@
# Discourse Patrons
# Discourse Subscriptions
[![Build Status](https://travis-ci.org/rimian/discourse-patrons.svg?branch=master)](https://travis-ci.org/rimian/discourse-patrons)
[![Build Status](https://travis-ci.org/rimian/discourse-subscriptions.svg?branch=master)](https://travis-ci.org/rimian/discourse-subscriptions)
The Discourse Patrons plugin allows you to set up a subscription based Discourse application. By integrating with the [Stripe](https://stripe.com) payment gateway and setting up this plugin to manage Subscriptions, you can start selling users access to content on your website.
The Discourse Subscriptions plugin allows you to set up a subscription based Discourse application. By integrating with the [Stripe](https://stripe.com) payment gateway and setting up this plugin to manage Subscriptions, you can start selling users access to content on your website.
You can try it out here: https://discourse.rimian.com.au/patrons/subscribe
@ -50,7 +50,7 @@ You can also toggle the Subscribe button on and off in case you want to hide the
In the admin, add a new Product. Once you have a product saved, you can add plans to it. Keep in mind that the pricing and billing intervals of plans cannot be changed once you create them. This is to avoid confusion around subscription management.
If you take a look at your [Stripe Dashboard](https://dashboard.stripe.com), you'll see all those products and plans are listed. Discourse Patrons does not create them locally. They are created in Stripe.
If you take a look at your [Stripe Dashboard](https://dashboard.stripe.com), you'll see all those products and plans are listed. Discourse Patrons does not create them locally. They are created in Stripe.
## Testing
@ -58,7 +58,7 @@ Test with these credit card numbers:
* 4111 1111 1111 1111
Visit `/patrons/subscribe` and enter a few test transcations.
Visit `/patrons/subscribe` and enter a few test transcations.
## Warranty

View File

@ -4,7 +4,7 @@ export default Ember.Controller.extend({
actions: {
editPlan(id) {
return DiscourseURL.redirectTo(
`/admin/plugins/discourse-patrons/plans/${id}`
`/admin/plugins/discourse-subscriptions/plans/${id}`
);
}
}

View File

@ -11,7 +11,7 @@ export default Ember.Controller.extend({
this.get("model.plan")
.save()
.then(() => {
this.transitionToRoute("adminPlugins.discourse-patrons.plans");
this.transitionToRoute("adminPlugins.discourse-subscriptions.plans");
})
.catch(popupAjaxError);
}

View File

@ -17,7 +17,7 @@ export default Ember.Controller.extend({
redirect(product_id) {
DiscourseURL.redirectTo(
`/admin/plugins/discourse-patrons/products/${product_id}`
`/admin/plugins/discourse-subscriptions/products/${product_id}`
);
},

View File

@ -3,7 +3,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Controller.extend({
actions: {
cancelProduct() {
this.transitionToRoute("adminPlugins.discourse-patrons.products");
this.transitionToRoute("adminPlugins.discourse-subscriptions.products");
},
createProduct() {
@ -11,7 +11,7 @@ export default Ember.Controller.extend({
.save()
.then(product => {
this.transitionToRoute(
"adminPlugins.discourse-patrons.products.show",
"adminPlugins.discourse-subscriptions.products.show",
product.id
);
})
@ -22,7 +22,7 @@ export default Ember.Controller.extend({
this.get("model.product")
.update()
.then(() => {
this.transitionToRoute("adminPlugins.discourse-patrons.products");
this.transitionToRoute("adminPlugins.discourse-subscriptions.products");
})
.catch(popupAjaxError);
}

View File

@ -3,7 +3,7 @@ export default {
path: "/plugins",
map() {
this.route("discourse-patrons", function() {
this.route("discourse-subscriptions", function() {
this.route("dashboard");
this.route("products", function() {

View File

@ -1,4 +1,4 @@
import Plan from "discourse/plugins/discourse-patrons/discourse/models/plan";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
import computed from "ember-addons/ember-computed-decorators";
import { ajax } from "discourse/lib/ajax";

View File

@ -1,6 +1,6 @@
import computed from "ember-addons/ember-computed-decorators";
import { ajax } from "discourse/lib/ajax";
import Plan from "discourse/plugins/discourse-patrons/discourse/models/plan";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
const UserSubscription = Discourse.Model.extend({
@computed("status")

View File

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

View File

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

View File

@ -1,4 +1,4 @@
import AdminProduct from "discourse/plugins/discourse-patrons/discourse/models/admin-product";
import AdminProduct from "discourse/plugins/discourse-subscriptions/discourse/models/admin-product";
export default Discourse.Route.extend({
model() {
@ -16,7 +16,7 @@ export default Discourse.Route.extend({
product
.destroy()
.then(() => {
this.controllerFor("adminPluginsDiscoursePatronsProductsIndex")
this.controllerFor("adminPluginsDiscourseSubscriptionsProductsIndex")
.get("model")
.removeObject(product);
})

View File

@ -1,11 +1,11 @@
import AdminPlan from "discourse/plugins/discourse-patrons/discourse/models/admin-plan";
import AdminPlan from "discourse/plugins/discourse-subscriptions/discourse/models/admin-plan";
import Group from "discourse/models/group";
export default Discourse.Route.extend({
model(params) {
const id = params["plan-id"];
const product = this.modelFor(
"adminPlugins.discourse-patrons.products.show"
"adminPlugins.discourse-subscriptions.products.show"
).product;
let plan;
@ -26,10 +26,10 @@ export default Discourse.Route.extend({
},
renderTemplate() {
this.render("adminPlugins.discourse-patrons.products.show.plans.show", {
into: "adminPlugins.discourse-patrons.products",
this.render("adminPlugins.discourse-subscriptions.products.show.plans.show", {
into: "adminPlugins.discourse-subscriptions.products",
outlet: "main",
controller: "adminPlugins.discourse-patrons.products.show.plans.show"
controller: "adminPlugins.discourse-subscriptions.products.show.plans.show"
});
}
});

View File

@ -1,5 +1,5 @@
import AdminProduct from "discourse/plugins/discourse-patrons/discourse/models/admin-product";
import AdminPlan from "discourse/plugins/discourse-patrons/discourse/models/admin-plan";
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({
model(params) {
@ -28,7 +28,7 @@ export default Discourse.Route.extend({
plan
.destroy()
.then(() => {
this.controllerFor("adminPluginsDiscoursePatronsProductsShow")
this.controllerFor("adminPluginsDiscourseSubscriptionsProductsShow")
.get("model.plans")
.removeObject(plan);
})

View File

@ -1,4 +1,4 @@
import AdminSubscription from "discourse/plugins/discourse-patrons/discourse/models/admin-subscription";
import AdminSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/admin-subscription";
export default Discourse.Route.extend({
model() {

View File

@ -1,6 +1,6 @@
import Product from "discourse/plugins/discourse-patrons/discourse/models/product";
import Plan from "discourse/plugins/discourse-patrons/discourse/models/plan";
import Subscription from "discourse/plugins/discourse-patrons/discourse/models/subscription";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
export default Discourse.Route.extend({
model(params) {

View File

@ -1,4 +1,4 @@
import Product from "discourse/plugins/discourse-patrons/discourse/models/product";
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
export default Discourse.Route.extend({
model() {

View File

@ -1,4 +1,4 @@
import Invoice from "discourse/plugins/discourse-patrons/discourse/models/invoice";
import Invoice from "discourse/plugins/discourse-subscriptions/discourse/models/invoice";
export default Discourse.Route.extend({
model() {

View File

@ -1,4 +1,4 @@
import UserSubscription from "discourse/plugins/discourse-patrons/discourse/models/user-subscription";
import UserSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/user-subscription";
export default Discourse.Route.extend({
model() {

View File

@ -1,14 +0,0 @@
<h2>{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}</h2>
<ul class="nav nav-pills">
{{!-- {{nav-item route='adminPlugins.discourse-patrons.dashboard' label='discourse_patrons.admin.dashboard.title'}} --}}
{{nav-item route='adminPlugins.discourse-patrons.products' label='discourse_patrons.admin.products.title'}}
{{nav-item route='adminPlugins.discourse-patrons.subscriptions' label='discourse_patrons.admin.subscriptions.title'}}
</ul>
<hr>
<div id="discourse-patrons-admin">
{{outlet}}
</div>

View File

@ -1,6 +1,6 @@
<p class="btn-right">
{{#link-to 'adminPlugins.discourse-patrons.products.show' 'new' class="btn btn-primary"}}
{{#link-to 'adminPlugins.discourse-subscriptions.products.show' 'new' class="btn btn-primary"}}
{{d-icon "plus"}}
<span>{{i18n 'discourse_patrons.admin.products.operations.new'}}</span>
{{/link-to}}
@ -22,7 +22,7 @@
<td>{{format-unix-date product.updated}}</td>
<td class="td-right">{{product.active}}</td>
<td class="td-right">
{{#link-to "adminPlugins.discourse-patrons.products.show" product.id class="btn no-text btn-icon"}}
{{#link-to "adminPlugins.discourse-subscriptions.products.show" product.id class="btn no-text btn-icon"}}
{{d-icon "far-edit"}}
{{/link-to}}
{{d-button

View File

@ -42,9 +42,9 @@
<th>{{i18n 'discourse_patrons.admin.plans.plan.active'}}</th>
<th class="td-right">{{i18n 'discourse_patrons.admin.plans.plan.amount'}}</th>
<th class="td-right">
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
{{i18n 'discourse_patrons.admin.plans.operations.add'}}
{{/link-to}}
{{#link-to "adminPlugins.discourse-subscriptions.products.show.plans.show" model.product.id "new" class="btn"}}
{{i18n 'discourse_patrons.admin.plans.operations.add'}}
{{/link-to}}
</th>
</thead>
{{#each model.plans as |plan|}}
@ -56,7 +56,7 @@
<td>{{plan.active}}</td>
<td class="td-right">{{format-currency plan.currency plan.amountDollars}}</td>
<td class="td-right">
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
{{#link-to "adminPlugins.discourse-subscriptions.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
{{d-icon "far-edit"}}
{{/link-to}}
{{d-button

View File

@ -0,0 +1,14 @@
<h2>{{i18n 'discourse_patrons.title' site_name=siteSettings.title}}</h2>
<ul class="nav nav-pills">
{{!-- {{nav-item route='adminPlugins.discourse-subscriptions.dashboard' label='discourse_patrons.admin.dashboard.title'}} --}}
{{nav-item route='adminPlugins.discourse-subscriptions.products' label='discourse_patrons.admin.products.title'}}
{{nav-item route='adminPlugins.discourse-subscriptions.subscriptions' label='discourse_patrons.admin.subscriptions.title'}}
</ul>
<hr>
<div id="discourse-patrons-admin">
{{outlet}}
</div>

View File

@ -1,6 +1,6 @@
en:
site_settings:
discourse_patrons_enabled: Enable the Discourse Patrons plugin.
discourse_patrons_enabled: Enable the Discourse Subscriptions plugin.
discourse_patrons_extra_nav_subscribe: Show the subscribe button in the primary navigation
discourse_patrons_public_key: Stripe Publishable Key
discourse_patrons_secret_key: Stripe Secret Key
@ -15,7 +15,7 @@ en:
discourse_patrons_amount_must_be_currency: "Currency amounts must be currencies without dollar symbol (eg 1.50)"
js:
discourse_patrons:
title: Discourse Patrons
title: Discourse Subscriptions
optional: Optional
transactions:
payment:

View File

@ -1,9 +1,9 @@
# frozen_string_literal: true
# name: discourse-patrons
# about: Integrates Stripe into Discourse to allow visitors to make payments and Subscribe
# version: 2.3.2
# url: https://github.com/rimian/discourse-patrons
# name: discourse-subscriptions
# about: Integrates Stripe into Discourse to allow visitors to subscribe
# version: 2.4.0
# url: https://github.com/rimian/discourse-subscriptions
# authors: Rimian Perkins
enabled_site_setting :discourse_patrons_enabled
@ -24,24 +24,29 @@ extend_content_security_policy(
script_src: ['https://js.stripe.com/v3/']
)
add_admin_route 'discourse_patrons.title', 'discourse-patrons.products'
add_admin_route 'discourse_patrons.title', 'discourse-subscriptions.products'
Discourse::Application.routes.append do
get '/admin/plugins/discourse-patrons' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/products' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/products/:product_id' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/products/:product_id/plans' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/products/:product_id/plans/:plan_id' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/subscriptions' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/plans' => 'admin/plugins#index'
get '/admin/plugins/discourse-patrons/plans/:plan_id' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/products' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/products/:product_id' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/products/:product_id/plans' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/products/:product_id/plans/:plan_id' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/subscriptions' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/plans' => 'admin/plugins#index'
get '/admin/plugins/discourse-subscriptions/plans/:plan_id' => 'admin/plugins#index'
get 'u/:username/billing' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
get 'u/:username/subscriptions' => 'users#show', constraints: { username: USERNAME_ROUTE_FORMAT }
end
after_initialize do
::Stripe.api_version = "2019-11-05"
::Stripe.set_app_info('Discourse Patrons', version: '2.3.2', url: 'https://github.com/rimian/discourse-patrons')
::Stripe.set_app_info(
'Discourse Subscriptions',
version: '2.4.0',
url: 'https://github.com/rimian/discourse-subscriptions'
)
[
"../lib/discourse_patrons/engine",