1
0
mirror of synced 2026-08-02 21:27:02 +00:00

plan can be active or not

This commit is contained in:
Rimian Perkins
2019-10-24 10:02:31 +11:00
parent 922dee581c
commit 603ddc354b
7 changed files with 20 additions and 2 deletions
@@ -27,6 +27,7 @@ module DiscoursePatrons
product: params[:product],
trial_period_days: params[:trial_period_days],
currency: SiteSetting.discourse_patrons_currency,
active: params[:active],
metadata: { group_name: params[:metadata][:group_name] }
)
@@ -54,6 +55,7 @@ module DiscoursePatrons
params[:id],
nickname: params[:nickname],
trial_period_days: params[:trial_period_days],
active: params[:active],
metadata: { group_name: params[:metadata][:group_name] }
)
@@ -36,6 +36,7 @@ const AdminPlan = Discourse.Model.extend({
trial_period_days: this.parseTrialPeriodDays,
product: this.product,
metadata: this.metadata,
active: this.active
};
return ajax("/patrons/admin/plans", { method: "post", data });
@@ -46,6 +47,7 @@ const AdminPlan = Discourse.Model.extend({
nickname: this.nickname,
trial_period_days: this.parseTrialPeriodDays,
metadata: this.metadata,
active: this.active
};
return ajax(`/patrons/admin/plans/${this.id}`, { method: "patch", data });
@@ -8,7 +8,7 @@ export default Discourse.Route.extend({
let plan;
if(id === 'new') {
plan = AdminPlan.create({ isNew: true, product: product.get('id') });
plan = AdminPlan.create({ active: true, isNew: true, product: product.get('id') });
}
else {
plan = AdminPlan.find(id);
@@ -40,6 +40,12 @@
</label>
{{combo-box valueAttribute="value" content=model.plan.intervals value=model.plan.interval}}
</p>
<p>
<label for="active">
{{i18n 'discourse_patrons.admin.plans.plan.active'}}
</label>
{{input type="checkbox" name="active" checked=model.plan.active}}
</p>
</form>
<section>
@@ -30,6 +30,7 @@
<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.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">
{{#link-to "adminPlugins.discourse-patrons.products.show.plans.show" model.product.id "new" class="btn"}}
@@ -43,6 +44,7 @@
<td>{{plan.interval}}</td>
<td>{{format-date plan.createdFormatted}}</td>
<td>{{plan.metadata.group_name}}</td>
<td>{{plan.active}}</td>
<td class="td-right">{{plan.amount}}</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"}}
@@ -58,7 +60,7 @@
{{/each}}
<tr>
<td colspan="6">
<td colspan="7">
{{#unless model.plans}}
<hr>
{{i18n 'discourse_patrons.admin.products.product.plan_help'}}
+1
View File
@@ -97,6 +97,7 @@ en:
trial_help: Subscriptions to this plan will automatically start with a free trial of this length
group: User Group
group_help: This is the discourse user group the customer gets added to when the subscription is created.
active: Active
created_at: Created
subscriptions:
title: Subscriptions
@@ -120,6 +120,11 @@ module DiscoursePatrons
post "/patrons/admin/plans.json", params: { product: 'prod_walterwhite', metadata: { group_name: '' } }
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
::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' } }