Browse Source

fix: mauvaises dates dans la liste des évènements

master
François Vaux 10 years ago
parent
commit
5dd438e8e4
2 changed files with 11 additions and 1 deletions
  1. +10
    -0
      app/models/event.rb
  2. +1
    -1
      app/views/items/show.html.erb

+ 10
- 0
app/models/event.rb View File

@ -24,4 +24,14 @@ class Event < ActiveRecord::Base
def anchor
'event-%s' % id.to_s(16)
end
def bookings_between(lower, upper)
bookings_range(lower.at_midnight, 1.day.since(upper).at_midnight - 1)
end
private
def bookings_range(lower, upper)
self.bookings.find :all,
:conditions => ['start_at >= ? AND end_at <= ?', lower, upper]
end
end

+ 1
- 1
app/views/items/show.html.erb View File

@ -49,7 +49,7 @@
<ul class="booking-list">
<%=
render :partial => 'bookings/booking',
:collection => event.item.bookings_between(@date, upper)
:collection => event.bookings_between(@date, upper)
%>
</ul>
<p class="edit">