Skip to content

Commit

Permalink
Added past event data in seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
sunilkr committed May 3, 2021
1 parent 964a664 commit 5a06db4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ class Event < ActiveRecord::Base
has_many :event_registrations, :dependent => :destroy

before_create :set_automatic_values! # Defaults
after_create :slugify!
#after_create :slugify!
before_create :slugify!
after_create :notify_admin_on_create
after_save :setup_scheduled_tasks, :if => lambda { public_changed? }

Expand Down Expand Up @@ -147,7 +148,7 @@ def to_param
# ActiveRecord :on_create
def slugify!
self.slug = "#{self.chapter.name} #{self.name.parameterize} #{self.id}".parameterize
self.save()
#self.save()
end

def external_url()
Expand Down
28 changes: 28 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,32 @@
published: true
})
end

## Past data
10.times do |i|
e = Event.create({
venue_id: i+1,
chapter_id: i+1,
event_type_id: 1+rand(3),
name: "Past Event Test-#{i}",
public: true,
can_show_on_homepage: true,
can_show_on_archive: true,
accepting_registration: true,
max_registration: 100,
start_time: Time.now + 1.hour - i.days,
end_time: Time.now - i.days + 6.hour,
registration_start_time: Time.now - i.days,
registration_end_time: Time.now + i.days + 1.year
})
e.save(:validate => false)
e.event_sessions.create({
user_id: 1,
name: "Past Event Session #{i}",
description: "Past Event Description #{i}",
placeholder: false,
start_time: e.start_time + 1.hour,
end_time: e.start_time + 2.hour
})
end
end
2 changes: 1 addition & 1 deletion docker-compose-full-stack.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
db:
image: mysql:5.5
image: mysql:5
volumes:
- swachalit-mysql:/var/lib/mysql
env_file:
Expand Down

0 comments on commit 5a06db4

Please sign in to comment.