event_calendar_engine 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/events_controller.rb +24 -7
- data/app/models/event.rb +4 -9
- data/app/views/events/_details.html.erb +2 -0
- data/app/views/events/index.html.erb +5 -23
- data/public/javascripts/event_calendar/event_calendar.js +2 -5
- data/public/stylesheets/event_calendar/blueprint/screen.css +1 -1
- data/spec/controllers/events_controller_spec.rb +9 -28
- data/spec/models/event_spec.rb +4 -8
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
@@ -2,20 +2,37 @@ class EventsController < EventCalendar::ApplicationController
|
|
2
2
|
|
3
3
|
# before_filter :load_and_authorize_current_user, :except => [:index, :show]
|
4
4
|
|
5
|
+
private
|
6
|
+
def events_to_json
|
7
|
+
return {} unless @events
|
8
|
+
json = @events.map do |event|
|
9
|
+
{
|
10
|
+
:id => event.id,
|
11
|
+
:title => event.name,
|
12
|
+
:start => event.start_on,
|
13
|
+
:end => event.end_on,
|
14
|
+
:url => event_path(event),
|
15
|
+
:details => render_to_string(:partial => 'events/details', :object => event)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
json.to_json
|
19
|
+
end
|
20
|
+
protected
|
21
|
+
public
|
22
|
+
|
5
23
|
# GET /events
|
6
24
|
# GET /events.xml
|
7
25
|
def index
|
8
|
-
|
26
|
+
if params[:start] && params[:end]
|
27
|
+
@events = Event.between(Time.at(params[:start].to_i), Time.at(params[:end].to_i))
|
28
|
+
else
|
29
|
+
@events = Event.find :all
|
30
|
+
end
|
9
31
|
|
10
32
|
respond_to do |format|
|
11
33
|
format.html # index.html.erb
|
12
34
|
format.xml { render :xml => @events }
|
13
|
-
format.js
|
14
|
-
json = @events.map do |e|
|
15
|
-
e.to_hash_for_calendar(event_path(e))
|
16
|
-
end
|
17
|
-
render :json => json.to_json
|
18
|
-
end
|
35
|
+
format.js { render :json => events_to_json }
|
19
36
|
end
|
20
37
|
end
|
21
38
|
|
data/app/models/event.rb
CHANGED
@@ -22,6 +22,10 @@ class Event < ActiveRecord::Base
|
|
22
22
|
scope :past, where(sanitize_sql_array(["end_on < '%s'", Date.current]))
|
23
23
|
scope :future, where(sanitize_sql_array(["start_on > '%s'", Date.current]))
|
24
24
|
scope :current, where(sanitize_sql_array(["end_on >= '%s' AND start_on <= '%s'", Date.current, Date.current]))
|
25
|
+
scope :between, lambda{ |start_date, end_date|
|
26
|
+
where(["start_on BETWEEN ? AND ? OR end_on BETWEEN ? AND ?",
|
27
|
+
start_date, end_date, start_date, end_date])
|
28
|
+
}
|
25
29
|
|
26
30
|
validate :sane_dates
|
27
31
|
|
@@ -100,15 +104,6 @@ class Event < ActiveRecord::Base
|
|
100
104
|
def to_s
|
101
105
|
"#{name} (#{start_on} #{end_on ? ' - ' + end_on.to_s : ''})"
|
102
106
|
end
|
103
|
-
|
104
|
-
def to_hash_for_calendar(url)
|
105
|
-
# { :id => id, :title => name_and_file_count, :start => start_on, :end => end_on, :url => "/events/#{id}",
|
106
|
-
# :description => description && description.gsub("\n", "<br/>") || '',
|
107
|
-
# :location => location && location.gsub("\n", "<br/>") || '' }
|
108
|
-
{ :id => id, :title => name, :start => start_on, :end => end_on, :url => url,
|
109
|
-
:description => description && description.gsub("\n", "<br/>") || '',
|
110
|
-
:location => location && location.gsub("\n", "<br/>") || '' }
|
111
|
-
end
|
112
107
|
|
113
108
|
# list all groups that had least one member in attendance at this event
|
114
109
|
# def contact_groups_represented
|
@@ -2,38 +2,20 @@
|
|
2
2
|
|
3
3
|
<p><em>mouse over an event to preview; click on an event for full details</em></p>
|
4
4
|
|
5
|
-
<div id="
|
6
|
-
<div id="calendar_one_month" class="calendars"></div>
|
7
|
-
<div id="calendar_two_months" class="calendars"></div>
|
5
|
+
<div id="calendar" class="calendars"></div>
|
8
6
|
|
9
7
|
<div style="clear:both"></div>
|
8
|
+
|
10
9
|
<div id="event_quick_description" style="display:none"></div>
|
11
10
|
|
12
11
|
<% content_for :javascript do %>
|
13
12
|
<script type="text/javascript">
|
14
13
|
$(document).ready(function()
|
15
14
|
{
|
16
|
-
$(
|
17
|
-
|
18
|
-
|
19
|
-
editable: false, events: '<%= events_path %>', height: 300, aspectRatio: 1.2,
|
20
|
-
buttonText: { today:null, prev:null, next: null }, eventMouseover: updateEventDescription
|
21
|
-
});
|
22
|
-
|
23
|
-
$('#calendar_one_month').fullCalendar({
|
24
|
-
editable: false, events: '<%= events_path %>', height: 300, aspectRatio: 1.2,
|
25
|
-
buttonText: { today:null, prev:null, next: null }, eventMouseover: updateEventDescription
|
15
|
+
$('#calendar').fullCalendar({
|
16
|
+
editable: false, events: '<%= events_path %>', height: 500, aspectRatio: 1,
|
17
|
+
eventMouseover: updateEventDescription
|
26
18
|
});
|
27
|
-
|
28
|
-
$('#calendar_two_months').fullCalendar({
|
29
|
-
editable: false, events: '<%= events_path %>', height: 300, aspectRatio: 1.2,
|
30
|
-
buttonText: { today:null }, eventMouseover: updateEventDescription,
|
31
|
-
month: $('#calendar_one_month').fullCalendar('getDate').getMonth() + 1,
|
32
|
-
viewDisplay: function(view) {
|
33
|
-
$('#calendar_now').fullCalendar('gotoDate', $('#calendar_two_months').fullCalendar('getDate').getFullYear(), $('#calendar_two_months').fullCalendar('getDate').getMonth() - 2);
|
34
|
-
$('#calendar_one_month').fullCalendar('gotoDate', $('#calendar_two_months').fullCalendar('getDate').getFullYear(), $('#calendar_two_months').fullCalendar('getDate').getMonth() - 1);
|
35
|
-
}
|
36
|
-
});
|
37
19
|
}
|
38
20
|
);
|
39
21
|
|
@@ -1,14 +1,11 @@
|
|
1
1
|
// use to give the preview of details for an event below a calendar
|
2
2
|
var updateEventDescription = function(event, jsEvent) {
|
3
|
-
$("#event_quick_description")
|
3
|
+
$("#event_quick_description").empty();
|
4
4
|
$("#event_quick_description").append(
|
5
5
|
$("<h3/>").append(
|
6
6
|
$('<a/>', { text : event.title, href : event.url })
|
7
7
|
)
|
8
|
-
);
|
9
|
-
$("#event_quick_description")[0].innerHTML += "Location: " + event.location + "<br/>";
|
10
|
-
$("#event_quick_description")[0].innerHTML += event.description;
|
11
|
-
|
8
|
+
).append(event.details);
|
12
9
|
$("#event_quick_description").show();
|
13
10
|
}
|
14
11
|
|
@@ -372,7 +372,7 @@ table.fc-header {width:100%;}
|
|
372
372
|
.fc-event-vert span.fc-event-title {line-height:13px;}
|
373
373
|
.fc-event-vert span.fc-event-bg {position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background:#fff;opacity:.3;filter:alpha(opacity=30);}
|
374
374
|
.fc-event-vert .ui-resizable-s {bottom:0 !important;width:100% !important;height:8px !important;line-height:8px !important;font-size:11px !important;font-family:monospace;text-align:center;cursor:s-resize;}
|
375
|
-
.calendars {
|
375
|
+
.calendars {padding-right:20px;}
|
376
376
|
#event_quick_description {clear:both;border:1px solid #999;background:#FFC;padding:12px;margin-top:15px;}
|
377
377
|
.fc-grid table {margin-bottom:0
|
378
378
|
;}
|
@@ -3,30 +3,6 @@ require 'spec_helper'
|
|
3
3
|
describe require 'spec_helper'
|
4
4
|
|
5
5
|
describe EventsController do
|
6
|
-
# def mock_admin_user(stubs={})
|
7
|
-
# @mock_admin_user ||= mock_model(User, stubs.merge({
|
8
|
-
# :role => 'admin',
|
9
|
-
# :contact => mock_model(Contact, {
|
10
|
-
# :first_name => 'First',
|
11
|
-
# :last_name => 'Last',
|
12
|
-
# :email => 'test@test.com'
|
13
|
-
# })
|
14
|
-
# }))
|
15
|
-
# end
|
16
|
-
|
17
|
-
# def mock_user(stubs={})
|
18
|
-
# @mock_user ||= mock_model(User, stubs.merge({:role => 'general'}))
|
19
|
-
# end
|
20
|
-
|
21
|
-
describe "when logged in as admin" do
|
22
|
-
before do
|
23
|
-
# pending
|
24
|
-
# controller.stub(:current_user_session).and_return(
|
25
|
-
# mock_model(UserSession, {
|
26
|
-
# :user => mock_admin_user
|
27
|
-
# })
|
28
|
-
# )
|
29
|
-
end
|
30
6
|
|
31
7
|
describe "GET index" do
|
32
8
|
it "assigns all events as @events" do
|
@@ -38,8 +14,14 @@ describe EventsController do
|
|
38
14
|
|
39
15
|
describe "GET index as json" do
|
40
16
|
it "renders @events as json" do
|
41
|
-
mock_event
|
42
|
-
|
17
|
+
mock_event({
|
18
|
+
:name => 'Some Event',
|
19
|
+
:start_on => Date.yesterday,
|
20
|
+
:end_on => Date.tomorrow,
|
21
|
+
:description => 'Some Description',
|
22
|
+
:location => 'Some City'
|
23
|
+
})
|
24
|
+
Event.stub(:between).and_return([mock_event])
|
43
25
|
get :index, :format => 'js'
|
44
26
|
response.should be_success
|
45
27
|
end
|
@@ -162,7 +144,6 @@ describe EventsController do
|
|
162
144
|
delete :destroy, :id => "1"
|
163
145
|
response.should redirect_to(events_url)
|
164
146
|
end
|
165
|
-
end
|
166
|
-
end
|
147
|
+
end
|
167
148
|
|
168
149
|
end
|
data/spec/models/event_spec.rb
CHANGED
@@ -32,6 +32,10 @@ describe Event do
|
|
32
32
|
it "Event.current finds current events" do
|
33
33
|
Event.current.first.should eql @current
|
34
34
|
end
|
35
|
+
|
36
|
+
it "Event.between finds events between limits" do
|
37
|
+
Event.between(Date.new(2100,3,1), Date.new(2100,3,30)).first.should eql @mar_2100
|
38
|
+
end
|
35
39
|
|
36
40
|
it "should create a new instance given valid attributes" do
|
37
41
|
Event.create!(@valid_attributes)
|
@@ -49,14 +53,6 @@ describe Event do
|
|
49
53
|
Event.existing_event_types.should == ['Conference', 'Meeting']
|
50
54
|
end
|
51
55
|
|
52
|
-
it "should call to_hash_for_calendar" do
|
53
|
-
event = Event.create! :name => "test", :start_on => "2010-01-01", :end_on => "2010-01-07",
|
54
|
-
:event_type => "meeting", :description => "some kind of meeting", :location => 'skype.address'
|
55
|
-
event.to_hash_for_calendar("/events/#{event.id}").should == { :id => event.id, :title => "test",
|
56
|
-
:start => Date.new(2010,1,1), :end => Date.new(2010,1,7), :url => "/events/#{event.id}",
|
57
|
-
:description => "some kind of meeting", :location => 'skype.address' }
|
58
|
-
end
|
59
|
-
|
60
56
|
it "should create a new version when an attribute is updated" do
|
61
57
|
event = Event.create!(@valid_attributes)
|
62
58
|
event.revision_number.should == 0
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event_calendar_engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 7
|
10
|
+
version: 0.1.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason LaPier
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-23 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -414,6 +414,7 @@ files:
|
|
414
414
|
- app/views/event_revisions/index.html.erb
|
415
415
|
- app/views/event_revisions/show.html.erb
|
416
416
|
- app/views/events/_browse_event_revisions.html.erb
|
417
|
+
- app/views/events/_details.html.erb
|
417
418
|
- app/views/events/_event.html.erb
|
418
419
|
- app/views/events/_event_details.html.erb
|
419
420
|
- app/views/events/_form.html.erb
|