incubator-olio-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wso...@apache.org
Subject svn commit: r748294 - in /incubator/olio/webapp/rails/trunk/app: controllers/events_controller.rb helpers/events_helper.rb models/event.rb models/image.rb views/events/_attendees.html.erb
Date Thu, 26 Feb 2009 20:44:09 GMT
Author: wsobel
Date: Thu Feb 26 20:44:09 2009
New Revision: 748294

URL: http://svn.apache.org/viewvc?rev=748294&view=rev
Log:
Fix for OLIO-57. Attendence list only has 20 items and 21 if user is attending.

Modified:
    incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb
    incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb
    incubator/olio/webapp/rails/trunk/app/models/event.rb
    incubator/olio/webapp/rails/trunk/app/models/image.rb
    incubator/olio/webapp/rails/trunk/app/views/events/_attendees.html.erb

Modified: incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb?rev=748294&r1=748293&r2=748294&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb Thu Feb 26 20:44:09
2009
@@ -6,6 +6,8 @@
     :attend, :unattend, :tag
   ]
   protect_from_forgery :only => [:update, :destroy, :delete, :create]
+
+  MAX_ATTENDEES = 20
   
   # caches_page :index
     
@@ -44,9 +46,9 @@
   # GET /events/1
   # GET /events/1.xml  
   def show
-    @event = Event.find(params[:id], :include => [:users, :image, :document, {:comments
=> :user }, :address])
+    @event = Event.find(params[:id], :include => [:image, :document, {:comments =>
:user }, :address])
     @address = @event.address
-    @attendees = @event.users
+    @attendees = attendee_list(@event, MAX_ATTENDEES)
     @image = @event.image
     @document = @event.document
     @comments = @event.comments
@@ -237,7 +239,7 @@
       end
     end
     
-    @attendees = @event.users
+    @attendees = attendee_list(@event, MAX_ATTENDEES)
     
     respond_to do |format|
       format.html { redirect_to(event_path(@event)) }
@@ -259,7 +261,7 @@
       end
     end
     
-    @attendees = @event.users
+    @attendees = attendee_list(@event, MAX_ATTENDEES)
     
     respond_to do |format|
       format.html { redirect_to(event_path(@event)) }
@@ -314,5 +316,18 @@
   def new_document?
     return (params[:event_document] == '') ? false : true
   end
+
+  def attendee_list(event, max)
+    users = event.users.find(:all, :limit => max)
+    if session[:user_id]
+      included = users.find { |u| u.id == session[:user_id] }
+      p included
+      p event.users.count(:conditions => ["users.id = ?",  session[:user_id]])
+      if !included and event.users.count(:conditions => ["users.id = ?",  session[:user_id]])
> 0
+        users<< (@user || User.find(session[:user_id]))
+      end
+    end
+    users
+  end
   
 end

Modified: incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb?rev=748294&r1=748293&r2=748294&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb Thu Feb 26 20:44:09 2009
@@ -3,7 +3,7 @@
   def attendance_links(event)
     links = ""
     if logged_in?
-      attending = event.users.map{ |u| u.id }.include?(session[:user_id])
+      attending = @attendees.find { |u| u.id == session[:user_id] }
       if attending
         links += form_remote_tag :url => unattend_event_path(event), :method => :post,
:html => {:method => :post}
         links += submit_tag "Unattend"

Modified: incubator/olio/webapp/rails/trunk/app/models/event.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/models/event.rb?rev=748294&r1=748293&r2=748294&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/models/event.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/models/event.rb Thu Feb 26 20:44:09 2009
@@ -48,7 +48,7 @@
   end
   
   def new_attendee(user)
-    users << user if user.valid? && !users.include?(user)
+    users << user if !users.include?(user)
   end
   
   def remove_attendee(user)

Modified: incubator/olio/webapp/rails/trunk/app/models/image.rb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/models/image.rb?rev=748294&r1=748293&r2=748294&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/models/image.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/models/image.rb Thu Feb 26 20:44:09 2009
@@ -27,6 +27,13 @@
   validates_uniqueness_of :filename
   validates_as_attachment
   
+  # Overload the thumbnail name so it's compatible with the php file generator.
+  def thumbnail_name_for(thumbnail = nil)
+    name = super
+    name.sub!(/_thumb/, 't')
+    name
+  end
+  
   include Uploadable
   
 end

Modified: incubator/olio/webapp/rails/trunk/app/views/events/_attendees.html.erb
URL: http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/_attendees.html.erb?rev=748294&r1=748293&r2=748294&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/events/_attendees.html.erb (original)
+++ incubator/olio/webapp/rails/trunk/app/views/events/_attendees.html.erb Thu Feb 26 20:44:09
2009
@@ -1,5 +1,5 @@
 <div id="attendees">
-  <h2 class="smaller_heading"><%= pluralize @attendees.size, 'Attendee' %>:</h2><br/>
+  <h2 class="smaller_heading">At least <%= pluralize @attendees.size, 'Attendee'
%>:</h2><br/>
   
   <%= attendance_links(@event) %> 
 
@@ -13,4 +13,4 @@
     </ol>
   <% end -%>
 
-</div>
\ No newline at end of file
+</div>



Mime
View raw message