mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-03-03 00:29:17 +01:00
quick coding rules checking with rubocop
This commit is contained in:
parent
e94cf46fa4
commit
e9e27663cd
@ -350,11 +350,7 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs',
|
|||||||
if ($scope.isAdmin()) { return true; }
|
if ($scope.isAdmin()) { return true; }
|
||||||
const slotStart = moment(slot.start);
|
const slotStart = moment(slot.start);
|
||||||
const now = moment();
|
const now = moment();
|
||||||
if (slot.can_modify && $scope.enableBookingMove && (slotStart.diff(now, 'hours') >= $scope.moveBookingDelay)) {
|
return (slot.can_modify && $scope.enableBookingMove && (slotStart.diff(now, 'hours') >= $scope.moveBookingDelay));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -365,11 +361,7 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs',
|
|||||||
if ($scope.isAdmin()) { return true; }
|
if ($scope.isAdmin()) { return true; }
|
||||||
const slotStart = moment(slot.start);
|
const slotStart = moment(slot.start);
|
||||||
const now = moment();
|
const now = moment();
|
||||||
if (slot.can_modify && $scope.enableBookingCancel && (slotStart.diff(now, 'hours') >= $scope.cancelBookingDelay)) {
|
return (slot.can_modify && $scope.enableBookingCancel && (slotStart.diff(now, 'hours') >= $scope.cancelBookingDelay));
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -448,7 +440,7 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs',
|
|||||||
slots_attributes: [],
|
slots_attributes: [],
|
||||||
plan_id: ((plan ? plan.id : undefined))
|
plan_id: ((plan ? plan.id : undefined))
|
||||||
};
|
};
|
||||||
angular.forEach(slots, function (slot, key) {
|
angular.forEach(slots, function (slot) {
|
||||||
reservation.slots_attributes.push({
|
reservation.slots_attributes.push({
|
||||||
start_at: slot.start,
|
start_at: slot.start,
|
||||||
end_at: slot.end,
|
end_at: slot.end,
|
||||||
@ -608,7 +600,7 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs',
|
|||||||
}
|
}
|
||||||
, function (response) {
|
, function (response) {
|
||||||
$scope.alerts = [];
|
$scope.alerts = [];
|
||||||
$scope.alerts.push({ msg: _t('cart.a_problem_occured_during_the_payment_process_please_try_again_later'), type: 'danger' });
|
$scope.alerts.push({ msg: _t('cart.a_problem_occurred_during_the_payment_process_please_try_again_later'), type: 'danger' });
|
||||||
return $scope.attempting = false;
|
return $scope.attempting = false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -618,7 +610,7 @@ Application.Directives.directive('cart', [ '$rootScope', '$uibModal', 'dialogs',
|
|||||||
}).result['finally'](null).then(function (reservation) { afterPayment(reservation); });
|
}).result['finally'](null).then(function (reservation) { afterPayment(reservation); });
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Actions to run after the payment was successfull
|
* Actions to run after the payment was successful
|
||||||
*/
|
*/
|
||||||
var afterPayment = function (reservation) {
|
var afterPayment = function (reservation) {
|
||||||
// we set the cart content as 'paid' to display a summary of the transaction
|
// we set the cart content as 'paid' to display a summary of the transaction
|
||||||
|
@ -5,7 +5,6 @@ class API::PaymentsController < API::ApiController
|
|||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
|
|
||||||
def confirm_payment
|
def confirm_payment
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if params[:payment_method_id].present?
|
if params[:payment_method_id].present?
|
||||||
# Create the PaymentIntent
|
# Create the PaymentIntent
|
||||||
@ -14,13 +13,13 @@ class API::PaymentsController < API::ApiController
|
|||||||
|
|
||||||
reservable = cart_items_params[:reservable_type].constantize.find(cart_items_params[:reservable_id])
|
reservable = cart_items_params[:reservable_type].constantize.find(cart_items_params[:reservable_id])
|
||||||
price_details = Price.compute(false,
|
price_details = Price.compute(false,
|
||||||
current_user,
|
current_user,
|
||||||
reservable,
|
reservable,
|
||||||
cart_items_params[:slots_attributes] || [],
|
cart_items_params[:slots_attributes] || [],
|
||||||
cart_items_params[:plan_id],
|
cart_items_params[:plan_id],
|
||||||
cart_items_params[:nb_reserve_places],
|
cart_items_params[:nb_reserve_places],
|
||||||
cart_items_params[:tickets_attributes],
|
cart_items_params[:tickets_attributes],
|
||||||
coupon_params[:coupon_code])
|
coupon_params[:coupon_code])
|
||||||
|
|
||||||
intent = Stripe::PaymentIntent.create(
|
intent = Stripe::PaymentIntent.create(
|
||||||
payment_method: params[:payment_method_id],
|
payment_method: params[:payment_method_id],
|
||||||
@ -39,6 +38,7 @@ class API::PaymentsController < API::ApiController
|
|||||||
render status: 200, json: { error: e.message }
|
render status: 200, json: { error: e.message }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO extract in subroutine
|
||||||
if intent.status == 'succeeded'
|
if intent.status == 'succeeded'
|
||||||
begin
|
begin
|
||||||
user_id = params[:cart_items][:reservation][:user_id]
|
user_id = params[:cart_items][:reservation][:user_id]
|
||||||
@ -75,7 +75,7 @@ class API::PaymentsController < API::ApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif intent.status == 'succeeded'
|
elsif intent.status == 'succeeded'
|
||||||
# The payment didn’t need any additional actions and is completed!
|
# The payment didn't need any additional actions and is completed!
|
||||||
# Handle post-payment fulfillment
|
# Handle post-payment fulfillment
|
||||||
{ status: 200, json: { success: true } }
|
{ status: 200, json: { success: true } }
|
||||||
else
|
else
|
||||||
@ -86,14 +86,14 @@ class API::PaymentsController < API::ApiController
|
|||||||
|
|
||||||
def reservation_params
|
def reservation_params
|
||||||
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :nb_reserve_places,
|
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :nb_reserve_places,
|
||||||
tickets_attributes: %i[event_price_category_id booked],
|
tickets_attributes: %i[event_price_category_id booked],
|
||||||
slots_attributes: %i[id start_at end_at availability_id offered])
|
slots_attributes: %i[id start_at end_at availability_id offered])
|
||||||
end
|
end
|
||||||
|
|
||||||
def cart_items_params
|
def cart_items_params
|
||||||
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :user_id, :nb_reserve_places,
|
params[:cart_items].require(:reservation).permit(:reservable_id, :reservable_type, :plan_id, :user_id, :nb_reserve_places,
|
||||||
tickets_attributes: %i[event_price_category_id booked],
|
tickets_attributes: %i[event_price_category_id booked],
|
||||||
slots_attributes: %i[id start_at end_at availability_id offered])
|
slots_attributes: %i[id start_at end_at availability_id offered])
|
||||||
end
|
end
|
||||||
|
|
||||||
def coupon_params
|
def coupon_params
|
||||||
|
@ -461,5 +461,5 @@ en:
|
|||||||
reservation_was_cancelled_successfully: "Reservation was cancelled successfully."
|
reservation_was_cancelled_successfully: "Reservation was cancelled successfully."
|
||||||
cancellation_failed: "Cancellation failed."
|
cancellation_failed: "Cancellation failed."
|
||||||
confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
||||||
a_problem_occured_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later."
|
a_problem_occurred_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later."
|
||||||
none: "None"
|
none: "None"
|
||||||
|
@ -461,5 +461,5 @@ es:
|
|||||||
reservation_was_cancelled_successfully: "La reserva se ha cancelado con éxito."
|
reservation_was_cancelled_successfully: "La reserva se ha cancelado con éxito."
|
||||||
cancellation_failed: "Cancelación fallida."
|
cancellation_failed: "Cancelación fallida."
|
||||||
confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
confirm_payment_of_html: "{ROLE, select, admin{Payment on site} other{Pay}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
||||||
a_problem_occured_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later."
|
a_problem_occurred_during_the_payment_process_please_try_again_later: "A problem occurred during the payment process. Please try again later."
|
||||||
none: "Ninguno"
|
none: "Ninguno"
|
||||||
|
@ -461,5 +461,5 @@ fr:
|
|||||||
reservation_was_cancelled_successfully: "La réservation a bien été annulée."
|
reservation_was_cancelled_successfully: "La réservation a bien été annulée."
|
||||||
cancellation_failed: "L'annulation a échouée."
|
cancellation_failed: "L'annulation a échouée."
|
||||||
confirm_payment_of_html: "{ROLE, select, admin{Paiement sur place} other{Payer}} : {AMOUNT}" # messageFormat interpolation (contexte : valider mon paiement de 20,00 €)
|
confirm_payment_of_html: "{ROLE, select, admin{Paiement sur place} other{Payer}} : {AMOUNT}" # messageFormat interpolation (contexte : valider mon paiement de 20,00 €)
|
||||||
a_problem_occured_during_the_payment_process_please_try_again_later: "Il y a eu un problème lors de la procédure de paiement. Veuillez réessayer plus tard."
|
a_problem_occurred_during_the_payment_process_please_try_again_later: "Il y a eu un problème lors de la procédure de paiement. Veuillez réessayer plus tard."
|
||||||
none: "Aucune"
|
none: "Aucune"
|
||||||
|
@ -461,5 +461,5 @@ pt:
|
|||||||
reservation_was_cancelled_successfully: "Reserva a foi cancelada com sucesso."
|
reservation_was_cancelled_successfully: "Reserva a foi cancelada com sucesso."
|
||||||
cancellation_failed: "Cancelamento falhou."
|
cancellation_failed: "Cancelamento falhou."
|
||||||
confirm_payment_of_html: "{ROLE, select, admin{Pagamento pelo site} other{Pagar}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
confirm_payment_of_html: "{ROLE, select, admin{Pagamento pelo site} other{Pagar}}: {AMOUNT}" # messageFormat interpolation (context: confirm my payment of $20.00)
|
||||||
a_problem_occured_during_the_payment_process_please_try_again_later: "Um problema ocorreu durante o processo de pagamento. Por favor tente novamente mais tarde."
|
a_problem_occurred_during_the_payment_process_please_try_again_later: "Um problema ocorreu durante o processo de pagamento. Por favor tente novamente mais tarde."
|
||||||
none: "Vazio"
|
none: "Vazio"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user