public
Fork of insoshi/insoshi
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/diasjorge/insoshi.git
Events have comments. Showing event attendees
Jorge Dias (author)
Fri Aug 29 06:05:10 -0700 2008
commit  7eacda7299046d34ecd3a3b285e3ec482d442a4f
tree    1758bbd3e2588eeeb99cd2a09283374d08def48d
parent  c6a9ef2aa41402d128a666ef481f40071ee90297
...
53
54
55
 
 
56
57
58
...
91
92
93
 
 
94
95
96
...
100
101
102
 
 
103
104
105
...
115
116
117
 
 
118
119
120
...
124
125
126
 
 
127
128
129
...
136
137
138
 
 
 
 
139
...
53
54
55
56
57
58
59
60
...
93
94
95
96
97
98
99
100
...
104
105
106
107
108
109
110
111
...
121
122
123
124
125
126
127
128
...
132
133
134
135
136
137
138
139
...
146
147
148
149
150
151
152
153
0
@@ -53,6 +53,8 @@ class CommentsController < ApplicationController
0
       elsif blog?
0
         @blog = Blog.find(params[:blog_id])
0
         @post = Post.find(params[:post_id])
0
+ elsif event?
0
+ @event = Event.find(params[:event_id])
0
       end
0
     end
0
   
0
@@ -91,6 +93,8 @@ class CommentsController < ApplicationController
0
         @person.comments
0
       elsif blog?
0
         @post.comments.paginate(:page => params[:page])
0
+ elsif
0
+ @event.comments
0
       end
0
     end
0
     
0
@@ -100,6 +104,8 @@ class CommentsController < ApplicationController
0
         @person
0
       elsif blog?
0
         @post
0
+ elsif event?
0
+ @event
0
       end
0
     end
0
     
0
@@ -115,6 +121,8 @@ class CommentsController < ApplicationController
0
         "wall"
0
       elsif blog?
0
         "blog_post"
0
+ elsif event?
0
+ "event"
0
       end
0
     end
0
     
0
@@ -124,6 +132,8 @@ class CommentsController < ApplicationController
0
         @person
0
       elsif blog?
0
         blog_post_url(@blog, @post)
0
+ elsif event?
0
+ @event
0
       end
0
     end
0
 
0
@@ -136,4 +146,8 @@ class CommentsController < ApplicationController
0
     def blog?
0
       !params[:blog_id].nil?
0
     end
0
+
0
+ def event?
0
+ !params[:event_id].nil?
0
+ end
0
 end
...
22
23
24
 
25
26
27
...
22
23
24
25
26
27
28
0
@@ -22,6 +22,7 @@ class EventsController < ApplicationController
0
     @event = Event.find(params[:id])
0
     @date = @event.start_time.to_date
0
     @month_events = Event.monthly_events(@date).person_events(current_person)
0
+ @attendees = @event.attendees.paginate(:page => params[:page], :per_page => RASTER_PER_PAGE)
0
 
0
     respond_to do |format|
0
       format.html # show.html.erb
...
24
25
26
 
27
28
29
...
24
25
26
27
28
29
30
0
@@ -24,6 +24,7 @@ class Comment < ActiveRecord::Base
0
 
0
   belongs_to :person, :counter_cache => true
0
   belongs_to :post, :counter_cache => true, :foreign_key => "blog_post_id"
0
+ belongs_to :event
0
 
0
   has_many :activities, :foreign_key => "item_id", :dependent => :destroy
0
 
...
7
8
9
 
10
11
12
...
7
8
9
10
11
12
13
0
@@ -7,6 +7,7 @@ class Event < ActiveRecord::Base
0
   belongs_to :person
0
   has_many :event_attendees
0
   has_many :attendees, :through => :event_attendees, :source => :person
0
+ has_many :comments, :as => :commentable, :order => 'created_at DESC'
0
 
0
   validates_presence_of :title, :start_time, :person, :privacy
0
   validates_length_of :title, :maximum => MAX_TITLE_LENGTH
...
24
25
26
 
 
 
 
 
27
28
29
...
24
25
26
27
28
29
30
31
32
33
34
0
@@ -24,6 +24,11 @@
0
     | <%= link_to "Destroy", event, :confirm => 'Are you sure?', :method => :delete %>
0
     <% end -%>
0
   </p>
0
+ <% unless event.event_attendees_count == 0 -%>
0
+ <p>
0
+ <%= pluralize(event.event_attendees_count, 'Person') %> attending this event
0
+ </p>
0
+ <% end -%>
0
   <p>
0
     <% unless event.attending?(current_person) -%>
0
     <%= link_to "I will attend", attend_event_path(event) %>
...
1
2
3
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
6
7
...
1
 
 
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
0
@@ -1,7 +1,50 @@
0
 <% column_div :type => :primary do -%>
