From e7b24063336b5a6f68cf5faba4c39df22588bfc4 Mon Sep 17 00:00:00 2001 From: Konstantin Gredeskoul Date: Sat, 20 Apr 2024 13:55:00 -0700 Subject: [PATCH] Adding default values to Event creation (#94) * Adding default values to Event creation * Update with real defaults --- 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..3ae7afae 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: 250, + early_arrival_price: 20, + kid_ticket_price: 0, + late_departure_price: 20, + 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, + require_mailing_address: false, + allow_financial_assistance: true, + allow_donations: true + }.freeze + def admin?(user) user && (user.site_admin? || admins.exists?(id: user)) end