1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

Fix bug: Unable to create plans for all group

This commit is contained in:
Du Peng 2022-05-17 17:38:00 +02:00
parent 41d931aba0
commit cecf8126e0
4 changed files with 8 additions and 7 deletions

View File

@ -6,6 +6,7 @@
- Fix a bug: script mount-proof-of-identity-files unable to modify docker-compose.yml
- Fix a bug: Event reservation calendar encoding in mail
- Fix a bug: Missing of description of PlanCategory migration
- Fix a bug: Unable to create plans for all group
## v5.4.0 2022 May 12

View File

@ -27,7 +27,7 @@ class API::PlansController < API::ApiController
partner = params[:plan][:partner_id].empty? ? nil : User.find(params[:plan][:partner_id])
plan = PlansService.create(type, partner, plan_params)
if plan.errors.keys.count.positive?
if plan.key?(:errors)
render json: plan.errors, status: :unprocessable_entity
else
render json: plan, status: :created

View File

@ -181,16 +181,14 @@ Application.Controllers.controller('NewPlanController', ['$scope', '$uibModal',
* @param content {Object}
*/
$scope.afterSubmit = function (content) {
if ((content.id == null) && (content.plan_ids == null)) {
if (content.plan_ids === null || content.plan_ids === undefined) {
return growl.error(_t('app.admin.plans.new.unable_to_create_the_subscription_please_try_again'));
} else {
growl.success(_t('app.admin.plans.new.successfully_created_subscriptions_dont_forget_to_redefine_prices'));
if (content.plan_ids != null) {
if (content.plan_ids.length > 1) {
return $state.go('app.admin.pricing');
} else {
if (content.id != null) {
return $state.go('app.admin.plans.edit', { id: content.id });
}
return $state.go('app.admin.plans.edit', { id: content.plan_ids[0] });
}
}
};

View File

@ -14,8 +14,10 @@ class PlansService
plan = type.constantize.new(params)
if plan.save
partner&.add_role :partner, plan
else
return { errors: plan.errors.full_messages }
end
plan
{ plan_ids: [plan.id] }
end
rescue PaymentGatewayError => e
{ errors: e.message }