0
-<ul class="list full">
0
- <%= render :partial => @event %>
0
-<ul>
0
+ <h2>Event</h2>
0
+ <ul class="list full">
0
+ <%= render :partial => @event %>
0
+ </ul>
0
+
0
+ <h2>People attending this event</h2>
0
+ <% unless @attendees.empty? -%>
0
+ <% paginated_section @attendees do %>
0
+ <ul class="grid contacts medium">
0
+ <%- @attendees.each do |attendee| -%>
0
+ <li class="vcard attendee">
0
+ <%= image_link attendee, :image_options => { :class => "photo" },
0
+ :link_options => { :class => "url" },
0
+ :vcard => true,
0
+ :image => :bounded_icon %>
0
+ </li>
0
+ <%- end -%>
0
+ </ul>
0
+ <% end -%>
0
+ <% else -%>
0
+ This event doesn't have any attendees yet.
0
+ <% end -%>
0
+
0
+ <%- unless @event.comments.empty? -%>
0
+ <h2 id="comments">Comments</h4>
0
+ <ul class="list comments full">
0
+ <%= render :partial => 'comment', :collection => @event.comments %>
0
+ </ul>
0
+ <%- end -%>
0
+
0
+ <%- if logged_in? -%>
0
+ <h4>Leave a comment</h4>
0
+
0
+ <% form_for :comment, :url => event_comments_path(@event),
0
+ :html => { :id => "eventcomment" } do |f| %>
0
+ <div class="form_row">
0
+ <%= f.text_area :body, :rows => 10 %>
0
+ </div>
0
+
0
+ <div class="form_row">
0
+ <%= submit_tag "Submit", :class => "button" %>
0
+ </div>
0
+ <% end %>
0
+
0
+ <%- end -%>
0
+
0
 <% end -%>
0
 
0
 <% column_div :type => :secondary do -%>
...
1
2
 
 
 
 
3
4
5
...
1
 
2
3
4
5
6
7
8
0
@@ -1,5 +1,8 @@
0
 ActionController::Routing::Routes.draw do |map|
0
- map.resources :events, :member => { :attend => :get, :unattend => :get }
0
+ map.resources :events, :member => { :attend => :get,
0
+ :unattend => :get } do |event|
0
+ event.resources :comments
0
+ end
0
 
0
   map.resources :preferences
0
   map.resources :searches
...
50
51
52
53
 
54
55
56
...
62
63
64
65
 
66
...
50
51
52
 
53
54
55
56
...
62
63
64
 
65
66
0
@@ -50,7 +50,7 @@
0
   color: white;
0
 }
0
 .specialDay a, .specialDay a:visited, .specialDay a:hover {
0
- color: white;
0
+ color: red;
0
   text-decoration: none;
0
   padding: 0.1em;
0
 }
0
@@ -62,5 +62,5 @@
0
   background-color: #ffffdd;
0
 }
0
 .today{
0
- background-color: #4682b4;
0
+ background-color: #4682b4;
0
 }
...
14
15
16
17
 
 
18
19
20
...
69
70
71
72
 
73
74
 
75
76
77
78
79
80
81
82
83
...
14
15
16
 
17
18
19
20
21
...
70
71
72
 
73
74
75
76
77
78
79
80
81
 
82
83
84
0
@@ -14,7 +14,8 @@ describe EventsController do
0
       :destroy => true,
0
       :person => @person,
0
       :to_xml => '',
0
- :start_time => Time.now
0
+ :start_time => Time.now,
0
+ :attendees => []
0
     }.merge(stubs)
0
     @mock_event ||= mock_model(Event, stubs)
0
   end
0
@@ -69,15 +70,15 @@ describe EventsController do
0
   describe "responding to GET /events/1" do
0
 
0
     it "should succeed" do
0
- Event.stub!(:find).and_return(mock_event)
0
+ Event.stub!(:find).and_return(mock_event)
0
       get :show, :id => "1"
0
       response.should be_success
0
+ response.should render_template('show')
0
     end
0
   
0
     it "should render the 'show' template" do
0
       Event.stub!(:find).and_return(mock_event)
0
       get :show, :id => "1"
0
- response.should render_template('show')
0
     end
0
   
0
     it "should find the requested event" do
...
11
12
13
 
 
 
 
 
 
...
11
12
13
14
15
16
17
18
19
0
@@ -11,3 +11,9 @@ blog_comment:
0
   body: MyText
0
   commentable: blog_post
0
   commentable_type: BlogPost
0
+
0
+event_comment:
0
+ commenter: aaron
0
+ body: MyText
0
+ commentable: public
0
+ commentable_type: Event
...
61
62
63
 
 
 
 
 
 
 
 
 
 
 
64
...
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
0
@@ -61,4 +61,15 @@ describe Event do
0
                                         
0
   end
0
 
0
+ describe "comments association" do
0
+ before(:each) do
0
+ @event = events(:public)
0
+ end
0
+
0
+ it "should have many comments" do
0
+ @event.comments.should be_a_kind_of(Array)
0
+ @event.comments.should_not be_empty
0
+ end
0
+ end
0
+
0
 end

Comments

    No one has commented yet.