mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-02-08 20:54:40 +00:00
The code in the plugin needed a dramatic cleanup. This refactor collapses the Plan/Product/Subscription controllers on the backend into one new controller: `SubscribeController`. This reduces N+1 calls to the back end during the subscription process and simplifies use of the code. I've also removed a bunch of dead code and refactored some logic into methods for easier readability. No feature/functionality changes in this commit; only refactoring. However, refactoring will allow for implementation of better anonymous user handling, so this is largely a foundation to enable making that change.
29 lines
680 B
Ruby
29 lines
680 B
Ruby
# frozen_string_literal: true
|
|
require_dependency "subscriptions_user_constraint"
|
|
|
|
DiscourseSubscriptions::Engine.routes.draw do
|
|
# TODO: namespace this
|
|
scope 'admin' do
|
|
get '/' => 'admin#index'
|
|
end
|
|
|
|
namespace :admin do
|
|
resources :plans
|
|
resources :subscriptions, only: [:index, :destroy]
|
|
resources :products
|
|
end
|
|
|
|
namespace :user do
|
|
resources :payments, only: [:index]
|
|
resources :subscriptions, only: [:index, :destroy]
|
|
end
|
|
|
|
get '/' => 'subscribe#index'
|
|
get '.json' => 'subscribe#index'
|
|
get '/:id' => 'subscribe#show'
|
|
post '/create' => 'subscribe#create'
|
|
post '/finalize' => 'subscribe#finalize'
|
|
|
|
post '/hooks' => 'hooks#create'
|
|
end
|