social_stream-events 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -44,6 +44,9 @@
44
44
  background-color: #F2F2F2;
45
45
  }
46
46
 
47
+ #sidebar_calendar td.busy {
48
+ font-weight: bold;
49
+ }
47
50
  .sidebar_calendar_month {
48
51
  text-align: center;
49
52
  padding: 5px;
@@ -1,5 +1,13 @@
1
1
  module EventsHelper
2
2
  def event_class(day)
3
+ begin_date = Time.now.beginning_of_week.to_date
4
+ end_date = begin_date + 28
5
+
6
+ busy_dates =
7
+ profile_or_current_subject.
8
+ events.
9
+ ocurrences(begin_date, end_date)
10
+
3
11
  [].tap { |css|
4
12
  css <<
5
13
  if day < Date.today
@@ -10,7 +18,9 @@ module EventsHelper
10
18
  "next_month"
11
19
  end
12
20
 
13
- #TODO: event ocurrence
21
+
22
+ css << "busy" if busy_dates.include?(day)
23
+
14
24
  }.join(" ")
15
25
  end
16
26
  end
data/app/models/event.rb CHANGED
@@ -9,12 +9,23 @@ class Event < ActiveRecord::Base
9
9
 
10
10
  validate :room_belongs_to_receiver
11
11
 
12
+ class << self
13
+ def ocurrences(start_date, end_date)
14
+ between(start_date, end_date).
15
+ map { |e|
16
+ e.ocurrences(start_date, end_date)
17
+ }.
18
+ flatten.
19
+ uniq
20
+ end
21
+ end
22
+
12
23
  def to_json(options = {})
13
24
  if recurrence
14
25
  st = options[:start].try(:to_date)
15
26
  en = (options[:end] || end_at.end_of_month + 7.days).to_date
16
27
 
17
- recurrence.events(:starts => st, :until => en).map do |d|
28
+ ocurrences(st, en).map do |d|
18
29
 
19
30
  start_diff = d - start_at.to_date
20
31
  end_diff = d - end_at.to_date
@@ -7,6 +7,12 @@ module SocialStream
7
7
  included do
8
8
  has_many :rooms
9
9
  end
10
+
11
+ module InstanceMethods
12
+ def events
13
+ Event.authored_by(self)
14
+ end
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Events
3
- VERSION = "0.3.2".freeze
3
+ VERSION = "0.4.0".freeze
4
4
  end
5
5
  end
@@ -4,8 +4,10 @@ module SocialStream
4
4
  module Events
5
5
  def sidebar_items type
6
6
  super.tap do |items|
7
- items.unshift :key => 'calendar',
8
- :html => render(:partial => 'events/sidebar_calendar')
7
+ if profile_or_current_subject
8
+ items.unshift :key => 'calendar',
9
+ :html => render(:partial => 'events/sidebar_calendar')
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.11.2')
16
- s.add_runtime_dependency('rails-scheduler', '~> 0.0.4')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.12.0')
16
+ s.add_runtime_dependency('rails-scheduler', '~> 0.0.5')
17
17
  s.add_runtime_dependency('coffee-rails', '> 3.1.0')
18
18
 
19
19
  # Development Gem dependencies
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-events
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,33 +10,33 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-12-23 00:00:00.000000000Z
13
+ date: 2012-01-11 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: social_stream-base
17
- requirement: &70335200 !ruby/object:Gem::Requirement
17
+ requirement: &83181790 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
- version: 0.11.2
22
+ version: 0.12.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70335200
25
+ version_requirements: *83181790
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rails-scheduler
28
- requirement: &70334950 !ruby/object:Gem::Requirement
28
+ requirement: &83181320 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.4
33
+ version: 0.0.5
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70334950
36
+ version_requirements: *83181320
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: coffee-rails
39
- requirement: &70334710 !ruby/object:Gem::Requirement
39
+ requirement: &83164280 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>'
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 3.1.0
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *70334710
47
+ version_requirements: *83164280
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: sqlite3-ruby
50
- requirement: &70334500 !ruby/object:Gem::Requirement
50
+ requirement: &83163630 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70334500
58
+ version_requirements: *83163630
59
59
  description: ! 'Social Stream is a Ruby on Rails engine providing your application
60
60
  with social networking features and activity streams.
61
61