Skip to content

Commit

Permalink
Adding default values to Event creation (#94)
Browse files Browse the repository at this point in the history
* Adding default values to Event creation

* Update with real defaults
  • Loading branch information
kigster authored Apr 20, 2024
1 parent 1c774aa commit e7b2406
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def show
end

def new
@event = Event.new
@event = Event.new(Event::DEFAULT_ATTRIBUTES)
end

def edit
Expand Down
15 changes: 15 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e7b2406

Please sign in to comment.