Commit 0834d18f42c40789861855d3e760842dadf8712c

Authored by Paulo Meireles
1 parent 4eb56579

improving agenda/events

Show events by month
Event list now only show 10 events when listing events for month
(events for a day still listing all events)
Add information on indefined place
Enhance layout

(ActionItem2587)

Signed-off-by: Marcos Ramos <ms.ramos@outlook.com>
Signed-off-by: Arthur Del Esposte <arthurmde@yahoo.com.br>
Signed-off-by: Luiz Matos <luizff.matos@gmail.com>
Signed-off-by: Carlos Andre <carlos.andre.souza@msn.com>
Signed-off-by: Leandro Alves <leandrosustenido@gmail.com>
Signed-off-by: Tales Martins <tales.martins@gmail.com>
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com>
Signed-off-by; Gabriela Navarro <navarro1703@gmail.com>
app/controllers/public/events_controller.rb
1 1 class EventsController < PublicController
2 2  
3 3 needs_profile
4   - no_design_blocks
5 4  
6 5 def events
7   - @selected_day = nil
8   - @events_of_the_day = []
9   - date = build_date(params[:year], params[:month], params[:day])
  6 + @events = []
  7 + @date = build_date(params[:year], params[:month], params[:day])
10 8  
11   - if params[:day] || !params[:year] && !params[:month]
12   - @selected_day = date
13   - @events_of_the_day = profile.events.by_day(@selected_day)
  9 + if !params[:year] && !params[:month] && !params[:day]
  10 + @events = profile.events.next_events_from_month(@date)
14 11 end
15 12  
16   - events = profile.events.by_range((date - 1.month).at_beginning_of_month..(date + 1.month).at_end_of_month)
  13 + if params[:year] || params[:month]
  14 + @events = profile.events.by_month(@date)
  15 + end
  16 +
  17 + events_in_range = profile.events.by_range((@date - 1.month).at_beginning_of_month .. (@date + 1.month).at_end_of_month)
17 18  
18   - @calendar = populate_calendar(date, events)
19   - @previous_calendar = populate_calendar(date - 1.month, events)
20   - @next_calendar = populate_calendar(date + 1.month, events)
  19 + @calendar = populate_calendar(@date, events_in_range)
  20 + @previous_calendar = populate_calendar(@date - 1.month, events_in_range)
  21 + @next_calendar = populate_calendar(@date + 1.month, events_in_range)
21 22 end
22 23  
23 24 def events_by_day
24   - @selected_day = build_date(params[:year], params[:month], params[:day])
25   - @events_of_the_day = profile.events.by_day(@selected_day)
26   - render :partial => 'events_by_day'
  25 + @date = build_date(params[:year], params[:month], params[:day])
  26 + @events = profile.events.by_day(@date)
  27 + render :partial => 'events'
27 28 end
28 29  
29 30 protected
... ...
app/controllers/public/search_controller.rb
... ... @@ -93,25 +93,29 @@ class SearchController &lt; PublicController
93 93 year = (params[:year] ? params[:year].to_i : Date.today.year)
94 94 month = (params[:month] ? params[:month].to_i : Date.today.month)
95 95 day = (params[:day] ? params[:day].to_i : Date.today.day)
96   - date = build_date(params[:year], params[:month], params[:day])
97   - date_range = (date - 1.month).at_beginning_of_month..(date + 1.month).at_end_of_month
  96 + @date = build_date(year, month, day)
  97 + date_range = (@date - 1.month).at_beginning_of_month..(@date + 1.month).at_end_of_month
98 98  
99   - @selected_day = nil
100   - @events_of_the_day = []
  99 + @events = []
101 100 if params[:day] || !params[:year] && !params[:month]
102   - @selected_day = date
103   - @events_of_the_day = @category ?
104   - environment.events.by_day(@selected_day).in_category(Category.find(@category_id)) :
105   - environment.events.by_day(@selected_day)
  101 + @events = @category ?
  102 + environment.events.by_day(@date).in_category(Category.find(@category_id)) :
  103 + environment.events.by_day(@date)
  104 + end
  105 +
  106 + if params[:year] || params[:month]
  107 + @events = @category ?
  108 + environment.events.by_month(@date).in_category(Category.find(@category_id)) :
  109 + environment.events.by_month(@date)
106 110 end
107 111  
108 112 @scope = date_range && params[:action] == 'events' ? environment.events.by_range(date_range) : environment.events
109 113 full_text_search
110 114  
111 115 events = @searches[@asset][:results]
112   - @calendar = populate_calendar(date, events)
113   - @previous_calendar = populate_calendar(date - 1.month, events)
114   - @next_calendar = populate_calendar(date + 1.month, events)
  116 + @calendar = populate_calendar(@date, events)
  117 + @previous_calendar = populate_calendar(@date - 1.month, events)
  118 + @next_calendar = populate_calendar(@date + 1.month, events)
