1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(quality) translate validation messages

This commit is contained in:
Sylvain 2023-01-04 11:12:02 +01:00
parent 7bb97d267d
commit 8ce1ceb345
26 changed files with 119 additions and 15 deletions

View File

@ -107,6 +107,7 @@
<div class="section-separator"></div>
<div class="row">
<h3 class="m-l m-t-lg" translate>{{ 'app.admin.settings.reservation_deadline' }}</h3>
<p class="alert alert-warning m-h-md" translate>{{ 'app.admin.settings.reservation_deadline_help' }}</p>
<number-setting name="reservation_deadline"
settings="allSettings"
label="app.admin.settings.deadline_minutes"

View File

@ -33,7 +33,15 @@ class CartItem::MachineReservation < CartItem::Reservation
canceled_at: nil
).count
if same_hour_slots.positive?
@errors[:slot] = 'slot is reserved'
@errors[:slot] = I18n.t('cart_item_validation.reserved')
return false
end
if @reservable.disabled
@errors[:reservable] = I18n.t('cart_item_validation.machine')
return false
end
unless @reservable.reservable
@errors[:reservable] = I18n.t('cart_item_validation.reservable')
return false
end
end

View File

@ -39,7 +39,7 @@ class CartItem::PaymentSchedule
return true unless @requested && @plan&.monthly_payment
if @plan&.disabled
@errors[:item] = 'plan is disabled'
@errors[:item] = I18n.t('cart_item_validation.plan')
return false
end
true

View File

@ -40,7 +40,7 @@ class CartItem::PrepaidPack < CartItem::BaseItem
def valid?(_all_items)
if @pack.disabled
@errors[:item] = 'pack is disabled'
@errors[:item] = I18n.t('cart_item_validation.pack')
return false
end
true

View File

@ -49,30 +49,30 @@ class CartItem::Reservation < CartItem::BaseItem
@slots.each do |slot|
slot_db = Slot.find(slot[:slot_id])
if slot_db.nil?
@errors[:slot] = 'slot does not exist'
@errors[:slot] = I18n.t('cart_item_validation.slot')
return false
end
availability = Availability.find_by(id: slot[:slot_attributes][:availability_id])
if availability.nil?
@errors[:availability] = 'availability does not exist'
@errors[:availability] = I18n.t('cart_item_validation.availability')
return false
end
if slot_db.full?
@errors[:slot] = 'availability is full'
@errors[:slot] = I18n.t('cart_item_validation.full')
return false
end
if slot_db.start_at < reservation_deadline && !@operator.privileged?
@errors[:slot] = "cannot reserve a slot #{reservation_deadline_minutes} minutes prior to its start"
@errors[:slot] = I18n.t('cart_item_validation.deadline', { MINUTES: reservation_deadline_minutes })
return false
end
next if availability.plan_ids.empty?
next if required_subscription?(availability, pending_subscription)
@errors[:availability] = 'availability is restricted for subscribers'
@errors[:availability] = I18n.t('cart_item_validation.restricted')
return false
end

View File

@ -28,7 +28,7 @@ class CartItem::SpaceReservation < CartItem::Reservation
def valid?(all_items)
if @space.disabled
@errors[:reservable] = 'space is disabled'
@errors[:reservable] = I18n.t('cart_item_validation.space')
return false
end

View File

@ -44,7 +44,7 @@ class CartItem::Subscription < CartItem::BaseItem
def valid?(_all_items)
if @plan.disabled
@errors[:item] = 'plan is disabled'
@errors[:item] = I18n.t('cart_item_validation.plan')
return false
end
true

View File

@ -1475,6 +1475,7 @@ de:
visibility_for_yearly_members: "Für derzeit laufende Abonnements, mindestens 1 Jahr lang"
visibility_for_other_members: "Für alle anderen Mitglieder"
reservation_deadline: "Prevent last minute booking"
reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start."
deadline_minutes: "Prior period (minutes)"
ability_for_the_users_to_move_their_reservations: "Möglichkeit für die Benutzer, ihre Reservierungen zu verschieben"
reservations_shifting: "Verschiebung von Reservierungen"

View File

@ -1475,6 +1475,7 @@ en:
visibility_for_yearly_members: "For currently running subscriptions, at least 1 year long"
visibility_for_other_members: "For all other members"
reservation_deadline: "Prevent last minute booking"
reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start."
deadline_minutes: "Prior period (minutes)"
ability_for_the_users_to_move_their_reservations: "Ability for the users to move their reservations"
reservations_shifting: "Reservations shifting"

View File

@ -1475,6 +1475,7 @@ es:
visibility_for_yearly_members: "Para las suscripciones en curso, por lo menos 1 año"
visibility_for_other_members: "Para todos los demás miembros"
reservation_deadline: "Prevent last minute booking"
reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start."
deadline_minutes: "Prior period (minutes)"
ability_for_the_users_to_move_their_reservations: "Capacidad para que los usuarios muevan sus reservas"
reservations_shifting: "Cambio de reservas"

