refinerycms-sl-calendar 2.0.6.1 → 2.0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,8 +7,8 @@ module Refinery
7
7
  def index
8
8
  d = Date.parse(params[:date]) rescue nil
9
9
  @events = d.nil? ?
10
- Event.upcoming.order('refinery_calendar_events.from DESC') :
11
- Event.on_day(d).order('refinery_calendar_events.from DESC')
10
+ Event.upcoming.order('refinery_calendar_events.starts_at DESC') :
11
+ Event.on_day(d).order('refinery_calendar_events.starts_at DESC')
12
12
 
13
13
  # you can use meta fields from your model instead (e.g. browser_title)
14
14
  # by swapping @page for @event in the line below:
@@ -24,7 +24,7 @@ module Refinery
24
24
  end
25
25
 
26
26
  def archive
27
- @events = Event.archive.order('refinery_calendar_events.from DESC')
27
+ @events = Event.archive.order('refinery_calendar_events.starts_at DESC')
28
28
  render :template => 'refinery/calendar/events/index'
29
29
  end
30
30
 
@@ -17,12 +17,24 @@ module Refinery
17
17
 
18
18
  attr_accessor :locale
19
19
 
20
+ alias_attribute :from, :starts_at
21
+ alias_attribute :to, :ends_at
22
+
20
23
  delegate :name, :address,
21
24
  :to => :venue,
22
25
  :prefix => true,
23
26
  :allow_nil => true
24
27
 
25
- scope :on_day, lambda {|day| where('(refinery_calendar_events.`from` = ?) OR (refinery_calendar_events.`to` = ?) OR (refinery_calendar_events.`from` < ? AND (refinery_calendar_events.`to` > ?))', day, day, day, day) }
28
+ scope :starting_on_day, lambda {|day| where(starts_at: day.beginning_of_day..day.tomorrow.beginning_of_day) }
29
+ scope :ending_on_day, lambda {|day| where(ends_at: day.beginning_of_day..day.tomorrow.beginning_of_day) }
30
+
31
+ scope :on_day, lambda {|day|
32
+ where(
33
+ arel_table[:starts_at].in(day.beginning_of_day..day.tomorrow.beginning_of_day).
34
+ or(arel_table[:ends_at].in(day.beginning_of_day..day.tomorrow.beginning_of_day)).
35
+ or( arel_table[:starts_at].lt(day.beginning_of_day).and(arel_table[:ends_at].gt(day.tomorrow.beginning_of_day)) )
36
+ )
37
+ }
26
38
 
27
39
  class Translation
28
40
  attr_accessible :locale
@@ -30,7 +42,7 @@ module Refinery
30
42
 
31
43
  class << self
32
44
  def upcoming
33
- where('refinery_calendar_events.from >= ?', Time.now).with_globalize
45
+ where('refinery_calendar_events.starts_at >= ?', Time.now).with_globalize
34
46
  end
35
47
 
36
48
  def featured
@@ -38,7 +50,7 @@ module Refinery
38
50
  end
39
51
 
40
52
  def archive
41
- where('refinery_calendar_events.from < ?', Time.now).with_globalize
53
+ where('refinery_calendar_events.starts_at < ?', Time.now).with_globalize
42
54
  end
43
55
 
44
56
  # Wrap up the logic of finding the events based on the translations table.
@@ -1,4 +1,4 @@
1
- <% content_for :body_content_left do %>
1
+ <% content_for :body do %>
2
2
  <section id="events">
3
3
  <%= render @events %>
4
4
  </section>
@@ -0,0 +1,25 @@
1
+ class ChangeFromToAttributesInEvents < ActiveRecord::Migration
2
+ def up
3
+
4
+ add_column :refinery_calendar_events, :starts_at, :datetime
5
+ add_column :refinery_calendar_events, :ends_at, :datetime
6
+
7
+ Refinery::Calendar::Event.update_all '"starts_at" = "from", "ends_at" = "to"'
8
+
9
+ remove_column :refinery_calendar_events, :from, :datetime
10
+ remove_column :refinery_calendar_events, :to, :datetime
11
+
12
+ end
13
+
14
+ def down
15
+
16
+ add_column :refinery_calendar_events, :starts_at, :datetime
17
+ add_column :refinery_calendar_events, :ends_at, :datetime
18
+
19
+ Refinery::Calendar::Event.update_all '"starts_at" = "from", "ends_at" = "to"'
20
+
21
+ remove_column :refinery_calendar_events, :from, :datetime
22
+ remove_column :refinery_calendar_events, :to, :datetime
23
+
24
+ end
25
+ end
data/readme.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Calendar extension for Refinery CMS.
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/simplelogica/refinerycms-calendar.png)](http://travis-ci.org/simplelogica/refinerycms-calendar)
4
+
3
5
  This is a calendar gem for refinery forked from (https://github.com/refinery/refinerycms-calendar) with some additional features such as:
4
6
 
5
7
  * I18n support in models using Globalize3
@@ -9,7 +11,7 @@ This is a calendar gem for refinery forked from (https://github.com/refinery/ref
9
11
 
10
12
  ```ruby
11
13
  # in Gemfile:
12
- gem 'refinerycms-sl-calendar', '2.0.6'
14
+ gem 'refinerycms-sl-calendar', '~> 2.0.6.2'
13
15
  ```
14
16
 
15
17
  ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refinerycms-sl-calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6.1
4
+ version: 2.0.6.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -98,6 +98,7 @@ files:
98
98
  - config/database.yml.sqlite3
99
99
  - db/seeds.rb
100
100
  - db/migrate/4_create_calendar_venues_translations.rb
101
+ - db/migrate/5_change_from_to_attributes_in_events.rb
101
102
  - db/migrate/1_create_calendar_events.rb
102
103
  - db/migrate/3_create_calendar_events_translations.rb
103
104
  - db/migrate/2_create_calendar_venues.rb