1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00

fix confilt

This commit is contained in:
Du Peng 2022-09-06 20:06:01 +02:00
commit 93be370912
32 changed files with 397 additions and 247 deletions

8
.overcommit.yml Normal file
View File

@ -0,0 +1,8 @@
PreCommit:
RuboCop:
enabled: true
on_warn: fail # Treat all warnings as failures
TrailingWhitespace:
enabled: true

View File

@ -2,6 +2,13 @@
## next release
- Updated portuguese translations
- Added automatic RuboCop validation on pre-commit
- Use union type instead of enum for SettingName
- Fix a bug: wrong variable reference in `SingleSignOnConcern:Merge_form_sso`
- Fix a bug: wrong focus behavior on text editor
- Fix a bug: trainings monitoring is not available
## v5.4.15 2022 August 1
- Improved security: adds redis-session-store to store session

View File

@ -36,6 +36,7 @@ group :development do
gem 'web-console', '>= 3.3.0'
# Preview mail in the browser
gem 'listen', '~> 3.0.5'
gem 'overcommit'
gem 'rb-readline'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'railroady'
@ -66,7 +67,6 @@ gem 'pg_search'
# authentication
gem 'devise', '>= 4.6.0'
gem 'omniauth', '~> 1.9.0'
gem 'omniauth-oauth2'
gem 'omniauth_openid_connect'

View File

@ -95,6 +95,7 @@ GEM
caxlsx_rails (0.6.2)
actionpack (>= 3.1)
caxlsx (>= 3.0)
childprocess (4.1.0)
chroma (0.2.0)
cldr-plurals-runtime-rb (1.0.1)
coercible (1.0.0)
@ -178,6 +179,7 @@ GEM
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
iniparse (1.5.0)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
jbuilder_cache_multi (0.1.0)
@ -274,6 +276,10 @@ GEM
openlab_ruby (0.0.7)
httparty (~> 0.20)
orm_adapter (0.5.0)
overcommit (0.59.1)
childprocess (>= 0.6.3, < 5)
iniparse (~> 1.4)
rexml (~> 3.2)
parallel (1.19.1)
parser (3.1.2.0)
ast (~> 2.4.1)
@ -535,6 +541,7 @@ DEPENDENCIES
omniauth-rails_csrf_protection (~> 0.1)
omniauth_openid_connect
openlab_ruby
overcommit
pdf-reader
pg
pg_search

View File

@ -52,7 +52,13 @@ class API::TrainingsController < API::ApiController
authorize Training
@training = Training.find(params[:id])
@availabilities = @training.availabilities
.includes(slots: { slots_reservations: { reservations: { statistic_profile: [:trainings, user: [:profile]] } } })
.includes(slots: {
slots_reservations: {
reservation: {
statistic_profile: [:trainings, { user: [:profile] }]
}
}
})
.where('slots_reservations.canceled_at': nil)
.order('availabilities.start_at DESC')
end

View File

@ -55,7 +55,7 @@ export default class SettingAPI {
itemData.localized = item.localized;
}
map.set(item.name as SettingName, itemData);
map.set(item.name, itemData);
});
return map;
}

View File