View File

@ -1474,7 +1474,8 @@ fr:
max_visibility: "Visibilité maximum (en mois)"
visibility_for_yearly_members: "Pour les abonnements en cours d'au moins 1 an"
visibility_for_other_members: "Pour tous les autres membres"
reservation_deadline: "date limite de réservation"
reservation_deadline: "Empêcher les réservations de dernière minute"
reservation_deadline_help: "Si vous augmentez le délai préalable, les membres ne pourront pas réserver un créneau X minutes avant le début de celui-ci."
deadline_minutes: "Délai préalable (en minutes)"
ability_for_the_users_to_move_their_reservations: "Possibilité pour l'utilisateur de déplacer ses réservations"
reservations_shifting: "Déplacement des réservations"

View File

@ -1475,6 +1475,7 @@
visibility_for_yearly_members: "Abonnementer med varighet på minst 1 år"
visibility_for_other_members: "For alle andre medlemmer"
reservation_deadline: "Prevent last minute booking"
reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start."
deadline_minutes: "Prior period (minutes)"
ability_for_the_users_to_move_their_reservations: "Om brukerne kan flytte sine bestillinger"
reservations_shifting: "Reservasjonsendringer"

View File

@ -1475,6 +1475,7 @@ pt:
visibility_for_yearly_members: "Para inscrições atuais de pelo menos 1 ano"
visibility_for_other_members: "Para todos os outros membros"
reservation_deadline: "Prevent last minute booking"
reservation_deadline_help: "If you increase the prior period, members won't be able to book a slot X minutes before its start."
deadline_minutes: "Prior period (minutes)"
ability_for_the_users_to_move_their_reservations: "Habilidade para os usuários mover suas reservas"
reservations_shifting: "Mudança de reservas"

View File

@ -1475,6 +1475,7 @@ zu:
visibility_for_yearly_members: "crwdns26446:0crwdne26446:0"
visibility_for_other_members: "crwdns26448:0crwdne26448:0"
reservation_deadline: "crwdns31751:0crwdne31751:0"
reservation_deadline_help: "crwdns36265:0crwdne36265:0"
deadline_minutes: "crwdns31753:0crwdne31753:0"
ability_for_the_users_to_move_their_reservations: "crwdns26450:0crwdne26450:0"
reservations_shifting: "crwdns26452:0crwdne26452:0"

View File

@ -93,7 +93,7 @@ de:
phone_number_is_required: "Die Angabe der Telefonnummer ist erforderlich."
address: "Adresse"
address_is_required: "Adresse ist erforderlich"
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "I authorize users, registered on the site, to contact me"
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "Angemeldete Benutzer dürfen mich kontaktieren"
i_accept_to_receive_information_from_the_fablab: "Das Fablab darf mir Informationen schicken"
i_ve_read_and_i_accept_: "Ich habe gelesen und akzeptiere"
_the_fablab_policy: "the terms of use"

View File

@ -93,7 +93,7 @@ es:
phone_number_is_required: "El número de telefono es obligatorio."
address: "Dirección"
address_is_required: "Address is required"
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "I authorize users, registered on the site, to contact me"
i_authorize_Fablab_users_registered_on_the_site_to_contact_me: "Autorizo a los usuarios registrados en el sitio, a contactarme"
i_accept_to_receive_information_from_the_fablab: "Acepto recibir información del FabLab"
i_ve_read_and_i_accept_: "He leido y acepto"
_the_fablab_policy: "the terms of use"

View File

@ -489,6 +489,18 @@ de:
birthday_in_past: "Geburtsdatum muss in der Vergangenheit liegen"
order:
please_contact_FABLAB: "Please contact us for withdrawal instructions."
cart_item_validation:
slot: "The slot doesn't exist"
availability: "The availaility doesn't exist"
full: "The slot is already fully reserved"
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
reserved: "This slot is already reserved"
pack: "This prepaid pack is disabled"
space: "This space is disabled"
machine: "This machine is disabled"
reservable: "This machine is not reservable"
settings:
locked_setting: "die Einstellung ist gesperrt."
about_title: "Seitentitel \"Über\""

View File

@ -489,6 +489,18 @@ en:
birthday_in_past: "The date of birth must be in the past"
order:
please_contact_FABLAB: "Please contact us for withdrawal instructions."
cart_item_validation:
slot: "The slot doesn't exist"
availability: "The availaility doesn't exist"
full: "The slot is already fully reserved"
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
reserved: "This slot is already reserved"
pack: "This prepaid pack is disabled"
space: "This space is disabled"
machine: "This machine is disabled"
reservable: "This machine is not reservable"
settings:
locked_setting: "the setting is locked."
about_title: "\"About\" page title"

View File

