noosfero | Agenda shows by default all the events but says that they are from the month (#71)
Eduardo Vital
gitlab at gitlab.com
Wed May 27 19:14:21 BRT 2015
New comment for Issue 71
https://gitlab.com/noosfero/noosfero/issues/71#note_1292936
Author: Eduardo Vital
There are two options in my opinion to solve that.
+ stop showing all the events by default, altering the __events_controler__ in method events from
```ruby
if !params[:year] && !params[:month] && !params[:day]
@events = profile.events.next_events_from_month(@date).paginate(:per_page => per_page, :page => params[:page])
end
if params[:year] || params[:month]
@events = profile.events.by_month(@date).paginate(:per_page => per_page, :page => params[:page])
end
```
to
```ruby
@events = profile.events.by_month(@date).paginate(:per_page => per_page, :page => params[:page])
```
---
+ Show a different title by default, altering the __events_helper__ from
```ruby
def list_events(date, events)
title = _('Events for %s') % show_date_month(date)
content_tag('h2', title) +
content_tag('div',
(events.any? ?
content_tag('table', events.select { |item| item.display_to?(user) }.map {|item| display_event_in_listing(item)}.join('')) :
content_tag('em', _('No events for this month'), :class => 'no-events')
), :id => 'agenda-items'
)
end
```
to
```ruby
def list_events(date, events)
#Fix me. I am ugly.
if events == profile.events.next_events_from_month(Date.today).paginate(:per_page => 20, :page => params[:page])
title = _('All Future Events') % show_date_month(date)
else
title = _('Events for %s') % show_date_month(date)
end
content_tag('h2', title) +
content_tag('div',
(events.any? ?
content_tag('table', events.select { |item| item.display_to?(user) }.map {|item| display_event_in_listing(item)}.join('')) :
content_tag('em', _('No events for this month'), :class => 'no-events')
), :id => 'agenda-items'
)
end
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150527/a6d4d18a/attachment-0001.html>
More information about the Noosfero-dev
mailing list