group concern
This commit is contained in:
parent
ad77fc749b
commit
3904310432
|
@ -0,0 +1,11 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module DiscoursePatrons
|
||||||
|
module Group
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
def plan_group(plan)
|
||||||
|
::Group.find_by_name(plan[:metadata][:group_name])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,6 +3,7 @@
|
||||||
module DiscoursePatrons
|
module DiscoursePatrons
|
||||||
class SubscriptionsController < ::ApplicationController
|
class SubscriptionsController < ::ApplicationController
|
||||||
include DiscoursePatrons::Stripe
|
include DiscoursePatrons::Stripe
|
||||||
|
include DiscoursePatrons::Group
|
||||||
before_action :set_api_key
|
before_action :set_api_key
|
||||||
requires_login
|
requires_login
|
||||||
|
|
||||||
|
@ -59,10 +60,6 @@ module DiscoursePatrons
|
||||||
{ user_id: current_user.id, username: current_user.username_lower }
|
{ user_id: current_user.id, username: current_user.username_lower }
|
||||||
end
|
end
|
||||||
|
|
||||||
def plan_group(plan)
|
|
||||||
Group.find_by_name(plan[:metadata][:group_name])
|
|
||||||
end
|
|
||||||
|
|
||||||
def subscription_ok
|
def subscription_ok
|
||||||
['active', 'trialing'].include?(@subscription[:status])
|
['active', 'trialing'].include?(@subscription[:status])
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,6 +4,7 @@ module DiscoursePatrons
|
||||||
module User
|
module User
|
||||||
class SubscriptionsController < ::ApplicationController
|
class SubscriptionsController < ::ApplicationController
|
||||||
include DiscoursePatrons::Stripe
|
include DiscoursePatrons::Stripe
|
||||||
|
include DiscoursePatrons::Group
|
||||||
before_action :set_api_key
|
before_action :set_api_key
|
||||||
requires_login
|
requires_login
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ after_initialize do
|
||||||
[
|
[
|
||||||
"../lib/discourse_patrons/engine",
|
"../lib/discourse_patrons/engine",
|
||||||
"../config/routes",
|
"../config/routes",
|
||||||
|
"../app/controllers/concerns/group",
|
||||||
"../app/controllers/concerns/stripe",
|
"../app/controllers/concerns/stripe",
|
||||||
"../app/controllers/admin_controller",
|
"../app/controllers/admin_controller",
|
||||||
"../app/controllers/admin/plans_controller",
|
"../app/controllers/admin/plans_controller",
|
||||||
|
|
Loading…
Reference in New Issue