From 5a06db4d8be4bfd9dcfb17beb759965445b364e1 Mon Sep 17 00:00:00 2001 From: sunilkr Date: Mon, 3 May 2021 14:11:51 +0530 Subject: [PATCH] Added past event data in seeds --- app/models/event.rb | 5 +++-- db/seeds.rb | 28 ++++++++++++++++++++++++++++ docker-compose-full-stack.yml | 2 +- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index e432b39..2a88bd9 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -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? } @@ -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() diff --git a/db/seeds.rb b/db/seeds.rb index f58643c..c85b8c1 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -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 diff --git a/docker-compose-full-stack.yml b/docker-compose-full-stack.yml index 8ba9db7..7953863 100644 --- a/docker-compose-full-stack.yml +++ b/docker-compose-full-stack.yml @@ -1,7 +1,7 @@ version: '2' services: db: - image: mysql:5.5 + image: mysql:5 volumes: - swachalit-mysql:/var/lib/mysql env_file: