Commit 264f3eae7da28a81e46046fce607b063774347ff

Authored by Athos
2 parents 4fc3afb2 e6f69622

Merge branch 'master' of beta.softwarepublico.gov.br:softwarepublico/softwarepublico

src/noosfero-spb/software_communities/lib/software_events_block.rb
@@ -8,6 +8,10 @@ class SoftwareEventsBlock < Block @@ -8,6 +8,10 @@ class SoftwareEventsBlock < Block
8 _('This block displays the software community events in a list.') 8 _('This block displays the software community events in a list.')
9 end 9 end
10 10
  11 + def default_title
  12 + _('Other events')
  13 + end
  14 +
11 def content(args={}) 15 def content(args={})
12 block = self 16 block = self
13 17
@@ -34,8 +38,8 @@ class SoftwareEventsBlock < Block @@ -34,8 +38,8 @@ class SoftwareEventsBlock < Block
34 get_events.where("slug NOT IN (?)", event_slug) 38 get_events.where("slug NOT IN (?)", event_slug)
35 end 39 end
36 40
37 - def has_events_to_display?  
38 - not get_events.empty? 41 + def has_events_to_display? current_event_slug=""
  42 + not get_events_except(current_event_slug).empty?
39 end 43 end
40 44
41 def should_display_title? 45 def should_display_title?
src/noosfero-spb/software_communities/test/unit/software_events_block_test.rb
@@ -46,12 +46,22 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase @@ -46,12 +46,22 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase
46 should "tell if there are events to be displayed" do 46 should "tell if there are events to be displayed" do
47 assert_equal true, @software_events_block.has_events_to_display? 47 assert_equal true, @software_events_block.has_events_to_display?
48 48
49 - @community.events.update_all :start_date => (DateTime.now - 2.days),  
50 - :end_date => (DateTime.now - 1.day) 49 + update_all_events (DateTime.now - 2.days), (DateTime.now - 1.day)
51 50
52 assert_equal false, @software_events_block.has_events_to_display? 51 assert_equal false, @software_events_block.has_events_to_display?
53 end 52 end
54 53
  54 + should "tell if there are events to be displayed when given a event page slug" do
  55 + update_all_events (DateTime.now - 2.days), (DateTime.now - 1.day)
  56 +
  57 + last_event = @community.events.last
  58 + last_event.end_date = DateTime.now + 10.days
  59 + last_event.save!
  60 +
  61 + assert_equal true, @software_events_block.has_events_to_display?
  62 + assert_equal false, @software_events_block.has_events_to_display?(last_event.slug)
  63 + end
  64 +
55 should "tell that the block must show the title in other areas that are no the main area" do 65 should "tell that the block must show the title in other areas that are no the main area" do
56 assert_equal false, @software_events_block.should_display_title? 66 assert_equal false, @software_events_block.should_display_title?
57 67
@@ -60,4 +70,10 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase @@ -60,4 +70,10 @@ class SoftwareEventsBlockTest < ActiveSupport::TestCase
60 70
61 assert_equal true, @software_events_block.should_display_title? 71 assert_equal true, @software_events_block.should_display_title?
62 end 72 end
  73 +
  74 + private
  75 +
  76 + def update_all_events start_date, end_date
  77 + @community.events.update_all :start_date => start_date, :end_date => end_date
  78 + end
63 end 79 end
src/noosfero-spb/software_communities/views/blocks/software_events.html.erb
1 -<div class="software-community-events-block">  
2 - <% if block.has_events_to_display? %> 1 +<% if block.has_events_to_display? params[:page] %>
  2 + <div class="software-community-events-block">
3 <ul class="software-community-events-list"> 3 <ul class="software-community-events-list">
4 -  
5 <% if block.should_display_title? %> 4 <% if block.should_display_title? %>
6 <li class="software-events-list-item"> 5 <li class="software-events-list-item">
7 <span class="software-events-list-item-title"> 6 <span class="software-events-list-item-title">
@@ -18,5 +17,5 @@ @@ -18,5 +17,5 @@
18 <% end %> 17 <% end %>
19 18
20 </ul> 19 </ul>
21 - <% end %>  
22 -</div> 20 + </div>
  21 +<% end %>