115 119 end
116 120  
117 121 # keep old URLs workings
... ... @@ -136,9 +140,9 @@ class SearchController &lt; PublicController
136 140 end
137 141  
138 142 def events_by_day
139   - @selected_day = build_date(params[:year], params[:month], params[:day])
140   - @events_of_the_day = environment.events.by_day(@selected_day)
141   - render :partial => 'events/events_by_day'
  143 + @date = build_date(params[:year], params[:month], params[:day])
  144 + @events = environment.events.by_day(@date)
  145 + render :partial => 'events/events'
142 146 end
143 147  
144 148 #######################################################
... ...
app/helpers/dates_helper.rb
... ... @@ -35,6 +35,18 @@ module DatesHelper
35 35 end
36 36 end
37 37  
  38 + def show_date_month(date, use_numbers = false, year=true)
  39 + if date && use_numbers
  40 + date_format = year ? _('%{month}/%{year}') : _('%{month}/%{day}')
  41 + date_format % { :month => date.month, :year => date.year }
  42 + elsif date
  43 + date_format = year ? _('%{month_name}, %{year}') : _('%{month_name}')
  44 + date_format % { :month_name => month_name(date.month), :year => date.year }
  45 + else
  46 + ''
  47 + end
  48 + end
  49 +
38 50 # formats a datetime for displaying.
39 51 def show_time(time)
40 52 if time
... ... @@ -98,7 +110,11 @@ module DatesHelper
98 110 elsif opts[:previous]
99 111 date = date << 1
100 112 end
101   - _('%{month} %{year}') % { :year => date.year, :month => month_name(date.month.to_i) }
  113 + if opts[:only_month]
  114 + _('%{month}') % {:month => month_name(date.month.to_i) }
  115 + else
  116 + _('%{month} %{year}') % { :year => date.year, :month => month_name(date.month.to_i) }
  117 + end
102 118 end
103 119  
104 120 def build_date(year, month, day = 1)
... ... @@ -123,7 +139,7 @@ module DatesHelper
123 139 previous_month_date = date - 1.month
124 140  
125 141 label ||= show_month(previous_month_date.year, previous_month_date.month)
126   - link_to label, :year => previous_month_date.year, :month => previous_month_date.month
  142 + link_to label, {:year => previous_month_date.year, :month => previous_month_date.month}, {:class => 'button icon-back with-text'}
127 143 end
128 144  
129 145 def link_to_next_month(year, month, label = nil)
... ... @@ -131,7 +147,7 @@ module DatesHelper
131 147 next_month_date = date + 1.month
132 148  
133 149 label ||= show_month(next_month_date.year, next_month_date.month)
134   - link_to label, :year => next_month_date.year, :month => next_month_date.month
  150 + link_to label, {:year => next_month_date.year, :month => next_month_date.month}, {:class => 'button icon-next with-text'}
135 151 end
136 152  
137 153 def pick_date(object, method, options = {}, html_options = {})
... ...
app/helpers/events_helper.rb
1 1 module EventsHelper
2 2  
3 3 def list_events(date, events)
4   - return content_tag('em', _("Select a day on the left to display it's events here"), :class => 'select-a-day') unless date
5   - title = _('Events for %s') % show_date(date)
  4 + title = _('Events for %s') % show_date_month(date)
6 5 content_tag('h2', title) +
7 6 content_tag('div',
8 7 (events.any? ?
9 8 content_tag('table', events.select { |item| item.display_to?(user) }.map {|item| display_event_in_listing(item)}.join('')) :
10   - content_tag('em', _('No events for this date'), :class => 'no-events')
  9 + content_tag('em', _('No events for this month'), :class => 'no-events')
11 10 ), :id => 'agenda-items'
12 11 )
13 12 end
14 13  
15 14 def display_event_in_listing(article)
16   - content_tag(
17   - 'tr',
18   - content_tag('td', link_to(article.name, article.url, :class => icon_for_article(article))),
19   - :class => 'agenda-item'
  15 +
  16 + content_tag( 'tr',
  17 + content_tag('td',
  18 + content_tag('div', show_date(article.start_date) + ( article.end_date.nil? ? '' : (_(" to ") + show_date(article.end_date))),:class => 'event-date' ) +
  19 + content_tag('div',link_to(article.name,article.url),:class => 'event-title') +
  20 + content_tag('div',(article.address.nil? or article.address == '') ? '' : (_('Place: ') + article.address),:class => 'event-place')
  21 + )
20 22 )
21 23 end
22 24  
... ...
app/models/event.rb
... ... @@ -29,8 +29,29 @@ class Event &lt; Article
29 29 end
30 30 end
31 31  
32   - named_scope :by_day, lambda { |date|
33   - {:conditions => ['start_date = :date AND end_date IS NULL OR (start_date <= :date AND end_date >= :date)', {:date => date}]}
  32 +named_scope :by_day, lambda { |date|
  33 + {
  34 + :conditions => ['start_date = :date AND end_date IS NULL OR (start_date <= :date AND end_date >= :date)', {:date => date}],
  35 + :order => 'start_date ASC'
  36 + }
  37 + }
  38 +
  39 +named_scope :next_events_from_month, lambda { |date|
  40 + date_temp = date.strftime("%Y-%m-%d")
  41 + {
  42 + :conditions => ["start_date >= ?","#{date_temp}"],
  43 + :limit => 10,
  44 + :order => 'start_date ASC'
  45 + }
  46 + }
  47 +
  48 +named_scope :by_month, lambda { |date|
  49 + date_temp = date.strftime("%Y-%m")
  50 + {
  51 + :conditions => ["EXTRACT(YEAR FROM start_date) = ? AND EXTRACT(MONTH FROM start_date) = ?",date.year,date.month],
  52 + :limit => 10,
  53 + :order => 'start_date ASC'
  54 + }
34 55 }
35 56  
36 57 include WhiteListFilter
... ... @@ -105,7 +126,7 @@ class Event &lt; Article
105 126  
106 127 # TODO: some good soul, please clean this ugly hack:
107 128 if self.body
108   - html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description')
  129 + html.div('_____XXXX_DESCRIPTION_GOES_HERE_XXXX_____', :class => 'event-description')
109 130 end
110 131 }
111 132  
... ...
app/models/profile.rb
... ... @@ -193,7 +193,7 @@ class Profile &lt; ActiveRecord::Base
193 193  
194 194 has_many :tasks, :dependent => :destroy, :as => 'target'
195 195  
196   - has_many :events, :source => 'articles', :class_name => 'Event', :order => 'name'
  196 + has_many :events, :source => 'articles', :class_name => 'Event', :order => 'start_date'
197 197  
198 198 def find_in_all_tasks(task_id)
199 199 begin
... ...
app/views/events/_agenda.rhtml
... ... @@ -3,22 +3,14 @@
3 3 <table class='noborder current-month'>
4 4 <caption>
5 5 <h2><%= show_month(params[:year], params[:month]) %></h2>
6   - <%= link_to_previous_month(params[:year], params[:month], '&laquo; %s' % _('previous')) %>
7   - <%= link_to_next_month(params[:year], params[:month], '%s &raquo;' % _('next')) %>
  6 + <%= link_to_previous_month(params[:year], params[:month], show_month(params[:year], params[:month], :previous => true, :only_month => true)) %>
  7 + <%= link_to_next_month(params[:year], params[:month], show_month(params[:year], params[:month], :next => true, :only_month => true)) %>
8 8 </caption>
9 9 <%= render :partial => 'events/month', :locals => {:calendar => @calendar, :abbreviated => true} %>
10 10 </table>
11   - <table class='noborder previous-month'>
12   - <caption><h3><%= link_to_previous_month(params[:year], params[:month], show_month(params[:year], params[:month], :previous => true)) %></h3></caption>
13   - <%= render :partial => 'events/month', :locals => {:calendar => @previous_calendar, :abbreviated => true} %>
14   - </table>
15   - <table class='noborder next-month'>
16   - <caption><h3><%= link_to_next_month(params[:year], params[:month], show_month(params[:year], params[:month], :next => true)) %></h3></caption>
17   - <%= render :partial => 'events/month', :locals => {:calendar => @next_calendar, :abbreviated => true} %>
18   - </table>
19 11 <br clear='both'/>
20 12 </div>
21 13 <div id='events-of-the-day'>
22   - <%= render :partial => 'events/events_by_day' %>
  14 + <%= render :partial => 'events/events' %>
23 15 </div>
24 16 </div>
... ...
app/views/events/_events.rhtml 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= list_events(@date, @events) %>
0 2 \ No newline at end of file
... ...
app/views/events/_events_by_day.rhtml
... ... @@ -1 +0,0 @@
1   -<%= list_events(@selected_day, @events_of_the_day) %>
config/routes.rb
... ... @@ -55,6 +55,7 @@ ActionController::Routing::Routes.draw do |map|
55 55  
56 56 # events
57 57 map.events 'profile/:profile/events_by_day', :controller => 'events', :action => 'events_by_day', :profile => /#{Noosfero.identifier_format}/
  58 + map.events 'profile/:profile/events_by_month', :controller => 'events', :action => 'events_by_month', :profile => /#{Noosfero.identifier_format}/
58 59 map.events 'profile/:profile/events/:year/:month/:day', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :day => /\d*/, :profile => /#{Noosfero.identifier_format}/
59 60 map.events 'profile/:profile/events/:year/:month', :controller => 'events', :action => 'events', :year => /\d*/, :month => /\d*/, :profile => /#{Noosfero.identifier_format}/
60 61 map.events 'profile/:profile/events', :controller => 'events', :action => 'events', :profile => /#{Noosfero.identifier_format}/
... ...
features/events.feature
... ... @@ -12,43 +12,38 @@ Feature: events
12 12  
13 13 Scenario: go to next month
14 14 Given I am on /profile/josesilva/events/2009/10
15   - When I follow "next »"
  15 + When I follow "November"
16 16 Then I should see "November 2009" within ".current-month"
17 17  
18 18 Scenario: go to next month in global agenda
19 19 Given I am on /assets/events?year=2009&month=11
20   - When I follow "next »"
  20 + When I follow "December"
21 21 Then I should see "December 2009" within ".current-month"
22 22  
23 23 Scenario: go to previous month
24 24 Given I am on /profile/josesilva/events/2009/10
25   - When I follow "« previous"
  25 + When I follow "September"
26 26 Then I should see "September 2009" within ".current-month"
27 27  
28 28 Scenario: go to previous month in global agenda
29 29 Given I am on /assets/events?year=2009&month=11
30   - When I follow "« previous"
  30 + When I follow "October"
31 31 Then I should see "October 2009" within ".current-month"
32 32  
33 33 Scenario: go to next month by clicking in month name
34 34 Given I am on /profile/josesilva/events/2009/10
35   - When I follow "November 2009"
  35 + When I follow "November"
36 36 Then I should see "November 2009" within ".current-month"
37 37  
38 38 Scenario: go to previous month by clicking in month name
39 39 Given I am on /profile/josesilva/events/2009/10
40   - When I follow "September 2009"
  40 + When I follow "September"
41 41 Then I should see "September 2009" within ".current-month"
42 42  
43   - Scenario: go to specific day
44   - Given I am on the homepage
45   - When I am on /profile/josesilva/events/2009/01/20
46   - Then I should see "Events for January 20, 2009"
47   -
48 43 Scenario: go to specific day in global agenda
49 44 Given I am on the homepage
50 45 When I am on /assets/events?year=2009&month=11&day=12
51   - Then I should see "Events for November 12, 2009"
  46 + Then I should see "Events for November, 2009"
52 47  
53 48 Scenario: list events for specific day
54 49 Given I am on /profile/josesilva/events/2009/10
... ... @@ -64,7 +59,7 @@ Feature: events
64 59 | owner | name | start_date |
65 60 | josesilva | WikiSym 2009 | 2009-10-25 |
66 61 When I am on /profile/josesilva/events/2009/10/20
67   - Then I should not see "WikiSym 2009"
  62 + Then I should see "WikiSym 2009"
68 63  
69 64 Scenario: list event between a range
70 65 Given I am on /profile/josesilva/events/2009/10
... ... @@ -96,20 +91,11 @@ Feature: events
96 91 Then I should see "Another Conference"
97 92 And I should see "Manuel Birthday"
98 93  
99   - Scenario: ask for a day when no inform complete date
100   - When I am on /profile/josesilva/events/2009/5
101   - Then I should see "Select a day on the left to display it's events here"
102   -
103   - Scenario: ask for a day when no inform complete date in global agenda
104   - When I am on /assets/events?year=2009&month=5
105   - Then I should see "Select a day on the left to display it's events here"
106   -
  94 + @selenium
107 95 Scenario: provide links to days with events
108 96 Given I am on /profile/josesilva/events/2009/10
109 97 Then I should see "24" link
110   - When I follow "next »"
111   - Then I should see "24" link
112   - When I follow "next »"
  98 + When I follow "November"
113 99 Then I should not see "24" link
114 100  
115 101 Scenario: provide links to all days between start and end date
... ... @@ -128,7 +114,7 @@ Feature: events
128 114 @selenium
129 115 Scenario: show events when i follow a specific day
130 116 Given I am on /profile/josesilva/events/2009/10
131   - And I should not see "Another Conference"
  117 + And I should see "Another Conference"
132 118 When I follow "24"
133 119 Then I should see "Another Conference"
134 120  
... ... @@ -138,7 +124,7 @@ Feature: events
138 124 | owner | name | start_date | end_date |
139 125 | josesilva | YAPC::Brasil 2010 | 2010-10-30 | 2010-11-01 |
140 126 And I am on /profile/josesilva/events/2010/10
141   - And I should not see "YAPC::Brasil 2010"
  127 + And I should see "YAPC::Brasil 2010"
142 128 When I follow "31"
143 129 Then I should see "YAPC::Brasil 2010"
144 130  
... ... @@ -150,10 +136,6 @@ Feature: events
150 136 When I follow "Back to josesilva"
151 137 Then I should be on josesilva's homepage
152 138  
153   - Scenario: warn when there is no events
154   - When I am on /profile/josesilva/events/2020/12/1
155   - Then I should see "No events for this date"
156   -
157 139 Scenario: provide button to create new event
158 140 Given I am logged in as "josesilva"
159 141 When I am on /profile/josesilva/events/2020/12/1
... ... @@ -230,3 +212,35 @@ Feature: events
230 212 Then I should see "Leaded event"
231 213 And I should see "This is the abstract."
232 214 And I should not see "This is the real text."
  215 +
  216 + Scenario: show range date of event
  217 + Given I am on /profile/josesilva/events/2009/10
  218 + And the following events
  219 + | owner | name | start_date | end_date |
  220 + | josesilva | WikiSym 2009 | 2009-10-25 | 2009-10-27 |
  221 + When I am on /profile/josesilva/events/2009/10/26
  222 + Then I should see "October 25, 2009 to October 27, 2009"
  223 +
  224 + Scenario: show place of the event
  225 + Given I am on /profile/josesilva/events/2009/10
  226 + And the following events
  227 + | owner | name | start_date | end_date | address |
  228 + | josesilva | WikiSym 2009 | 2009-10-25 | 2009-10-27 | Earth Planet |
  229 + When I am on /profile/josesilva/events/2009/10/26
  230 + Then I should see "Place: Earth Planet"
  231 +
  232 + Scenario: show event name as link
  233 + Given the following events
  234 + | owner | name | start_date |
  235 + | josesilva | Unpublished event | 2009-10-25 |
  236 + And I am logged in as "josesilva"
  237 + When I am on /profile/josesilva/events/2009/10/25
  238 + Then I should see "Unpublished event" link
  239 +
  240 + Scenario: go to event page
  241 + Given the following events
  242 + | owner | name | start_date |
  243 + | josesilva | Oktoberfest | 2009-10-25 |
  244 + Given I am on /profile/josesilva/events/2009/10
  245 + When I follow "Oktoberfest"
  246 + Then I should see "Oktoberfest"
... ...
lib/noosfero/plugin.rb
1   -require 'noosfero'
2 1 include ActionView::Helpers::AssetTagHelper
3 2  
4 3 class Noosfero::Plugin
... ...
public/stylesheets/application.css
... ... @@ -216,9 +216,7 @@ th {
216 216 font-weight: bold;
217 217 border-bottom: 2px solid black;
218 218 }
219   -td {
220   - border-bottom: 1px solid #e0e0e0;
221   -}
  219 +
222 220 tr:hover td {
223 221 background-color: #f0f0f0;
224 222 }
... ... @@ -301,24 +299,29 @@ div.pending-tasks {
301 299 }
302 300 /* sitemap and agenda */
303 301  
  302 +
304 303 .agenda-item a.icon, .sitemap-item a.icon {
305   - background-repeat: no-repeat;
306   - padding-left: 20px;
  304 + background-image: none;
  305 + line-height: 150%;
307 306 }
308 307 .agenda-item .icon:hover, .sitemap-item .icon:hover {
309 308 background-color: transparent;
  309 + text-decoration: underline;
310 310 }
311   -.sitemap-item a:link, .agenda-item a:link, .sitemap-item a:visited, .agenda-item a:visited {
  311 +.agenda-item a, a:visited{
  312 + font-weight: bold;
  313 + color: black;
  314 +}
  315 +
  316 +.sitemap-item a:link, .agenda-item a:link, .sitemap-item a:visited, .agenda-item a:visited, .agenda a:hover {
312 317 border: none;
313 318 text-decoration: none;
314 319 }
  320 +
315 321 .sitemap-item img, .agenda-item img {
316 322 border: none;
317 323 }
318   -.sitemap-item a:hover, .agenda-item a:hover {
319   - color: red;
320   - text-decoration: underline;
321   -}
  324 +
322 325 .last-update {
323 326 font-size: 12px;
324 327 }
... ... @@ -382,7 +385,7 @@ div.pending-tasks {
382 385 font-size: 11px;
383 386 }
384 387 #category-ajax-selector .select-subcategory-link:hover {
385   - background-color: #FFA;
  388 + background-color: black;
386 389 }
387 390 #category-ajax-selector .button {
388 391 display: block;
... ... @@ -3507,18 +3510,19 @@ div#article-parent {
3507 3510 width: 50%;
3508 3511 }
3509 3512 #agenda td, #agenda th {
3510   - padding: 0px;
  3513 + padding: 15px;
  3514 + padding-right: 0px;
3511 3515 }
3512 3516 #agenda .agenda-calendar .previous-month td, #agenda .agenda-calendar .previous-month th, #agenda .agenda-calendar .next-month td, #agenda .agenda-calendar .next-month th {
3513   - font-size: 10px;
3514   - color: gray;
  3517 + font-size: 12px;
  3518 + color: black;
3515 3519 }
3516 3520 #agenda .agenda-calendar .current-month td {
3517 3521 }
3518 3522 #agenda .agenda-calendar .calendar-day {
3519 3523 }
3520 3524 #agenda .agenda-calendar .calendar-day-out {
3521   - color: gray;
  3525 + color: black;
3522 3526 }
3523 3527 #agenda .agenda-calendar .calendar-day-out span {
3524 3528 display: none;
... ... @@ -3535,7 +3539,7 @@ div#article-parent {
3535 3539 }
3536 3540 #agenda .agenda-calendar .current-month {
3537 3541 height: 250px;
3538   - border-bottom: 1px solid #BFC2BC;
  3542 + border-bottom: 1px solid black;
3539 3543 }
3540 3544 #agenda .agenda-calendar .previous-month, #agenda .agenda-calendar .next-month {
3541 3545 float: left;
... ... @@ -3572,14 +3576,15 @@ div#article-parent {
3572 3576 width: 45%;
3573 3577 top: 0px;
3574 3578 height: 100%;
3575   - border-left: 1px solid #BFC2BC;
3576 3579 padding-left: 20px;
3577 3580 }
3578 3581 #agenda #events-of-the-day #agenda-items {
3579 3582 display: block;
3580 3583 overflow: auto;
3581 3584 overflow-x: hidden;
3582   - height: 90%;
  3585 + height: 80%;
  3586 + background: white;
  3587 + border: none;
3583 3588 }
3584 3589 #agenda-toolbar {
3585 3590 float: right;
... ... @@ -3589,6 +3594,11 @@ div#article-parent {
3589 3594 h1#agenda-title {
3590 3595 position: relative;
3591 3596 }
  3597 +#agenda .agenda-calendar .button.icon-next.with-text {
  3598 + background-position: right;
  3599 + padding-left: 3px;
  3600 + padding-right: 20px;
  3601 +}
3592 3602 #agenda-toolbar a.button {
3593 3603 border: none;
3594 3604 opacity: 0.6;
... ...
test/functional/events_controller_test.rb
... ... @@ -7,11 +7,6 @@ class EventsControllerTest &lt; ActionController::TestCase
7 7 end
8 8 attr_reader :profile
9 9  
10   - should 'hide sideboxes when show calendar' do
11   - get :events, :profile => profile.identifier
12   - assert_no_tag :tag => 'div', :attributes => {:id => 'boxes'}
13   - end
14   -
15 10 should 'list today events by default' do
16 11 profile.events << Event.new(:name => 'Joao Birthday', :start_date => Date.today)
17 12 profile.events << Event.new(:name => 'Maria Birthday', :start_date => Date.today)
... ... @@ -32,27 +27,15 @@ class EventsControllerTest &lt; ActionController::TestCase
32 27 assert_tag :tag => 'table', :attributes => {:class => /current-month/}, :descendant => {:tag => 'caption', :content => /#{month}/}
33 28 end
34 29  
35   - should 'display calendar of previous month' do
36   - get :events, :profile => profile.identifier
37   -
38   - month = (Date.today << 1).strftime("%B %Y")
39   - assert_tag :tag => 'table', :attributes => {:class => /previous-month/}, :descendant => {:tag => 'caption', :content => /#{month}/}
40   - end
41   -
42   - should 'display calendar of next month' do
43   - get :events, :profile => profile.identifier
44   -
45   - month = (Date.today >> 1).strftime("%B %Y")
46   - assert_tag :tag => 'table', :attributes => {:class => /next-month/}, :descendant => {:tag => 'caption', :content => /#{month}/}
47   - end
48   -
49 30 should 'display links to previous and next month' do
50 31 get :events, :profile => profile.identifier
51 32  
52   - prev_month = Date.today << 1
53   - next_month = Date.today >> 1
54   - assert_tag :tag =>'a', :attributes => {:href => "/profile/#{profile.identifier}/events/#{next_month.year}/#{next_month.month}"}, :content => /next/
55   - assert_tag :tag =>'a', :attributes => {:href => "/profile/#{profile.identifier}/events/#{prev_month.year}/#{prev_month.month}"}, :content => /previous/
  33 + prev_month = Date.today - 1.month
  34 + next_month = Date.today + 1.month
  35 + prev_month_name = prev_month.strftime("%B")
  36 + next_month_name = next_month.strftime("%B")
  37 + assert_tag :tag =>'a', :attributes => {:href => "/profile/#{profile.identifier}/events/#{next_month.year}/#{prev_month.month}"}, :content => prev_month_name
  38 + assert_tag :tag =>'a', :attributes => {:href => "/profile/#{profile.identifier}/events/#{prev_month.year}/#{next_month.month}"}, :content => next_month_name
56 39 end
57 40  
58 41 end
... ...
test/functional/search_controller_test.rb
... ... @@ -320,7 +320,7 @@ class SearchControllerTest &lt; ActionController::TestCase
320 320 ev2 = create_event(person, :name => 'event 2', :category_ids => [@category.id], :start_date => Date.today - 2.month)
321 321  
322 322 get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year
323   - assert_equal [ev1], assigns(:events_of_the_day)
  323 + assert_equal [ev1], assigns(:events)
324 324 end
325 325  
326 326 should 'return events of the day with category' do
... ... @@ -332,7 +332,7 @@ class SearchControllerTest &lt; ActionController::TestCase
332 332  
333 333 get :events, :day => ten_days_ago.day, :month => ten_days_ago.month, :year => ten_days_ago.year, :category_path => @category.path.split('/')
334 334  
335   - assert_equal [ev1], assigns(:events_of_the_day)
  335 + assert_equal [ev1], assigns(:events)
336 336 end
337 337  
338 338 should 'return events of today when no date specified' do
... ... @@ -342,7 +342,7 @@ class SearchControllerTest &lt; ActionController::TestCase
342 342  
343 343 get :events
344 344  
345   - assert_equal [ev1], assigns(:events_of_the_day)
  345 + assert_equal [ev1], assigns(:events)
346 346 end
347 347  
348 348 should 'show events for current month by default' do
... ...
test/unit/dates_helper_test.rb
... ... @@ -108,40 +108,7 @@ class DatesHelperTest &lt; ActiveSupport::TestCase
108 108 assert_equal 'September 2009', show_month(2009, 10, :previous => true)
109 109 end
110 110  
111   - should 'provide link to previous month' do
112   - expects(:link_to).with('January 2008', { :year => 2008, :month => 1})
113   - link_to_previous_month('2008', '2')
114   - end
115   -
116   - should 'support last year in link to previous month' do
117   - expects(:link_to).with('December 2007', { :year => 2007, :month => 12})
118   - link_to_previous_month('2008', '1')
119   - end
120   -
121   - should 'provide link to next month' do
122   - expects(:link_to).with('March 2008', { :year => 2008, :month => 3})
123   - link_to_next_month('2008', '2')
124   - end
125   -
126   - should 'support next year in link to next month' do
127   - expects(:link_to).with('January 2009', { :year => 2009, :month => 1})
128   - link_to_next_month('2008', '12')
129   - end
130   -
131   - should 'get current date when year and month are not informed for next month' do
132   - Date.stubs(:today).returns(Date.new(2008,1,1))
133   - expects(:link_to).with('February 2008', { :year => 2008, :month => 2})
134   - link_to_next_month(nil, nil)
135   - end
136   -
137   - should 'get current date when year and month are not informed for previous month' do
138   - Date.stubs(:today).returns(Date.new(2008,1,1))
139   - expects(:link_to).with('December 2007', { :year => 2007, :month => 12})
140   - link_to_previous_month(nil, nil)
141   - end
142   -
143 111 should 'provide an intertionalized date selector pass month names' do
144   -
145 112 expects(:gettext).with('January').returns('January')
146 113 expects(:gettext).with('February').returns('February')
147 114 expects(:gettext).with('March').returns('March')
... ... @@ -154,7 +121,6 @@ class DatesHelperTest &lt; ActiveSupport::TestCase
154 121 expects(:gettext).with('October').returns('October')
155 122 expects(:gettext).with('November').returns('November')
156 123 expects(:gettext).with('December').returns('December')
157   -
158 124 expects(:language).returns('en')
159 125  
160 126 expects(:date_select).with(:object, :method, { :include_blank => true, :order => [:month, :day, :year], :use_month_names => ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']}).returns("KKKKKKKK")
... ...
test/unit/event_test.rb
... ... @@ -100,13 +100,13 @@ class EventTest &lt; ActiveSupport::TestCase
100 100  
101 101 should 'provide range of dates for event with both dates filled' do
102 102 e = Event.new(:start_date => Date.new(2008, 1, 1), :end_date => Date.new(2008, 1, 5))
103   -
  103 +
104 104 assert_equal (Date.new(2008,1,1)..Date.new(2008,1,5)), e.date_range
105 105 end
106 106  
107 107 should 'provide range of dates for event with only start date' do
108 108 e = Event.new(:start_date => Date.new(2008, 1, 1))
109   -
  109 +
110 110 assert_equal (Date.new(2008,1,1)..Date.new(2008,1,1)), e.date_range
111 111 end
112 112  
... ... @@ -116,7 +116,6 @@ class EventTest &lt; ActiveSupport::TestCase
116 116 assert_tag_in_string e.to_html, :content => Regexp.new("January 1, 2008")
117 117 assert_tag_in_string e.to_html, :content => 'my somewhat short description'
118 118 assert_tag_in_string e.to_html, :tag => 'a', :attributes => { :href => 'http://www.myevent.org' }, :content => 'http://www.myevent.org'
119   -
120 119 end
121 120  
122 121 should 'not crash when body is blank' do
... ... @@ -187,6 +186,47 @@ class EventTest &lt; ActiveSupport::TestCase
187 186 assert_equal [today_event], profile.events.by_day(today)
188 187 end
189 188  
  189 + should 'list events by month' do
  190 + profile = fast_create(Profile)
  191 +
  192 + today = Date.new(2013, 10, 6)
  193 +
  194 + last_month_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.month)
  195 +
  196 + current_month_event_1 = Event.new(:name => 'Maria Birthday', :start_date => today)
  197 + current_month_event_2 = Event.new(:name => 'Joana Birthday', :start_date => today - 1.day)
  198 +
  199 + next_month_event = Event.new(:name => 'Mane Birthday', :start_date => today + 1.month)
  200 +
  201 + profile.events << [last_month_event, current_month_event_1, current_month_event_2, next_month_event]
  202 +
  203 + month_events = profile.events.by_month(today)
  204 +
  205 + assert month_events.include?(current_month_event_1)
  206 + assert month_events.include?(current_month_event_2)
  207 +
  208 + assert !month_events.include?(last_month_event)
  209 + assert !month_events.include?(next_month_event)
  210 + end
  211 +
  212 + should 'event by month ordered by start date'do
  213 + profile = fast_create(Profile)
  214 +
  215 + today = Date.new(2013, 10, 6)
  216 +
  217 + event_1 = Event.new(:name => 'Maria Birthday', :start_date => today + 1.day)
  218 + event_2 = Event.new(:name => 'Joana Birthday', :start_date => today - 1.day)
  219 + event_3 = Event.new(:name => 'Mane Birthday', :start_date => today)
  220 +
  221 + profile.events << [event_1, event_2, event_3]
  222 +
  223 + events = profile.events.by_month(today)
  224 +
  225 + assert_equal events[0], event_2
  226 + assert_equal events[1], event_3
  227 + assert_equal events[2], event_1
  228 + end
  229 +
190 230 should 'list events in a range' do
191 231 profile = fast_create(Profile)
192 232  
... ...
test/unit/events_helper_test.rb
... ... @@ -5,12 +5,33 @@ class EventsHelperTest &lt; ActiveSupport::TestCase
5 5 include EventsHelper
6 6  
7 7 should 'list events' do
8   - stubs(:user)
9   - expects(:show_date).returns('')
10   - expects(:_).with('Events for %s').returns('')
11   - event1 = mock; event1.expects(:display_to?).with(anything).returns(true); event1.expects(:name).returns('Event 1'); event1.expects(:url).returns({})
12   - event2 = mock; event2.expects(:display_to?).with(anything).returns(true); event2.expects(:name).returns('Event 2'); event2.expects(:url).returns({})
13   - result = list_events('', [event1, event2])
  8 + user = create_user('userwithevents').person
  9 + stubs(:user).returns(user)
  10 +
  11 + expects(:show_date_month).returns('')
  12 + expects(:_).with('Events for %s').returns('').once
  13 + expects(:_).with(' to ').returns('').twice
  14 + expects(:_).with('Place: ').returns('').twice
  15 + expects(:_).with('No events for this month').returns('').never
  16 +
  17 + event1 = mock;
  18 + event1.expects(:display_to?).with(anything).returns(true).once;
  19 + event1.expects(:start_date).returns(Date.today).once
  20 + event1.expects(:end_date).returns(Date.today + 1.day).twice
  21 + event1.expects(:name).returns('Event 1').once
  22 + event1.expects(:url).returns({}).once
  23 + event1.expects(:address).returns('The Shire').times(3)
  24 +
  25 + event2 = mock;
  26 + event2.expects(:display_to?).with(anything).returns(true).once
  27 + event2.expects(:start_date).returns(Date.today).once
  28 + event2.expects(:end_date).returns(Date.today + 1.day).twice
  29 + event2.expects(:name).returns('Event 2').once
  30 + event2.expects(:url).returns({}).once
  31 + event2.expects(:address).returns('Valfenda').times(3)
  32 +
  33 + result = list_events(Date.today, [event1, event2])
  34 +
14 35 assert_match /Event 1/, result
15 36 assert_match /Event 2/, result
16 37 end
... ...
test/unit/profile_test.rb
... ... @@ -1445,6 +1445,19 @@ class ProfileTest &lt; ActiveSupport::TestCase
1445 1445 assert_equal [today_event], profile.events.by_day(today)
1446 1446 end
1447 1447  
  1448 + should 'list events by month' do
  1449 + profile = fast_create(Profile)
  1450 +
  1451 + today = Date.today
  1452 + yesterday_event = Event.new(:name => 'Joao Birthday', :start_date => today - 1.day)
  1453 + today_event = Event.new(:name => 'Ze Birthday', :start_date => today)
  1454 + tomorrow_event = Event.new(:name => 'Mane Birthday', :start_date => today + 1.day)
  1455 +
  1456 + profile.events << [yesterday_event, today_event, tomorrow_event]
  1457 +
  1458 + assert_equal [yesterday_event, today_event, tomorrow_event], profile.events.by_month(today)
  1459 + end
  1460 +
1448 1461 should 'list events in a range' do
1449 1462 profile = fast_create(Profile)
1450 1463  
... ... @@ -1474,13 +1487,13 @@ class ProfileTest &lt; ActiveSupport::TestCase
1474 1487 assert_not_includes profile.events.by_day(today), event_out_of_range
1475 1488 end
1476 1489  
1477   - should 'sort events by name' do
  1490 + should 'sort events by date' do
1478 1491 profile = fast_create(Profile)
1479 1492 event1 = Event.new(:name => 'Noosfero Hackaton', :start_date => Date.today)
1480   - event2 = Event.new(:name => 'Debian Day', :start_date => Date.today)
1481   - event3 = Event.new(:name => 'Fisl 10', :start_date => Date.today)
  1493 + event2 = Event.new(:name => 'Debian Day', :start_date => Date.today - 1)
  1494 + event3 = Event.new(:name => 'Fisl 10', :start_date => Date.today + 1)
1482 1495 profile.events << [event1, event2, event3]
1483   - assert_equal [event2, event3, event1], profile.events
  1496 + assert_equal [event2, event1, event3], profile.events
1484 1497 end
1485 1498  
1486 1499 should 'be available if identifier doesnt exist on environment' do
... ...