@ -489,6 +489,18 @@ es:
birthday_in_past: "The date of birth must be in the past"
order:
please_contact_FABLAB: "Please contact us for withdrawal instructions."
cart_item_validation:
slot: "The slot doesn't exist"
availability: "The availaility doesn't exist"
full: "The slot is already fully reserved"
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
reserved: "This slot is already reserved"
pack: "This prepaid pack is disabled"
space: "This space is disabled"
machine: "This machine is disabled"
reservable: "This machine is not reservable"
settings:
locked_setting: "the setting is locked."
about_title: "\"About\" page title"

View File

@ -489,6 +489,18 @@ fr:
birthday_in_past: "La date de naissance doit être dans le passé"
order:
please_contact_FABLAB: "Veuillez nous contacter pour des instructions de retrait."
cart_item_validation:
slot: "Le créneau n'existe pas"
availability: "La disponibilité n'existe pas"
full: "Le créneau est déjà entièrement réservé"
deadline: "Vous ne pouvez pas réserver un créneau %{MINUTES} minutes avant son début"
restricted: "Cette disponibilité n'est disponible que pour les abonnés"
plan: "Cette formule d'abonnement est désactivé"
reserved: "Ce créneau est déjà réservé"
pack: "Ce pack prépayé est désactivé"
space: "Cet espace est désactivé"
machine: "Cette machine est désactivée"
reservable: "Cette machine n'est pas réservable"
settings:
locked_setting: "le paramètre est verrouillé."
about_title: "Le titre de la page \"À propos\""

View File

@ -489,6 +489,18 @@
birthday_in_past: "The date of birth must be in the past"
order:
please_contact_FABLAB: "Please contact us for withdrawal instructions."
cart_item_validation:
slot: "The slot doesn't exist"
availability: "The availaility doesn't exist"
full: "The slot is already fully reserved"
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
reserved: "This slot is already reserved"
pack: "This prepaid pack is disabled"
space: "This space is disabled"
machine: "This machine is disabled"
reservable: "This machine is not reservable"
settings:
locked_setting: "innstillingen er låst."
about_title: "\"Om\" sidetittel"

View File

@ -489,6 +489,18 @@ pt:
birthday_in_past: "A data de nascimento deve estar no passado"
order:
please_contact_FABLAB: "Please contact us for withdrawal instructions."
cart_item_validation:
slot: "The slot doesn't exist"
availability: "The availaility doesn't exist"
full: "The slot is already fully reserved"
deadline: "You can't reserve a slot %{MINUTES} minutes prior to its start"
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
reserved: "This slot is already reserved"
pack: "This prepaid pack is disabled"
space: "This space is disabled"
machine: "This machine is disabled"
reservable: "This machine is not reservable"
settings:
locked_setting: "a configuração está bloqueada."
about_title: "\"Sobre\" título da página"

View File

@ -489,6 +489,18 @@ zu:
birthday_in_past: "crwdns22127:0crwdne22127:0"
order:
please_contact_FABLAB: "crwdns31721:0crwdne31721:0"
cart_item_validation:
slot: "crwdns36267:0crwdne36267:0"
availability: "crwdns36269:0crwdne36269:0"
full: "crwdns36271:0crwdne36271:0"
deadline: "crwdns36273:0%{MINUTES}crwdne36273:0"
restricted: "crwdns36275:0crwdne36275:0"
plan: "crwdns36277:0crwdne36277:0"
reserved: "crwdns36279:0crwdne36279:0"
pack: "crwdns36281:0crwdne36281:0"
space: "crwdns36283:0crwdne36283:0"
machine: "crwdns36285:0crwdne36285:0"
reservable: "crwdns36287:0crwdne36287:0"
settings:
locked_setting: "crwdns21632:0crwdne21632:0"
about_title: "crwdns21634:0crwdne21634:0"

View File

@ -41,7 +41,7 @@ class Exports::MembersExportTest < ActionDispatch::IntegrationTest
# test data
wb = workbook[I18n.t('export_members.members')]
member = User.find(wb.sheet_data[1][0].value)
assert_equal (member.is_allow_newsletter ? 1 : nil), wb.sheet_data[1][4].value
assert_equal (member.is_allow_newsletter ? 1 : 0), wb.sheet_data[1][4].value
# Clean XLSX file
require 'fileutils'

View File

@ -40,7 +40,7 @@ class Reservations::LastMinuteTest < ActionDispatch::IntegrationTest
# general assertions
assert_equal 422, response.status
assert_match(/cannot reserve a slot 120 minutes prior to its start/, response.body)
assert_match(I18n.t('cart_item_validation.deadline', { MINUTES: 120 }), response.body)
end
test 'user can reserve last minute booking' do

View File

@ -10,6 +10,10 @@ class AccountingWorkerTest < ActiveSupport::TestCase
@worker = AccountingWorker.new
end
teardown do
Sidekiq::Testing.fake!
end
test 'build accounting lines for yesterday by default' do
date = DateTime.current.midnight
travel_to(date)