@ -20,17 +20,17 @@ const ReservationsDashboard: React.FC<ReservationsDashboardProps> = ({ onError,
const [modules, setModules] = useState<Map<SettingName, string>>();
useEffect(() => {
SettingAPI.query([SettingName.SpacesModule, SettingName.MachinesModule])
SettingAPI.query(['spaces_module', 'machines_module'])
.then(res => setModules(res))
.catch(error => onError(error));
}, []);
return (
<div className="reservations-dashboard">
{modules?.get(SettingName.MachinesModule) !== 'false' && <CreditsPanel userId={userId} onError={onError} reservableType="Machine" />}
{modules?.get(SettingName.SpacesModule) !== 'false' && <CreditsPanel userId={userId} onError={onError} reservableType="Space" />}
{modules?.get(SettingName.MachinesModule) !== 'false' && <ReservationsPanel userId={userId} onError={onError} reservableType="Machine" />}
{modules?.get(SettingName.SpacesModule) !== 'false' && <ReservationsPanel userId={userId} onError={onError} reservableType="Space" />}
{modules?.get('machines_module') !== 'false' && <CreditsPanel userId={userId} onError={onError} reservableType="Machine" />}
{modules?.get('spaces_module') !== 'false' && <CreditsPanel userId={userId} onError={onError} reservableType="Space" />}
{modules?.get('machines_module') !== 'false' && <ReservationsPanel userId={userId} onError={onError} reservableType="Machine" />}
{modules?.get('spaces_module') !== 'false' && <ReservationsPanel userId={userId} onError={onError} reservableType="Space" />}
</div>
);
};

View File

@ -9,15 +9,16 @@ export interface AbstractFormItemProps<TFieldValues> extends PropsWithChildren<A
tooltip?: ReactNode,
className?: string,
disabled?: boolean|((id: string) => boolean),
onLabelClick?: (event: React.MouseEvent<HTMLLabelElement, MouseEvent>) => void,
onLabelClick?: (event: React.MouseEvent<HTMLParagraphElement, MouseEvent>) => void,
inLine?: boolean,
containerType?: 'label' | 'div'
}
/**
* This abstract component should not be used directly.
* Other forms components that are intended to be used with react-hook-form must extend this component.
*/
export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label, tooltip, className, disabled, error, warning, rules, formState, onLabelClick, inLine, children }: AbstractFormItemProps<TFieldValues>) => {
export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label, tooltip, className, disabled, error, warning, rules, formState, onLabelClick, inLine, containerType, children }: AbstractFormItemProps<TFieldValues>) => {
const [isDirty, setIsDirty] = useState<boolean>(false);
const [fieldError, setFieldError] = useState<{ message: string }>(error);
const [isDisabled, setIsDisabled] = useState<boolean>(false);
@ -52,16 +53,16 @@ export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label,
* This function is called when the label is clicked.
* It is used to focus the input.
*/
function handleLabelClick (event: React.MouseEvent<HTMLLabelElement, MouseEvent>) {
function handleLabelClick (event: React.MouseEvent<HTMLParagraphElement, MouseEvent>) {
if (typeof onLabelClick === 'function') {
onLabelClick(event);
}
}
return (
<label className={`form-item ${classNames}`} onClick={handleLabelClick}>
return React.createElement(containerType, { className: `form-item ${classNames}` }, (
<>
{(label && !inLine) && <div className='form-item-header'>
<p>{label}</p>
<p onClick={handleLabelClick}>{label}</p>
{tooltip && <div className="item-tooltip">
<span className="trigger"><i className="fa fa-question-circle" /></span>
<div className="content">{tooltip}</div>
@ -79,6 +80,8 @@ export const AbstractFormItem = <TFieldValues extends FieldValues>({ id, label,
</div>
{(isDirty && fieldError) && <div className="form-item-error">{fieldError.message}</div> }
{(isDirty && warning) && <div className="form-item-warning">{warning.message}</div> }
</label>
);
</>
));
};
AbstractFormItem.defaultProps = { containerType: 'label' };

View File

@ -35,13 +35,14 @@ export const FormRichText = <TFieldValues extends FieldValues, TContext extends
* We do not want the default behavior (focus the first child, which is the Bold button)
* but we want to focus the text edition area.
*/
function focusTextEditor (event: React.MouseEvent<HTMLLabelElement, MouseEvent>) {
function focusTextEditor (event: React.MouseEvent<HTMLParagraphElement, MouseEvent>) {
event.preventDefault();
textEditorRef.current.focus();
}
return (
<AbstractFormItem id={id} label={label} tooltip={tooltip}
containerType={'div'}
className={`form-rich-text ${className || ''}`}
error={error} warning={warning} rules={rules}
disabled={disabled} formState={formState} onLabelClick={focusTextEditor}>

View File

@ -11,7 +11,6 @@ import { useForm } from 'react-hook-form';
import { FormSelect } from '../form/form-select';
import MemberAPI from '../../api/member';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
import UserLib from '../../lib/user';
declare const Application: IApplication;
@ -46,7 +45,7 @@ export const ChangeGroup: React.FC<ChangeGroupProps> = ({ user, onSuccess, onErr
useEffect(() => {
GroupAPI.index({ disabled: false, admins: user?.role === 'admin' }).then(setGroups).catch(onError);
MemberAPI.current().then(setOperator).catch(onError);
SettingAPI.get(SettingName.UserChangeGroup).then((setting) => {
SettingAPI.get('user_change_group').then((setting) => {
setAllowedUserChangeGoup(setting.value === 'true');
}).catch(onError);
}, []);

View File

@ -10,7 +10,6 @@ import { Machine } from '../../models/machine';
import { User } from '../../models/user';
import { IApplication } from '../../models/application';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
declare const Application: IApplication;
@ -46,7 +45,7 @@ const ReserveButton: React.FC<ReserveButtonProps> = ({ currentUser, machineId, o
// check the trainings after we retrieved the machine data
useEffect(() => checkTraining(), [machine]);
useEffect(() => {
SettingAPI.get(SettingName.PackOnlyForSubscription)
SettingAPI.get('pack_only_for_subscription')
.then(data => setIsPackOnlyForSubscription(data.value === 'true'))
.catch(error => onError(error));
}, []);

View File

@ -12,7 +12,7 @@ import FormatLib from '../../lib/format';
import { PaymentScheduleItemActions, TypeOnce } from './payment-schedule-item-actions';
import { StripeElements } from '../payment/stripe/stripe-elements';
import SettingAPI from '../../api/setting';
import { Setting, SettingName } from '../../models/setting';
import { Setting } from '../../models/setting';
interface PaymentSchedulesTableProps {
paymentSchedules: Array<PaymentSchedule>,
@ -40,7 +40,7 @@ const PaymentSchedulesTable: React.FC<PaymentSchedulesTableProps> = ({ paymentSc
const [gateway, setGateway] = useState<Setting>(null);
useEffect(() => {
SettingAPI.get(SettingName.PaymentGateway)
SettingAPI.get('payment_gateway')
.then(setting => setGateway(setting))
.catch(error => onError(error));
}, []);

View File

@ -13,7 +13,6 @@ import PriceAPI from '../../api/price';
import WalletAPI from '../../api/wallet';
import { Invoice } from '../../models/invoice';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
import { GoogleTagManager } from '../../models/gtm';
import { ComputePriceResult } from '../../models/price';
import { Wallet } from '../../models/wallet';
@ -91,7 +90,7 @@ export const AbstractPaymentModal: React.FC<AbstractPaymentModalProps> = ({ isOp
useEffect(() => {
mounted.current = true;
CustomAssetAPI.get(CustomAssetName.CgvFile).then(asset => setCgv(asset));
SettingAPI.get(SettingName.PaymentGateway).then((setting) => {
SettingAPI.get('payment_gateway').then((setting) => {
// we capitalize the first letter of the name
if (setting.value) {
setGateway(setting.value.replace(/^\w/, (c) => c.toUpperCase()));

View File

@ -7,7 +7,7 @@ import { IApplication } from '../../models/application';
import { ShoppingCart } from '../../models/payment';
import { User } from '../../models/user';
import { PaymentSchedule } from '../../models/payment-schedule';
import { Setting, SettingName } from '../../models/setting';
import { Setting } from '../../models/setting';
import { Invoice } from '../../models/invoice';
import SettingAPI from '../../api/setting';
import { useTranslation } from 'react-i18next';
@ -35,7 +35,7 @@ const CardPaymentModal: React.FC<CardPaymentModalProps> = ({ isOpen, toggleModal
const [gateway, setGateway] = useState<Setting>(null);
useEffect(() => {
SettingAPI.get(SettingName.PaymentGateway)
SettingAPI.get('payment_gateway')
.then(setting => setGateway(setting))
.catch(error => onError(error));
}, []);

View File

@ -5,7 +5,6 @@ import { GatewayFormProps } from '../abstract-payment-modal';
import LocalPaymentAPI from '../../../api/local-payment';
import FormatLib from '../../../lib/format';
import SettingAPI from '../../../api/setting';
import { SettingName } from '../../../models/setting';
import { CardPaymentModal } from '../card-payment-modal';
import { PaymentSchedule } from '../../../models/payment-schedule';
import { HtmlTranslate } from '../../base/html-translate';
@ -75,7 +74,7 @@ export const LocalPaymentForm: React.FC<GatewayFormProps> = ({ onSubmit, onSucce
if (paymentSchedule && method === 'card') {
// check that the online payment is active
try {
const online = await SettingAPI.get(SettingName.OnlinePaymentModule);
const online = await SettingAPI.get('online_payment_module');
if (online.value !== 'true') {
return onError(t('app.admin.local_payment_form.online_payment_disabled'));
}

View File

@ -2,7 +2,6 @@ import React, { FormEvent, FunctionComponent, useEffect, useRef, useState } from
import KRGlue from '@lyracom/embedded-form-glue';
import { GatewayFormProps } from '../abstract-payment-modal';
import SettingAPI from '../../../api/setting';
import { SettingName } from '../../../models/setting';
import PayzenAPI from '../../../api/payzen';
import {
CreateTokenResponse,
@ -27,10 +26,10 @@ export const PayzenForm: React.FC<PayzenFormProps> = ({ onSubmit, onSuccess, onE
const [loadingClass, setLoadingClass] = useState<'hidden' | 'loader' | 'loader-overlay'>('loader');
useEffect(() => {
SettingAPI.query([SettingName.PayZenEndpoint, SettingName.PayZenPublicKey]).then(settings => {
SettingAPI.query(['payzen_endpoint', 'payzen_public_key']).then(settings => {
createToken().then(formToken => {
// Load the remote library
KRGlue.loadLibrary(settings.get(SettingName.PayZenEndpoint), settings.get(SettingName.PayZenPublicKey))
KRGlue.loadLibrary(settings.get('payzen_endpoint'), settings.get('payzen_public_key'))
.then(({ KR }) =>
KR.setFormConfig({
formToken: formToken.formToken

View File

@ -17,9 +17,9 @@ interface PayzenKeysFormProps {
}
// all settings related to PayZen that are requested by this form
const payZenSettings: Array<SettingName> = [SettingName.PayZenUsername, SettingName.PayZenPassword, SettingName.PayZenEndpoint, SettingName.PayZenHmacKey, SettingName.PayZenPublicKey];
// settings related the to PayZen REST API (server side)
const restApiSettings: Array<SettingName> = [SettingName.PayZenUsername, SettingName.PayZenPassword, SettingName.PayZenEndpoint, SettingName.PayZenHmacKey];
const payzenSettings: Array<SettingName> = ['payzen_username', 'payzen_password', 'payzen_endpoint', 'payzen_hmac', 'payzen_public_key'];
// settings related to the PayZen REST API (server side)
const restApiSettings: Array<SettingName> = ['payzen_username', 'payzen_password', 'payzen_endpoint', 'payzen_hmac'];
// Prevent multiples call to the payzen keys validation endpoint.
// this cannot be handled by a React state because of their asynchronous nature
@ -32,7 +32,7 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
const { t } = useTranslation('admin');
// values of the PayZen settings
const [settings, updateSettings] = useImmer<Map<SettingName, string>>(new Map(payZenSettings.map(name => [name, ''])));
const [settings, updateSettings] = useImmer<Map<SettingName, string>>(new Map(payzenSettings.map(name => [name, ''])));
// Icon of the fieldset for the PayZen's keys concerning the REST API. Used to display if the key is valid.
const [restApiAddOn, setRestApiAddOn] = useState<ReactNode>(null);
// Style class for the add-on icon, for the REST API
@ -46,7 +46,7 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
* When the component loads for the first time, initialize the keys with the values fetched from the API (if any)
*/
useEffect(() => {
SettingAPI.query(payZenSettings).then(payZenKeys => {
SettingAPI.query(payzenSettings).then(payZenKeys => {
updateSettings(new Map(payZenKeys));
}).catch(error => console.error(error));
}, []);
@ -78,7 +78,7 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
setPublicKeyAddOnClassName('key-invalid');
return;
}
updateSettings(draft => draft.set(SettingName.PayZenPublicKey, key));
updateSettings(draft => draft.set('payzen_public_key', key));
setPublicKeyAddOn(<i className="fa fa-check" />);
setPublicKeyAddOnClassName('key-valid');
};
@ -94,9 +94,9 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
if (valid && !pendingKeysValidation) {
pendingKeysValidation = true;
PayzenAPI.chargeSDKTest(
settings.get(SettingName.PayZenEndpoint),
settings.get(SettingName.PayZenUsername),
settings.get(SettingName.PayZenPassword)
settings.get('payzen_endpoint'),
settings.get('payzen_username'),
settings.get('payzen_password')
).then(result => {
pendingKeysValidation = false;
@ -123,7 +123,7 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
/**
* Assign the inputted key to the given settings
*/
const setApiKey = (setting: SettingName.PayZenUsername | SettingName.PayZenPassword | SettingName.PayZenEndpoint | SettingName.PayZenHmacKey) => {
const setApiKey = (setting: typeof restApiSettings[number]) => {
return (key: string) => {
updateSettings(draft => draft.set(setting, key));
};
@ -148,7 +148,7 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
<label htmlFor="payzen_public_key">{ t('app.admin.invoices.payzen_keys_form.payzen_public_key') } *</label>
<FabInput id="payzen_public_key"
icon={<i className="fas fa-info" />}
defaultValue={settings.get(SettingName.PayZenPublicKey)}
defaultValue={settings.get('payzen_public_key')}
onChange={testPublicKey}
addOn={publicKeyAddOn}
addOnClassName={publicKeyAddOnClassName}
@ -166,8 +166,8 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
<FabInput id="payzen_username"
type="number"
icon={<i className="fas fa-user-alt" />}
defaultValue={settings.get(SettingName.PayZenUsername)}
onChange={setApiKey(SettingName.PayZenUsername)}
defaultValue={settings.get('payzen_username')}
onChange={setApiKey('payzen_username')}
debounce={200}
required />
</div>
@ -175,8 +175,8 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
<label htmlFor="payzen_password">{ t('app.admin.invoices.payzen_keys_form.payzen_password') } *</label>
<FabInput id="payzen_password"
icon={<i className="fas fa-key" />}
defaultValue={settings.get(SettingName.PayZenPassword)}
onChange={setApiKey(SettingName.PayZenPassword)}
defaultValue={settings.get('payzen_password')}
onChange={setApiKey('payzen_password')}
debounce={200}
required />
</div>
@ -185,8 +185,8 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
<FabInput id="payzen_endpoint"
type="url"
icon={<i className="fas fa-link" />}
defaultValue={settings.get(SettingName.PayZenEndpoint)}
onChange={setApiKey(SettingName.PayZenEndpoint)}
defaultValue={settings.get('payzen_endpoint')}
onChange={setApiKey('payzen_endpoint')}
debounce={200}
required />
</div>
@ -194,8 +194,8 @@ const PayzenKeysForm: React.FC<PayzenKeysFormProps> = ({ onValidKeys, onInvalidK
<label htmlFor="payzen_hmac">{ t('app.admin.invoices.payzen_keys_form.payzen_hmac') } *</label>
<FabInput id="payzen_hmac"
icon={<i className="fas fa-subscript" />}
defaultValue={settings.get(SettingName.PayZenHmacKey)}
onChange={setApiKey(SettingName.PayZenHmacKey)}
defaultValue={settings.get('payzen_hmac')}
onChange={setApiKey('payzen_hmac')}
debounce={200}
required />
</div>

View File

@ -21,21 +21,21 @@ interface PayzenSettingsProps {
const PAYZEN_HIDDEN = 'HiDdEnHIddEnHIdDEnHiDdEnHIddEnHIdDEn';
// settings related to PayZen that can be shown publicly
const payZenPublicSettings: Array<SettingName> = [SettingName.PayZenPublicKey, SettingName.PayZenEndpoint, SettingName.PayZenUsername];
const payZenPublicSettings: Array<SettingName> = ['payzen_public_key', 'payzen_endpoint', 'payzen_username'];
// settings related to PayZen that must be kept on server-side
const payZenPrivateSettings: Array<SettingName> = [SettingName.PayZenPassword, SettingName.PayZenHmacKey];
const payZenPrivateSettings: Array<SettingName> = ['payzen_password', 'payzen_hmac'];
// other settings related to PayZen
const payZenOtherSettings: Array<SettingName> = [SettingName.PayZenCurrency];
const payZenOtherSettings: Array<SettingName> = ['payzen_currency'];
// all PayZen settings
const payZenSettings: Array<SettingName> = payZenPublicSettings.concat(payZenPrivateSettings).concat(payZenOtherSettings);
// icons for the inputs of each setting
const icons:Map<SettingName, string> = new Map([
[SettingName.PayZenHmacKey, 'subscript'],
[SettingName.PayZenPassword, 'key'],
[SettingName.PayZenUsername, 'user'],
[SettingName.PayZenEndpoint, 'link'],
[SettingName.PayZenPublicKey, 'info']
['payzen_hmac', 'subscript'],
['payzen_password', 'key'],
['payzen_username', 'user'],
['payzen_endpoint', 'link'],
['payzen_public_key', 'info']
]);
/**
@ -55,11 +55,11 @@ export const PayzenSettings: React.FC<PayzenSettingsProps> = ({ onEditKeys, onCu
*/
useEffect(() => {
SettingAPI.query(payZenPublicSettings.concat(payZenOtherSettings)).then(payZenKeys => {
SettingAPI.isPresent(SettingName.PayZenPassword).then(pzPassword => {
SettingAPI.isPresent(SettingName.PayZenHmacKey).then(pzHmac => {
SettingAPI.isPresent('payzen_password').then(pzPassword => {
SettingAPI.isPresent('payzen_hmac').then(pzHmac => {
const map = new Map(payZenKeys);
map.set(SettingName.PayZenPassword, pzPassword ? PAYZEN_HIDDEN : '');
map.set(SettingName.PayZenHmacKey, pzHmac ? PAYZEN_HIDDEN : '');
map.set('payzen_password', pzPassword ? PAYZEN_HIDDEN : '');
map.set('payzen_hmac', pzHmac ? PAYZEN_HIDDEN : '');
updateSettings(map);
}).catch(error => { console.error(error); });
@ -81,7 +81,7 @@ export const PayzenSettings: React.FC<PayzenSettingsProps> = ({ onEditKeys, onCu
const handleCurrencyUpdate = (value: string, validity?: ValidityState): void => {
if (!validity || validity.valid) {
setError('');
updateSettings(draft => draft.set(SettingName.PayZenCurrency, value));
updateSettings(draft => draft.set('payzen_currency', value));
} else {
setError(t('app.admin.invoices.payment.payzen_settings.currency_error'));
}
@ -92,9 +92,9 @@ export const PayzenSettings: React.FC<PayzenSettingsProps> = ({ onEditKeys, onCu
* This will update the setting on the server.
*/
const saveCurrency = (): void => {
SettingAPI.update(SettingName.PayZenCurrency, settings.get(SettingName.PayZenCurrency)).then(result => {
SettingAPI.update('payzen_currency', settings.get('payzen_currency')).then(result => {
setError('');
updateSettings(draft => draft.set(SettingName.PayZenCurrency, result.value));
updateSettings(draft => draft.set('payzen_currency', result.value));
onCurrencyUpdateSuccess(result.value);
}, reason => {
setError(t('app.admin.invoices.payment.payzen_settings.error_while_saving') + reason);
@ -130,7 +130,7 @@ export const PayzenSettings: React.FC<PayzenSettingsProps> = ({ onEditKeys, onCu
<div className="payzen-currency-form">
<div className="currency-wrapper">
<label htmlFor="payzen_currency">{t('app.admin.invoices.payment.payzen_settings.payzen_currency')}</label>
<FabInput defaultValue={settings.get(SettingName.PayZenCurrency)}
<FabInput defaultValue={settings.get('payzen_currency')}
id="payzen_currency"
icon={<i className="fas fa-money-bill" />}
onChange={handleCurrencyUpdate}

View File

@ -38,7 +38,7 @@ export const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isO
// request the configured gateway to the API
useEffect(() => {
SettingAPI.get(SettingName.PaymentGateway).then(gateway => {
SettingAPI.get('payment_gateway').then(gateway => {
setSelectedGateway(gateway.value ? gateway.value : '');
});
}, []);
@ -73,8 +73,8 @@ export const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isO
const handleValidStripeKeys = (publicKey: string, secretKey: string): void => {
setGatewayConfig((prev) => {
const newMap = new Map(prev);
newMap.set(SettingName.StripeSecretKey, secretKey);
newMap.set(SettingName.StripePublicKey, publicKey);
newMap.set('stripe_secret_key', secretKey);
newMap.set('stripe_public_key', publicKey);
return newMap;
});
setPreventConfirmGateway(false);
@ -100,7 +100,7 @@ export const SelectGatewayModal: React.FC<SelectGatewayModalModalProps> = ({ isO
*/
const updateSettings = (): void => {
const settings = new Map<SettingName, string>(gatewayConfig);
settings.set(SettingName.PaymentGateway, selectedGateway);
settings.set('payment_gateway', selectedGateway);
SettingAPI.bulkUpdate(settings, true).then(result => {
const errorResults = Array.from(result.values()).filter(item => !item.status);

View File

@ -1,7 +1,6 @@
import React, { memo, useEffect, useState } from 'react';
import { Elements } from '@stripe/react-stripe-js';
import { loadStripe, Stripe } from '@stripe/stripe-js';
import { SettingName } from '../../../models/setting';
import SettingAPI from '../../../api/setting';
/**
@ -14,7 +13,7 @@ export const StripeElements: React.FC = memo(({ children }) => {
* When this component is mounted, we initialize the <Elements> tag with the Stripe's public key
*/
useEffect(() => {
SettingAPI.get(SettingName.StripePublicKey).then(key => {
SettingAPI.get('stripe_public_key').then(key => {
if (key?.value) {
const promise = loadStripe(key.value);
setStripe(promise);

View File

@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
import { HtmlTranslate } from '../../base/html-translate';
import { FabInput } from '../../base/fab-input';
import { Loader } from '../../base/loader';
import { SettingName } from '../../../models/setting';
import StripeAPI from '../../../api/external/stripe';
import SettingAPI from '../../../api/setting';
@ -42,9 +41,9 @@ const StripeKeysForm: React.FC<StripeKeysFormProps> = ({ onValidKeys, onInvalidK
useEffect(() => {
mounted.current = true;
SettingAPI.query([SettingName.StripePublicKey, SettingName.StripeSecretKey]).then(stripeKeys => {
setPublicKey(stripeKeys.get(SettingName.StripePublicKey));
setSecretKey(stripeKeys.get(SettingName.StripeSecretKey));
SettingAPI.query(['stripe_public_key', 'stripe_secret_key']).then(stripeKeys => {
setPublicKey(stripeKeys.get('stripe_public_key'));
setSecretKey(stripeKeys.get('stripe_secret_key'));
}).catch(error => console.error(error));
// when the component unmounts, mark it as unmounted

View File

@ -5,7 +5,6 @@ import { User } from '../../models/user';
import { UserPack } from '../../models/user-pack';
import UserPackAPI from '../../api/user-pack';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
import { FabButton } from '../base/fab-button';
import { useTranslation } from 'react-i18next';
import { ProposePacksModal } from './propose-packs-modal';
@ -44,10 +43,10 @@ const PacksSummary: React.FC<PacksSummaryProps> = ({ item, itemType, customer, o
const [isPackOnlyForSubscription, setIsPackOnlyForSubscription] = useState<boolean>(true);
useEffect(() => {
SettingAPI.get(SettingName.RenewPackThreshold)
SettingAPI.get('renew_pack_threshold')
.then(data => setThreshold(parseFloat(data.value)))
.catch(error => onError(error));
SettingAPI.get(SettingName.PackOnlyForSubscription)
SettingAPI.get('pack_only_for_subscription')
.then(data => setIsPackOnlyForSubscription(data.value === 'true'))
.catch(error => onError(error));
}, []);

View File

@ -6,7 +6,7 @@ import { Loader } from '../base/loader';
import { react2angular } from 'react2angular';
import { IApplication } from '../../models/application';
import SettingAPI from '../../api/setting';
import { SettingName } from '../../models/setting';
import { SettingName, titleSettings } from '../../models/setting';
import UserLib from '../../lib/user';
declare const Application: IApplication;
@ -27,7 +27,7 @@ export const CompletionHeaderInfo: React.FC<CompletionHeaderInfoProps> = ({ user
const userLib = new UserLib(user);
useEffect(() => {
SettingAPI.query([SettingName.NameGenre, SettingName.FablabName]).then(setSettings).catch(onError);
SettingAPI.query(titleSettings).then(setSettings).catch(onError);
}, []);
return (
@ -39,8 +39,8 @@ export const CompletionHeaderInfo: React.FC<CompletionHeaderInfoProps> = ({ user
<p className="intro">
<span>
{t('app.logged.profile_completion.completion_header_info.sso_intro', {
GENDER: settings?.get(SettingName.NameGenre),
NAME: settings?.get(SettingName.FablabName)
GENDER: settings?.get('name_genre'),
NAME: settings?.get('fablab_name')
})}
</span>
<span className="provider-name">

View File

@ -36,7 +36,7 @@ export const UserValidationSetting: React.FC<UserValidationSettingProps> = ({ on
const updateSetting = (name: SettingName, value: string) => {
SettingAPI.update(name, value)
.then(() => {
if (name === SettingName.UserValidationRequired) {
if (name === 'user_validation_required') {
onSuccess(t('app.admin.settings.account.user_validation_setting.customization_of_SETTING_successfully_saved', {
SETTING: t(`app.admin.settings.account.${name}`) // eslint-disable-line fabmanager/scoped-translation
}));
@ -45,7 +45,7 @@ export const UserValidationSetting: React.FC<UserValidationSettingProps> = ({ on
if (err.status === 304) return;
if (err.status === 423) {
if (name === SettingName.UserValidationRequired) {
if (name === 'user_validation_required') {
onError(t('app.admin.settings.account.user_validation_setting.error_SETTING_locked', {
SETTING: t(`app.admin.settings.account.${name}`) // eslint-disable-line fabmanager/scoped-translation
}));
@ -62,19 +62,19 @@ export const UserValidationSetting: React.FC<UserValidationSettingProps> = ({ on
* Callback triggered when the 'save' button is clicked.
*/
const handleSave = () => {
updateSetting(SettingName.UserValidationRequired, userValidationRequired);
updateSetting('user_validation_required', userValidationRequired);
if (userValidationRequiredList !== null) {
if (userValidationRequired === 'true') {
updateSetting(SettingName.UserValidationRequiredList, userValidationRequiredList);
updateSetting('user_validation_required_list', userValidationRequiredList);
} else {
updateSetting(SettingName.UserValidationRequiredList, null);
updateSetting('user_validation_required_list', null);
}
}
};
return (
<div className="user-validation-setting">
<BooleanSetting name={SettingName.UserValidationRequired}
<BooleanSetting name={'user_validation_required'}
label={t('app.admin.settings.account.user_validation_setting.user_validation_required_option_label')}
hideSave={true}
onChange={setUserValidationRequired}
@ -90,7 +90,7 @@ export const UserValidationSetting: React.FC<UserValidationSettingProps> = ({ on
<FabAlert level="warning">
{t('app.admin.settings.account.user_validation_setting.user_validation_required_list_other_info')}
</FabAlert>
<CheckListSetting name={SettingName.UserValidationRequiredList}
<CheckListSetting name={'user_validation_required_list'}
label=""
availableOptions={userValidationRequiredOptions}
defaultValue={userValidationRequiredListDefault.join(',')}

View File

@ -25,7 +25,7 @@ interface FabSocialsProps {
*/
export const FabSocials: React.FC<FabSocialsProps> = ({ show = false, onError, onSuccess }) => {
const { t } = useTranslation('shared');
// regular expression to validate the the input fields
// regular expression to validate the input fields
const urlRegex = /^(https?:\/\/)([\da-z.-]+)\.([-a-z\d.]{2,30})([/\w .-]*)*\/?$/;
const { handleSubmit, register, setValue, formState } = useForm();

View File

@ -99,7 +99,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
});
setValue('invoicing_profile_attributes.user_profile_custom_fields_attributes', userProfileCustomFields);
}).catch(error => onError(error));
SettingAPI.query([SettingName.PhoneRequired, SettingName.AddressRequired])
SettingAPI.query(['phone_required', 'address_required'])
.then(settings => setRequiredFieldsSettings(settings))
.catch(error => onError(error));
}, []);
@ -219,7 +219,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
value: phoneRegex,
message: t('app.shared.user_profile_form.phone_number_invalid')
},
required: requiredFieldsSettings.get(SettingName.PhoneRequired) === 'true'
required: requiredFieldsSettings.get('phone_required') === 'true'
}}
disabled={isDisabled}
formState={formState}
@ -232,7 +232,7 @@ export const UserProfileForm: React.FC<UserProfileFormProps> = ({ action, size,
<FormInput id="invoicing_profile_attributes.address_attributes.address"
register={register}
disabled={isDisabled}
rules={{ required: requiredFieldsSettings.get(SettingName.AddressRequired) === 'true' }}
rules={{ required: requiredFieldsSettings.get('address_required') === 'true' }}
label={t('app.shared.user_profile_form.address')} />
</div>
</div>

View File

@ -1,144 +1,242 @@
import { HistoryValue } from './history-value';
import { TDateISO } from '../typings/date-iso';
export enum SettingName {
AboutTitle = 'about_title',
AboutBody = 'about_body',
AboutContacts = 'about_contacts',
PrivacyDraft = 'privacy_draft',
PrivacyBody = 'privacy_body',
PrivacyDpo = 'privacy_dpo',
TwitterName = 'twitter_name',
HomeBlogpost = 'home_blogpost',
MachineExplicationsAlert = 'machine_explications_alert',
TrainingExplicationsAlert = 'training_explications_alert',
TrainingInformationMessage = 'training_information_message',
SubscriptionExplicationsAlert = 'subscription_explications_alert',
InvoiceLogo = 'invoice_logo',
InvoiceReference = 'invoice_reference',
InvoiceCodeActive = 'invoice_code-active',
InvoiceCodeValue = 'invoice_code-value',
InvoiceOrderNb = 'invoice_order-nb',
InvoiceVATActive = 'invoice_VAT-active',
InvoiceVATRate = 'invoice_VAT-rate',
InvoiceVATRateMachine = 'invoice_VAT-rate_Machine',
InvoiceVATRateTraining = 'invoice_VAT-rate_Training',
InvoiceVATRateSpace = 'invoice_VAT-rate_Space',
InvoiceVATRateEvent = 'invoice_VAT-rate_Event',
InvoiceVATRateSubscription = 'invoice_VAT-rate_Subscription',
InvoiceText = 'invoice_text',
InvoiceLegals = 'invoice_legals',
BookingWindowStart = 'booking_window_start',
BookingWindowEnd = 'booking_window_end',
BookingMoveEnable = 'booking_move_enable',
BookingMoveDelay = 'booking_move_delay',
BookingCancelEnable = 'booking_cancel_enable',
BookingCancelDelay = 'booking_cancel_delay',
MainColor = 'main_color',
SecondaryColor = 'secondary_color',
FablabName = 'fablab_name',
NameGenre = 'name_genre',
ReminderEnable = 'reminder_enable',
ReminderDelay = 'reminder_delay',
EventExplicationsAlert = 'event_explications_alert',
SpaceExplicationsAlert = 'space_explications_alert',
VisibilityYearly = 'visibility_yearly',
VisibilityOthers = 'visibility_others',
DisplayNameEnable = 'display_name_enable',
MachinesSortBy = 'machines_sort_by',
AccountingJournalCode = 'accounting_journal_code',
AccountingCardClientCode = 'accounting_card_client_code',
AccountingCardClientLabel = 'accounting_card_client_label',
AccountingWalletClientCode = 'accounting_wallet_client_code',
AccountingWalletClientLabel = 'accounting_wallet_client_label',
AccountingOtherClientCode = 'accounting_other_client_code',
AccountingOtherClientLabel = 'accounting_other_client_label',
AccountingWalletCode = 'accounting_wallet_code',
AccountingWalletLabel = 'accounting_wallet_label',
AccountingVATCode = 'accounting_VAT_code',
AccountingVATLabel = 'accounting_VAT_label',
AccountingSubscriptionCode = 'accounting_subscription_code',
AccountingSubscriptionLabel = 'accounting_subscription_label',
AccountingMachineCode = 'accounting_Machine_code',
AccountingMachineLabel = 'accounting_Machine_label',
AccountingTrainingCode = 'accounting_Training_code',
AccountingTrainingLabel = 'accounting_Training_label',
AccountingEventCode = 'accounting_Event_code',
AccountingEventLabel = 'accounting_Event_label',
AccountingSpaceCode = 'accounting_Space_code',
AccountingSpaceLabel = 'accounting_Space_label',
HubLastVersion = 'hub_last_version',
HubPublicKey = 'hub_public_key',
FabAnalytics = 'fab_analytics',
LinkName = 'link_name',
HomeContent = 'home_content',
HomeCss = 'home_css',
Origin = 'origin',
Uuid = 'uuid',
PhoneRequired = 'phone_required',
TrackingId = 'tracking_id',
BookOverlappingSlots = 'book_overlapping_slots',
SlotDuration = 'slot_duration',
EventsInCalendar = 'events_in_calendar',
SpacesModule = 'spaces_module',
PlansModule = 'plans_module',
InvoicingModule = 'invoicing_module',
FacebookAppId = 'facebook_app_id',
TwitterAnalytics = 'twitter_analytics',
RecaptchaSiteKey = 'recaptcha_site_key',
RecaptchaSecretKey = 'recaptcha_secret_key',
FeatureTourDisplay = 'feature_tour_display',
EmailFrom = 'email_from',
DisqusShortname = 'disqus_shortname',
AllowedCadExtensions = 'allowed_cad_extensions',
AllowedCadMimeTypes = 'allowed_cad_mime_types',
OpenlabAppId = 'openlab_app_id',
OpenlabAppSecret = 'openlab_app_secret',
OpenlabDefault = 'openlab_default',
OnlinePaymentModule = 'online_payment_module',
StripePublicKey = 'stripe_public_key',
StripeSecretKey = 'stripe_secret_key',
StripeCurrency = 'stripe_currency',
InvoicePrefix = 'invoice_prefix',
ConfirmationRequired = 'confirmation_required',
WalletModule = 'wallet_module',
StatisticsModule = 'statistics_module',
UpcomingEventsShown = 'upcoming_events_shown',
PaymentSchedulePrefix = 'payment_schedule_prefix',
TrainingsModule = 'trainings_module',
AddressRequired = 'address_required',
PaymentGateway = 'payment_gateway',
PayZenUsername = 'payzen_username',
PayZenPassword = 'payzen_password',
PayZenEndpoint = 'payzen_endpoint',
PayZenPublicKey = 'payzen_public_key',
PayZenHmacKey = 'payzen_hmac',
PayZenCurrency = 'payzen_currency',
PublicAgendaModule = 'public_agenda_module',
RenewPackThreshold = 'renew_pack_threshold',
PackOnlyForSubscription = 'pack_only_for_subscription',
OverlappingCategories = 'overlapping_categories',
ExtendedPricesInSameDay = 'extended_prices_in_same_day',
PublicRegistrations = 'public_registrations',
SocialsFacebook = 'facebook',
SocialsTwitter = 'twitter',
SocialsViadeo = 'viadeo',
SocialsLinkedin = 'linkedin',
SocialsInstagram = 'instagram',
SocialsYoutube = 'youtube',
SocialsVimeo = 'vimeo',
SocialsDailymotion = 'dailymotion',
SocialsGithub = 'github',
SocialsEchosciences = 'echosciences',
SocialsPinterest = 'pinterest',
SocialsLastfm = 'lastfm',
SocialsFlickr = 'flickr',
MachinesModule = 'machines_module',
UserChangeGroup = 'user_change_group',
UserValidationRequired = 'user_validation_required',
UserValidationRequiredList = 'user_validation_required_list',
ShowUsernameInAdminList = 'show_username_in_admin_list'
}
export const homePageSettings = [
'twitter_name',
'home_blogpost',
'home_content',
'home_css',
'upcoming_events_shown'
];
export const privacyPolicySettings = [
'privacy_draft',
'privacy_body',
'privacy_dpo'
];
export const aboutPageSettings = [
'about_title',
'about_body',
'about_contacts',
'link_name'
];
export const socialNetworksSettings = [
'facebook',
'twitter',
'viadeo',
'linkedin',
'instagram',
'youtube',
'vimeo',
'dailymotion',
'github',
'echosciences',
'pinterest',
'lastfm',
'flickr'
];
export const messagesSettings = [
'machine_explications_alert',
'training_explications_alert',
'training_information_message',
'subscription_explications_alert',
'event_explications_alert',
'space_explications_alert'
];
export const invoicesSettings = [
'invoice_logo',
'invoice_reference',
'invoice_code-active',
'invoice_code-value',
'invoice_order-nb',
'invoice_VAT-active',
'invoice_VAT-rate',
'invoice_VAT-rate_Machine',
'invoice_VAT-rate_Training',
'invoice_VAT-rate_Space',
'invoice_VAT-rate_Event',
'invoice_VAT-rate_Subscription',
'invoice_text',
'invoice_legals',
'invoice_prefix',
'payment_schedule_prefix'
];
export const bookingSettings = [
'booking_window_start',
'booking_window_end',
'booking_move_enable',
'booking_move_delay',
'booking_cancel_enable',
'booking_cancel_delay',
'reminder_enable',
'reminder_delay',
'visibility_yearly',
'visibility_others',
'display_name_enable',
'book_overlapping_slots',
'slot_duration',
'overlapping_categories'
];
export const themeSettings = [
'main_color',
'secondary_color'
];
export const titleSettings = [
'fablab_name',
'name_genre'
];
export const accountingSettings = [
'accounting_journal_code',
'accounting_card_client_code',
'accounting_card_client_label',
'accounting_wallet_client_code',
'accounting_wallet_client_label',
'accounting_other_client_code',
'accounting_other_client_label',
'accounting_wallet_code',
'accounting_wallet_label',
'accounting_VAT_code',
'accounting_VAT_label',
'accounting_subscription_code',
'accounting_subscription_label',
'accounting_Machine_code',
'accounting_Machine_label',
'accounting_Training_code',
'accounting_Training_label',
'accounting_Event_code',
'accounting_Event_label',
'accounting_Space_code',
'accounting_Space_label'
];
export const modulesSettings = [
'spaces_module',
'plans_module',
'wallet_module',
'statistics_module',
'trainings_module',
'machines_module',
'online_payment_module',
'public_agenda_module',
'invoicing_module'
];
export const stripeSettings = [
'stripe_public_key',
'stripe_secret_key',
'stripe_currency'
];
export const payzenSettings = [
'payzen_username',
'payzen_password',
'payzen_endpoint',
'payzen_public_key',
'payzen_hmac',
'payzen_currency'
];
export const openLabSettings = [
'openlab_app_id',
'openlab_app_secret',
'openlab_default'
];
export const accountSettings = [
'phone_required',
'confirmation_required',
'address_required',
'user_change_group',
'user_validation_required',
'user_validation_required_list'
];
export const analyticsSettings = [
'tracking_id',
'facebook_app_id',
'twitter_analytics'
];
export const fabHubSettings = [
'hub_last_version',
'hub_public_key',
'fab_analytics',
'origin',
'uuid'
];
export const projectsSettings = [
'allowed_cad_extensions',
'allowed_cad_mime_types',
'disqus_shortname'
];
export const prepaidPacksSettings = [
'renew_pack_threshold',
'pack_only_for_subscription'
];
export const registrationSettings = [
'public_registrations',
'recaptcha_site_key',
'recaptcha_secret_key'
];
export const adminSettings = [
'feature_tour_display',
'show_username_in_admin_list'
];
export const pricingSettings = [
'extended_prices_in_same_day'
];
export const poymentSettings = [
'payment_gateway'
];
export const displaySettings = [
'machines_sort_by',
'events_in_calendar',
'email_from'
];
export const allSettings = [
...homePageSettings,
...privacyPolicySettings,
...aboutPageSettings,
...socialNetworksSettings,
...messagesSettings,
...invoicesSettings,
...bookingSettings,
...themeSettings,
...titleSettings,
...accountingSettings,
...modulesSettings,
...stripeSettings,
...payzenSettings,
...openLabSettings,
...accountSettings,
...analyticsSettings,
...fabHubSettings,
...projectsSettings,
...prepaidPacksSettings,
...registrationSettings,
...adminSettings,
...pricingSettings,
...poymentSettings,
...displaySettings
] as const;
export type SettingName = typeof allSettings[number];
export type SettingValue = string|boolean|number;
@ -153,7 +251,7 @@ export interface Setting {
export interface SettingError {
error: string,
id: number,
name: string
name: SettingName
}
export interface SettingBulkResult {

View File

@ -124,7 +124,7 @@ module SingleSignOnConcern
logger.debug "mapping sso field #{field} with value=#{value}"
# we do not merge the email field if its end with the special value '-duplicate' as this means
# that the user is currently merging with the account that have the same email than the sso
set_data_from_sso_mapping(field, value) unless (field == 'user.email' && value.end_with?('-duplicate')) || (field == 'user.group_id' && user.admin?)
set_data_from_sso_mapping(field, value) unless (field == 'user.email' && value.end_with?('-duplicate')) || (field == 'user.group_id' && sso_user.admin?)
end
# run the account transfer in an SQL transaction to ensure data integrity

View File

@ -1,11 +1,13 @@
# frozen_string_literal: true
json.extract! @training, :id, :name, :description, :machine_ids, :nb_total_places, :public_page
json.availabilities @availabilities do |a|
json.id a.id
json.start_at a.start_at.iso8601
json.end_at a.end_at.iso8601
json.reservation_users a.slots.map do |slot|
json.id slot.reservations.first.statistic_profile.user_id
json.full_name slot.reservations.first.statistic_profile&.user&.profile&.full_name
json.is_valid slot.reservations.first.statistic_profile.trainings.include?(@training)
json.reservation_users a.slots.map(&:slots_reservations).flatten.map do |sr|
json.id sr.reservation.statistic_profile.user_id
json.full_name sr.reservation.statistic_profile.user&.profile&.full_name
json.is_valid sr.reservation.statistic_profile.trainings&.include?(@training)
end
end

View File

@ -71,9 +71,9 @@ pt:
email_is_required: "E-mail é obrigatório."
your_password: "Sua senha"
password_is_required: "Senha é obrigatório."
password_is_too_short: "Password is too short (minimum 12 characters)"
password_is_too_weak: "Password is too weak:"
password_is_too_weak_explanations: "minimum 12 characters, at least one uppercase letter, one lowercase letter, one number and one special character"
password_is_too_short: "Senha muito curta (mínimo 12 caracteres)"
password_is_too_weak: "A senha é muito fraca:"
password_is_too_weak_explanations: "mínimo de 12 caracteres, pelo menos uma letra maiúscula, uma letra minúscula, um número e um caractere especial"
type_your_password_again: "Digite sua senha novamente"
password_confirmation_is_required: "Confirmação de senha é obrigatório."
password_does_not_match_with_confirmation: "A senha não é igual ao da confirmação."
@ -103,7 +103,7 @@ pt:
used_for_reservation: "Estes dados serão utilizados em caso de alteração em uma das suas reservas"
used_for_profile: "Estes dados serão exibidos apenas no seu perfil"
public_profile: "Você terá um perfil público e outros usuários poderão associá-lo em seus projetos"
you_will_receive_confirmation_instructions_by_email_detailed: "If your e-mail address is valid, you will receive an email with instructions about how to confirm your account in a few minutes."
you_will_receive_confirmation_instructions_by_email_detailed: "Se seu endereço de e-mail for válido, você receberá em breve um e-mail com instruções sobre como confirmar sua conta."
#password modification modal
change_your_password: "Mudar sua senha"
your_new_password: "Sua nova senha"
@ -119,7 +119,7 @@ pt:
#confirmation modal
you_will_receive_confirmation_instructions_by_email: "Você receberá instruções de confirmação por e-mail."
#forgotten password modal
you_will_receive_in_a_moment_an_email_with_instructions_to_reset_your_password: "If your e-mail address is valid, you will receive in a moment an e-mail with instructions to reset your password."
you_will_receive_in_a_moment_an_email_with_instructions_to_reset_your_password: "Se o seu endereço de e-mail for válido, você receberá em breve um e-mail com instruções para redefinir sua senha."
#Fab-manager's version
version: "Versão:"
upgrade_fabmanager: "Atualizar Fab-manager"

View File

@ -19,9 +19,9 @@ pt:
extension_whitelist_error: "Você não tem permissão para fazer o upload de arquivos com esta extensão %{extension}, tipos permitidos: %{allowed_types}"
extension_blacklist_error: "Você não tem permissão para carregar arquivos %{extension}, tipos proibidos: %{prohibited_types}"
content_type_whitelist_error: "Você não tem permissão para enviar arquivos %{content_type}, tipos permitidos: %{allowed_types}"
rmagick_processing_error: "Failed to manipulate with rmagick, maybe it is not an image?"
mime_types_processing_error: "Failed to process file with MIME::Types, maybe not valid content-type?"
mini_magick_processing_error: "Failed to manipulate the file, maybe it is not an image?"
rmagick_processing_error: "Falha ao manipular com rmagick, talvez não seja uma imagem?"
mime_types_processing_error: "Falha ao processar arquivo com MIME::Types, talvez tipo de conteúdo inválido?"
mini_magick_processing_error: "Falha ao manipular o arquivo, talvez não seja uma imagem?"
wrong_size: "é o tamanho errado (deveria ser %{file_size})"
size_too_small: "é muito pequeno (deve ser pelo menos %{file_size})"
size_too_big: "é muito grande (deve ser no máximo %{file_size})"

View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'test_helper'
module Trainings; end
class Trainings::AvailabilitiesTest < ActionDispatch::IntegrationTest
def setup
@admin = User.find_by(username: 'admin')
login_as(@admin, scope: :user)
end
test 'get trainings availabilities list' do
training = Training.find(1)
get "/api/trainings/#{training.id}/availabilities"
# Check response format & status
assert_equal 200, response.status, response.body
assert_equal Mime[:json], response.content_type
# Check the correct training was returned
result = json_response(response.body)
assert_equal training.id, result[:id], 'training id does not match'
assert_not_empty result[:availabilities], 'no training availabilities were returned'
end
end