From b10077f8f8de548527f9166d69fafd28bf0275e1 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Fri, 19 Apr 2024 17:59:42 -0700 Subject: [PATCH 1/2] Adding default values to Event creation --- app/controllers/events_controller.rb | 2 +- app/models/event.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index de4e01a1..9c286c34 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -23,7 +23,7 @@ def show end def new - @event = Event.new + @event = Event.new(Event::DEFAULT_ATTRIBUTES) end def edit diff --git a/app/models/event.rb b/app/models/event.rb index ff70c420..5fd15b89 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -71,6 +71,21 @@ class Event < ApplicationRecord validate :end_time_after_start_time, :sales_end_time_after_start_time, :ensure_prices_set_if_maximum_specified + DEFAULT_ATTRIBUTES = { + adult_ticket_price: 150, + early_arrival_price: 20, + kid_ticket_price: 50, + late_departure_price: 20, + max_adult_tickets_per_request: 4, + max_kid_tickets_per_request: 2, + max_cabins_per_request: 1, + max_cabin_requests: 2, + tickets_require_approval: true, + require_mailing_address: false, + allow_financial_assistance: true, + allow_donations: true + }.freeze + def admin?(user) user && (user.site_admin? || admins.exists?(id: user)) end From bd8d102e4b5dfa9f4049998487eab0a2e7ff9a5e Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 20 Apr 2024 12:13:11 -0700 Subject: [PATCH 2/2] Update with real defaults --- app/models/event.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index 5fd15b89..3ae7afae 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -72,12 +72,12 @@ class Event < ApplicationRecord :ensure_prices_set_if_maximum_specified DEFAULT_ATTRIBUTES = { - adult_ticket_price: 150, + adult_ticket_price: 250, early_arrival_price: 20, - kid_ticket_price: 50, + kid_ticket_price: 0, late_departure_price: 20, - max_adult_tickets_per_request: 4, - max_kid_tickets_per_request: 2, + max_adult_tickets_per_request: 10, + max_kid_tickets_per_request: 4, max_cabins_per_request: 1, max_cabin_requests: 2, tickets_require_approval: true,