1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

Merge branch 'dev' for release 5.6.7

This commit is contained in:
Sylvain 2023-01-25 13:00:02 +01:00
commit 5e2bab4559
5 changed files with 36 additions and 6 deletions

View File

@ -1,5 +1,10 @@
# Changelog Fab-manager
## v5.6.7 2023 January 25
- Fix a bug: updating plan prices
- Fix a bug: admin cannot book an event for himself
## v5.6.6 2023 January 23
- Add more context data to sentry reports

View File

@ -73,7 +73,7 @@ export const PlanPricingForm = <TContext extends object>({ register, control, fo
(price.priceable_type === 'Space' && spaces?.find(s => s.id === price.priceable_id));
if (!item?.disabled) {
return (
<div key={index}>
<div key={price.id}>
<FormInput register={register}
id={`prices_attributes.${index}.id`}
formState={formState}

View File

@ -329,16 +329,15 @@ Application.Controllers.controller('ShowEventController', ['$scope', '$state', '
return Wallet.getWalletByUser({ user_id: $scope.ctrl.member.id }, function (wallet) {
const amountToPay = helpers.getAmountToPay($scope.reserve.amountTotal, wallet.amount);
if ((AuthService.isAuthorized(['member']) && amountToPay > 0)
|| (AuthService.isAuthorized('manager') && $scope.ctrl.member.id === $rootScope.currentUser.id && amountToPay > 0)) {
if ((AuthService.isAuthorized('member') && amountToPay > 0)
|| (AuthService.isAuthorized(['manager', 'admin']) && $scope.ctrl.member.id === $rootScope.currentUser.id && amountToPay > 0)) {
if (settingsPromise.online_payment_module !== 'true') {
growl.error(_t('app.public.events_show.online_payment_disabled'));
} else {
return payOnline(reservation);
}
} else {
if (AuthService.isAuthorized('admin')
|| (AuthService.isAuthorized('manager') && $scope.ctrl.member.id !== $rootScope.currentUser.id)
if (AuthService.isAuthorized(['manager', 'admin']) && $scope.ctrl.member.id !== $rootScope.currentUser.id
|| amountToPay === 0) {
return payOnSite(reservation);
}

View File

@ -1,6 +1,6 @@
{
"name": "fab-manager",
"version": "5.6.6",
"version": "5.6.7",
"description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.",
"keywords": [
"fablab",

View File

@ -5,6 +5,7 @@ import { Plan } from 'models/plan';
import selectEvent from 'react-select-event';
import userEvent from '@testing-library/user-event';
import plans from '../../__fixtures__/plans';
import machines from '../../__fixtures__/machines';
import { tiptapEvent } from '../../__lib__/tiptap';
describe('PlanForm', () => {
@ -152,4 +153,29 @@ describe('PlanForm', () => {
expect(screen.getByText(/app.admin.plan_form.alert_partner_notification/)).toBeInTheDocument();
});
});
test('update plan prices', async () => {
const plan = plans[1];
const machine = machines[1];
render(<PlanForm action="update" plan={plan} onError={onError} onSuccess={onSuccess} beforeSubmit={beforeSubmit} />);
await waitFor(() => screen.getByLabelText(new RegExp(machine.name)));
// update machine price
fireEvent.change(screen.getByLabelText(new RegExp(machine.name)), { target: { value: 42.42 } });
// send the form
fireEvent.click(screen.getByRole('button', { name: /app.admin.plan_form.ACTION_plan/ }));
await waitFor(() => {
const expected = {
prices_attributes: expect.arrayContaining([{
amount: 42.42,
duration: 60,
group_id: plan.group_id,
id: expect.any(Number),
plan_id: plan.id,
priceable_id: machine.id,
priceable_type: 'Machine'
}])
};
expect(beforeSubmit).toHaveBeenCalledWith(expect.objectContaining(expected));
});
});
});