mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-07-04 05:22:12 +00:00
plan can be active or not
This commit is contained in:
parent
922dee581c
commit
603ddc354b
@ -27,6 +27,7 @@ module DiscoursePatrons
|
|||||||
product: params[:product],
|
product: params[:product],
|
||||||
trial_period_days: params[:trial_period_days],
|
trial_period_days: params[:trial_period_days],
|
||||||
currency: SiteSetting.discourse_patrons_currency,
|
currency: SiteSetting.discourse_patrons_currency,
|
||||||
|
active: params[:active],
|
||||||
metadata: { group_name: params[:metadata][:group_name] }
|
metadata: { group_name: params[:metadata][:group_name] }
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -54,6 +55,7 @@ module DiscoursePatrons
|
|||||||
params[:id],
|
params[:id],
|
||||||
nickname: params[:nickname],
|
nickname: params[:nickname],
|
||||||
trial_period_days: params[:trial_period_days],
|
trial_period_days: params[:trial_period_days],
|
||||||
|
active: params[:active],
|
||||||
metadata: { group_name: params[:metadata][:group_name] }
|
metadata: { group_name: params[:metadata][:group_name] }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ const AdminPlan = Discourse.Model.extend({
|
|||||||
trial_period_days: this.parseTrialPeriodDays,
|
trial_period_days: this.parseTrialPeriodDays,
|
||||||
product: this.product,
|
product: this.product,
|
||||||
metadata: this.metadata,
|
metadata: this.metadata,
|
||||||
|
active: this.active
|
||||||
};
|
};
|
||||||
|
|
||||||
return ajax("/patrons/admin/plans", { method: "post", data });
|
return ajax("/patrons/admin/plans", { method: "post", data });
|
||||||
@ -46,6 +47,7 @@ const AdminPlan = Discourse.Model.extend({
|
|||||||
nickname: this.nickname,
|
nickname: this.nickname,
|
||||||
trial_period_days: this.parseTrialPeriodDays,
|
trial_period_days: this.parseTrialPeriodDays,
|
||||||
metadata: this.metadata,
|
metadata: this.metadata,
|
||||||
|
active: this.active
|
||||||
};
|
};
|
||||||
|
|
||||||
return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data });
|
return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data });
|
||||||
|
@ -8,7 +8,7 @@ export default Discourse.Route.extend({
|
|||||||
let plan;
|
let plan;
|
||||||
|
|
||||||
if(id === 'new') {
|
if(id === 'new') {
|
||||||
plan = AdminPlan.create({ isNew: true, product: product.get('id') });
|
plan = AdminPlan.create({ active: true, isNew: true, product: product.get('id') });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plan = AdminPlan.find(id);
|
plan = AdminPlan.find(id);
|
||||||
|
@ -40,6 +40,12 @@
|
|||||||
</label>
|
</label>
|
||||||
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
|
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="active">
|
||||||
|
{{i18n 'discourse_patrons.admin.plans.plan.active'}}
|
||||||
|
</label>
|
||||||
|
{{input type="checkbox" name="active" checked=model.plan.active}}
|
||||||
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.interval'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.plans.plan.interval'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.created_at'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.plans.plan.created_at'}}</th>
|
||||||
<th>{{i18n 'discourse_patrons.admin.plans.plan.group'}}</th>
|
<th>{{i18n 'discourse_patrons.admin.plans.plan.group'}}</th>
|
||||||
|
<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">{{i18n 'discourse_patrons.admin.plans.plan.amount'}}</th>
|
||||||
<th class="td-right">
|
<th class="td-right">
|
||||||
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
|
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
|
||||||
@ -43,6 +44,7 @@
|
|||||||
<td>{{plan.interval}}</td>
|
<td>{{plan.interval}}</td>
|
||||||
<td>{{format-date plan.createdFormatted}}</td>
|
<td>{{format-date plan.createdFormatted}}</td>
|
||||||
<td>{{plan.metadata.group_name}}</td>
|
<td>{{plan.metadata.group_name}}</td>
|
||||||
|
<td>{{plan.active}}</td>
|
||||||
<td class="td-right">{{plan.amount}}</td>
|
<td class="td-right">{{plan.amount}}</td>
|
||||||
<td class="td-right">
|
<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-patrons.products.show.plans.show" model.product.id plan.id class="btn no-text btn-icon"}}
|
||||||
@ -58,7 +60,7 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="6">
|
<td colspan="7">
|
||||||
{{#unless model.plans}}
|
{{#unless model.plans}}
|
||||||
<hr>
|
<hr>
|
||||||
{{i18n 'discourse_patrons.admin.products.product.plan_help'}}
|
{{i18n 'discourse_patrons.admin.products.product.plan_help'}}
|
||||||
|
@ -97,6 +97,7 @@ en:
|
|||||||
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
|
||||||
group: User Group
|
group: User Group
|
||||||
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
group_help: This is the discourse user group the customer gets added to when the subscription is created.
|
||||||
|
active: Active
|
||||||
created_at: Created
|
created_at: Created
|
||||||
subscriptions:
|
subscriptions:
|
||||||
title: Subscriptions
|
title: Subscriptions
|
||||||
|
@ -120,6 +120,11 @@ module DiscoursePatrons
|
|||||||
post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite', metadata: { group_name: '' } }
|
post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite', metadata: { group_name: '' } }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "creates a plan with an active status" do
|
||||||
|
::Stripe::Plan.expects(:create).with(has_entry(:active, 'false'))
|
||||||
|
post "/patrons/admin/plans.json", params: { active: 'false', metadata: { group_name: '' } }
|
||||||
|
end
|
||||||
|
|
||||||
it 'has a metadata' do
|
it 'has a metadata' do
|
||||||
::Stripe::Plan.expects(:create).with(has_entry(metadata: { group_name: 'discourse-user-group-name' }))
|
::Stripe::Plan.expects(:create).with(has_entry(metadata: { group_name: 'discourse-user-group-name' }))
|
||||||
post "/patrons/admin/plans.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
post "/patrons/admin/plans.json", params: { metadata: { group_name: 'discourse-user-group-name' } }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user