basic user billing page

This commit is contained in:
Rimian Perkins 2019-10-25 13:23:32 +11:00
parent 9e981c3dae
commit edd6449105
6 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,7 @@
export default {
resource: 'user',
path: 'users/:username',
map() {
this.route('billing');
}
};

View File

@ -0,0 +1,9 @@
import { registerUnbound } from 'discourse-common/lib/helpers';
export default registerUnbound('user-viewing-self', function(model) {
if (Discourse.User.current()){
return Discourse.User.current().username.toLowerCase() === model.username.toLowerCase();
}
return false;
});

View File

@ -0,0 +1,16 @@
export default Discourse.Route.extend({
model() {
console.log('billing');
return {};
},
setupController(controller, model) {
if (this.currentUser.id !== this.modelFor("user").id) {
this.replaceWith("userActivity");
}
else {
controller.setProperties({ model });
};
}
});

View File

@ -0,0 +1,3 @@
{{#if (user-viewing-self model)}}
{{#link-to 'user.billing'}}{{d-icon "credit-card"}}{{I18n 'discourse_patrons.navigation.billing'}}{{/link-to}}
{{/if}}

View File

@ -0,0 +1,3 @@
user/billing

View File

@ -12,6 +12,7 @@ gem 'stripe', '5.7.1'
register_asset "stylesheets/common/discourse-patrons.scss"
register_asset "stylesheets/mobile/discourse-patrons.scss"
register_svg_icon "credit-card" if respond_to?(:register_svg_icon)
register_html_builder('server:before-head-close') do
"<script src='https://js.stripe.com/v3/'></script>"
@ -33,6 +34,7 @@ Discourse::Application.routes.append do
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 'u/:username/billing' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT}
end
after_initialize do