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

(bug) plan visibility is not applied

(bug) plan limit error message
(quality) improved error message
(ui) plan visibility cannot be under 7
This commit is contained in:
Sylvain 2023-03-16 12:02:08 +01:00
parent ba97de18d3
commit 328529809d
21 changed files with 66 additions and 58 deletions

View File

@ -293,6 +293,7 @@ export const PlanForm: React.FC<PlanFormProps> = ({ action, plan, onError, onSuc
formState={formState}
nullable
id="machines_visibility"
rules={{ min: { value: 7, message: t('app.admin.plan_form.visibility_minimum') } }}
type="number"
label={t('app.admin.plan_form.machines_visibility')} />
</div>

View File

@ -67,7 +67,7 @@ class CartItem::Reservation < CartItem::BaseItem
unless ReservationLimitService.authorized?(plan, customer, self, all_items)
errors.add(:reservation, I18n.t('cart_item_validation.limit_reached', {
HOURS: ReservationLimitService.limit(plan, reservable),
HOURS: ReservationLimitService.limit(plan, reservable).limit,
RESERVABLE: reservable.name
}))
return false

View File

@ -119,7 +119,7 @@ class Availabilities::AvailabilitiesService
end
# @param availabilities [ActiveRecord::Relation<Availability>]
# @param type [String]
# @param type [String] 'training', 'space', 'machines' or 'event'
# @param user [User]
# @param range_start [ActiveSupport::TimeWithZone]
# @param range_end [ActiveSupport::TimeWithZone]

View File

@ -11,7 +11,7 @@ class Availabilities::VisibilityService
end
# @param user [User,NilClass]
# @param available_type [String] 'training', 'space', 'machine' or 'event'
# @param available_type [String] 'training', 'space', 'machines' or 'event'
# @param range_start [ActiveSupport::TimeWithZone]
# @param range_end [ActiveSupport::TimeWithZone]
# @return [Array<ActiveSupport::TimeWithZone,Date,Time>] as: [start,end]
@ -44,7 +44,7 @@ class Availabilities::VisibilityService
# @return [Time,NilClass]
def subscription_visibility(user, available_type)
return nil unless user&.subscribed_plan
return nil unless available_type == 'machine'
return nil unless available_type == 'machines'
machines = user&.subscribed_plan&.machines_visibility
machines&.hours&.since

View File

@ -194,6 +194,7 @@ de:
slots_visibility: "Slots visibility"
slots_visibility_help: "You can determine how far in advance subscribers can view and reserve machine slots. When this setting is set, it takes precedence over the general settings."
machines_visibility: "Visibility time limit, in hours (machines)"
visibility_minimum: "Visibility cannot be less than 7 hours"
save: "Save"
create_success: "Plan(s) successfully created. Don't forget to redefine prices."
update_success: "The plan was updated successfully"

View File

@ -194,6 +194,7 @@ en:
slots_visibility: "Slots visibility"
slots_visibility_help: "You can determine how far in advance subscribers can view and reserve machine slots. When this setting is set, it takes precedence over the general settings."
machines_visibility: "Visibility time limit, in hours (machines)"
visibility_minimum: "Visibility cannot be less than 7 hours"
save: "Save"
create_success: "Plan(s) successfully created. Don't forget to redefine prices."
update_success: "The plan was updated successfully"

View File

@ -194,6 +194,7 @@ es:
slots_visibility: "Slots visibility"
slots_visibility_help: "You can determine how far in advance subscribers can view and reserve machine slots. When this setting is set, it takes precedence over the general settings."
machines_visibility: "Visibility time limit, in hours (machines)"
visibility_minimum: "Visibility cannot be less than 7 hours"
save: "Save"
create_success: "Plan(s) successfully created. Don't forget to redefine prices."
update_success: "The plan was updated successfully"

View File

@ -194,6 +194,7 @@ fr:
slots_visibility: "Visibilité des créneaux"
slots_visibility_help: "Vous pouvez déterminer combien de temps en avance les abonnés peuvent voir et réserver les créneaux machines. Lorsque ce paramètre est défini, il devient prioritaire sur les paramètres généraux."
machines_visibility: "Délai de visibilité, en heures (machines)"
visibility_minimum: "La visibilité ne peut pas être inférieure à 7 heures"
save: "Enregistrer"
create_success: "Création du/des formule(s) d'abonnement réussie(s). N'oubliez pas de redéfinir les tarifs."
update_success: "La formule d'abonnement a bien été mise à jour"

View File

@ -194,6 +194,7 @@
slots_visibility: "Slots visibility"
slots_visibility_help: "You can determine how far in advance subscribers can view and reserve machine slots. When this setting is set, it takes precedence over the general settings."
machines_visibility: "Visibility time limit, in hours (machines)"
visibility_minimum: "Visibility cannot be less than 7 hours"
save: "Save"
create_success: "Plan(s) successfully created. Don't forget to redefine prices."
update_success: "The plan was updated successfully"

View File

@ -194,6 +194,7 @@ pt:
slots_visibility: "Slots visibility"
slots_visibility_help: "You can determine how far in advance subscribers can view and reserve machine slots. When this setting is set, it takes precedence over the general settings."
machines_visibility: "Visibility time limit, in hours (machines)"
visibility_minimum: "Visibility cannot be less than 7 hours"
save: "Save"
create_success: "Plan(s) successfully created. Don't forget to redefine prices."
update_success: "The plan was updated successfully"

View File

@ -194,6 +194,7 @@ zu:
slots_visibility: "crwdns37491:0crwdne37491:0"
slots_visibility_help: "crwdns37493:0crwdne37493:0"
machines_visibility: "crwdns37495:0crwdne37495:0"
visibility_minimum: "crwdns37589:0crwdne37589:0"
save: "crwdns37411:0crwdne37411:0"
create_success: "crwdns31957:0crwdne31957:0"
update_success: "crwdns31959:0crwdne31959:0"

View File

@ -521,7 +521,7 @@ de:
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"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription. Please adjust your reservation."
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
plan_group: "This subscription plan is reserved for members of group %{GROUP}"

0
config/locales/devise.pt.yml Executable file → Normal file
View File

View File

@ -2,62 +2,62 @@
zu:
devise:
confirmations:
confirmed: "crwdns3771:0crwdne3771:0"
send_instructions: "crwdns3773:0crwdne3773:0"
send_paranoid_instructions: "crwdns3775:0crwdne3775:0"
confirmed: "crwdns37497:0crwdne37497:0"
send_instructions: "crwdns37499:0crwdne37499:0"
send_paranoid_instructions: "crwdns37501:0crwdne37501:0"
failure:
already_authenticated: "crwdns3777:0crwdne3777:0"
inactive: "crwdns3779:0crwdne3779:0"
invalid: "crwdns3781:0crwdne3781:0"
locked: "crwdns3783:0crwdne3783:0"
last_attempt: "crwdns3785:0crwdne3785:0"
not_found_in_database: "crwdns3787:0crwdne3787:0"
timeout: "crwdns3789:0crwdne3789:0"
unauthenticated: "crwdns3791:0crwdne3791:0"
unconfirmed: "crwdns19573:0crwdne19573:0"
already_authenticated: "crwdns37503:0crwdne37503:0"
inactive: "crwdns37505:0crwdne37505:0"
invalid: "crwdns37507:0crwdne37507:0"
locked: "crwdns37509:0crwdne37509:0"
last_attempt: "crwdns37511:0crwdne37511:0"
not_found_in_database: "crwdns37513:0crwdne37513:0"
timeout: "crwdns37515:0crwdne37515:0"
unauthenticated: "crwdns37517:0crwdne37517:0"
unconfirmed: "crwdns37519:0crwdne37519:0"
mailer:
confirmation_instructions:
action: "crwdns20182:0crwdne20182:0"
instruction: "crwdns20184:0crwdne20184:0"
subject: "crwdns3799:0crwdne3799:0"
action: "crwdns37521:0crwdne37521:0"
instruction: "crwdns37523:0crwdne37523:0"
subject: "crwdns37525:0crwdne37525:0"
reset_password_instructions:
action: "crwdns20186:0crwdne20186:0"
instruction: "crwdns20188:0crwdne20188:0"
ignore_otherwise: "crwdns20190:0crwdne20190:0"
subject: "crwdns3807:0crwdne3807:0"
action: "crwdns37527:0crwdne37527:0"
instruction: "crwdns37529:0crwdne37529:0"
ignore_otherwise: "crwdns37531:0crwdne37531:0"
subject: "crwdns37533:0crwdne37533:0"
unlock_instructions:
subject: "crwdns3809:0crwdne3809:0"
subject: "crwdns37535:0crwdne37535:0"
omniauth_callbacks:
failure: "crwdns3811:0%{kind}crwdnd3811:0%{reason}crwdne3811:0"
success: "crwdns3813:0%{kind}crwdne3813:0"
failure: "crwdns37537:0%{kind}crwdnd37537:0%{reason}crwdne37537:0"
success: "crwdns37539:0%{kind}crwdne37539:0"
passwords:
no_token: "crwdns3815:0crwdne3815:0"
send_instructions: "crwdns3817:0crwdne3817:0"
send_paranoid_instructions: "crwdns3819:0crwdne3819:0"
updated: "crwdns3821:0crwdne3821:0"
updated_not_active: "crwdns3823:0crwdne3823:0"
no_token: "crwdns37541:0crwdne37541:0"
send_instructions: "crwdns37543:0crwdne37543:0"
send_paranoid_instructions: "crwdns37545:0crwdne37545:0"
updated: "crwdns37547:0crwdne37547:0"
updated_not_active: "crwdns37549:0crwdne37549:0"
registrations:
destroyed: "crwdns3825:0crwdne3825:0"
signed_up: "crwdns3827:0crwdne3827:0"
signed_up_but_inactive: "crwdns3829:0crwdne3829:0"
signed_up_but_locked: "crwdns3831:0crwdne3831:0"
signed_up_but_unconfirmed: "crwdns3833:0crwdne3833:0"
update_needs_confirmation: "crwdns3835:0crwdne3835:0"
updated: "crwdns3837:0crwdne3837:0"
destroyed: "crwdns37551:0crwdne37551:0"
signed_up: "crwdns37553:0crwdne37553:0"
signed_up_but_inactive: "crwdns37555:0crwdne37555:0"
signed_up_but_locked: "crwdns37557:0crwdne37557:0"
signed_up_but_unconfirmed: "crwdns37559:0crwdne37559:0"
update_needs_confirmation: "crwdns37561:0crwdne37561:0"
updated: "crwdns37563:0crwdne37563:0"
sessions:
signed_in: "crwdns3839:0crwdne3839:0"
signed_out: "crwdns3841:0crwdne3841:0"
signed_in: "crwdns37565:0crwdne37565:0"
signed_out: "crwdns37567:0crwdne37567:0"
unlocks:
send_instructions: "crwdns3843:0crwdne3843:0"
send_paranoid_instructions: "crwdns3845:0crwdne3845:0"
unlocked: "crwdns3847:0crwdne3847:0"
send_instructions: "crwdns37569:0crwdne37569:0"
send_paranoid_instructions: "crwdns37571:0crwdne37571:0"
unlocked: "crwdns37573:0crwdne37573:0"
errors:
messages:
already_confirmed: "crwdns19575:0crwdne19575:0"
confirmation_period_expired: "crwdns3851:0%{period}crwdne3851:0"
expired: "crwdns3853:0crwdne3853:0"
not_found: "crwdns19577:0crwdne19577:0"
not_locked: "crwdns3857:0crwdne3857:0"
already_confirmed: "crwdns37575:0crwdne37575:0"
confirmation_period_expired: "crwdns37577:0%{period}crwdne37577:0"
expired: "crwdns37579:0crwdne37579:0"
not_found: "crwdns37581:0crwdne37581:0"
not_locked: "crwdns37583:0crwdne37583:0"
not_saved:
one: "crwdns3859:1%{resource}crwdne3859:1"
other: "crwdns3859:5%{count}crwdnd3859:5%{resource}crwdne3859:5"
one: "crwdns37585:1%{resource}crwdne37585:1"
other: "crwdns37585:5%{count}crwdnd37585:5%{resource}crwdne37585:5"

View File

@ -521,7 +521,7 @@ en:
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"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription. Please adjust your reservation."
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
plan_group: "This subscription plan is reserved for members of group %{GROUP}"

View File

@ -521,7 +521,7 @@ es:
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"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription. Please adjust your reservation."
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
plan_group: "This subscription plan is reserved for members of group %{GROUP}"

View File

@ -521,7 +521,7 @@ fr:
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"
limit_reached: "Vous avez atteint la limite de réservation de %{HOURS}H par jour pour la %{RESERVABLE}, pour votre abonnement actuel"
limit_reached: "Vous avez atteint la limite de réservation de %{HOURS}H par jour pour la %{RESERVABLE}, pour votre abonnement actuel. Merci d'ajuster votre réservation."
restricted: "Cette disponibilité n'est disponible que pour les abonnés"
plan: "Cette formule d'abonnement est désactivé"
plan_group: "Cette formule d'abonnement est réservée aux membres du groupe %{GROUP}"

View File

@ -521,7 +521,7 @@
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"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription. Please adjust your reservation."
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
plan_group: "This subscription plan is reserved for members of group %{GROUP}"

View File

@ -521,7 +521,7 @@ pt:
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"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription"
limit_reached: "You have reached the booking limit of %{HOURS}H per day for the %{RESERVABLE}, for your current subscription. Please adjust your reservation."
restricted: "This availability is restricted for subscribers"
plan: "This subscription plan is disabled"
plan_group: "This subscription plan is reserved for members of group %{GROUP}"

View File

@ -521,7 +521,7 @@ zu:
availability: "crwdns36269:0crwdne36269:0"
full: "crwdns36271:0crwdne36271:0"
deadline: "crwdns36273:0%{MINUTES}crwdne36273:0"
limit_reached: "crwdns37475:0%{HOURS}crwdnd37475:0%{RESERVABLE}crwdne37475:0"
limit_reached: "crwdns37587:0%{HOURS}crwdnd37587:0%{RESERVABLE}crwdne37587:0"
restricted: "crwdns36275:0crwdne36275:0"
plan: "crwdns36277:0crwdne36277:0"
plan_group: "crwdns37207:0%{GROUP}crwdne37207:0"

View File

@ -123,7 +123,7 @@ class Availabilities::VisibilityServiceTest < ActiveSupport::TestCase
plan.update(machines_visibility: 48)
starting = Time.current.beginning_of_day
ending = 1.month.from_now.end_of_day
window = Availabilities::VisibilityService.new.visibility(@with_subscription, 'machine', starting, ending)
window = Availabilities::VisibilityService.new.visibility(@with_subscription, 'machines', starting, ending)
assert_datetimes_equal Time.current, window[0]
assert_datetimes_equal 48.hours.from_now, window[1]
end