diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-11-30 22:48:13 +0000 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2012-11-30 22:48:13 +0000 |
commit | 45ae88e9087e87852f76bfbd62bcf6e66500da70 (patch) | |
tree | 2925d9aa72aaf5bdcfa57ee358e6237f831026eb /views | |
parent | 494de72e43b0f294aed3b5006b0793ae3ab8a545 (diff) |
Improved logic in the events calendar -- should be faster now.
Diffstat (limited to 'views')
-rw-r--r-- | views/_events_calendar_day.haml | 13 | ||||
-rw-r--r-- | views/events_calendar.haml | 5 |
2 files changed, 9 insertions, 9 deletions
diff --git a/views/_events_calendar_day.haml b/views/_events_calendar_day.haml index 1b42520..fa0c517 100644 --- a/views/_events_calendar_day.haml +++ b/views/_events_calendar_day.haml @@ -1,14 +1,15 @@ %td{:class => (@today.month % 2 == 0 ? "even" : "odd")} %p.event_date %a{:href => "/events/list/#{@today.strftime("%F")}?#{request.query_string}"} - = @today.strftime(((@today - 1.day).month != @today.month) ? "%d %b" : "%d") - =partial("history", :collection => events_calendar_day.first(10)) + = @today.strftime(((@today - 1).month != @today.month) ? "%d %b" : "%d") + =partial("history", :collection => events_calendar_day.last(10).to_a.reverse) %p - - if events_calendar_day.length > 10 + - n_events = events_calendar_day.count + - if n_events > 10 There are - = events_calendar_day.length - 10 + = n_events - 10 more events to display. - - if events_calendar_day.length > 0 + - if n_events > 0 %a{:href => "/events/list/#{@today.strftime("%F")}?#{request.query_string}"} Show the whole day. - - @today += 1.day + - @today += 1 diff --git a/views/events_calendar.haml b/views/events_calendar.haml index e3cec5e..0ff4e17 100644 --- a/views/events_calendar.haml +++ b/views/events_calendar.haml @@ -1,11 +1,10 @@ %h2 Events Calendar - %p - %a{:href => "/events/calendar/#{(@month-31.days).strftime("%Y-%m")}?"+request.query_string} + %a{:href => "/events/calendar/#{(@month << 1).strftime("%Y-%m")}?"+request.query_string} ← Previous Month = @month.strftime("%b %Y") - %a{:href => "/events/calendar/#{(@month+31.days).strftime("%Y-%m")}?"+request.query_string} + %a{:href => "/events/calendar/#{(@month >> 1).strftime("%Y-%m")}?"+request.query_string} Next month → = partial('events_form') = partial('events_calendar') |