diff --git a/plugins/event/lib/event_plugin/event_block.rb b/plugins/event/lib/event_plugin/event_block.rb index bc943d8..0c5a526 100644 --- a/plugins/event/lib/event_plugin/event_block.rb +++ b/plugins/event/lib/event_plugin/event_block.rb @@ -5,7 +5,7 @@ class EventPlugin::EventBlock < Block settings_items :all_env_events, :type => :boolean, :default => false settings_items :limit, :type => :integer, :default => 4 - settings_items :future_only, :type => :boolean, :default => false + settings_items :future_only, :type => :boolean, :default => true settings_items :date_distance_limit, :type => :integer, :default => 0 def self.description @@ -17,15 +17,12 @@ class EventPlugin::EventBlock < Block end def events_source - unless all_env_events - if self.owner.kind_of? Environment - return self.owner - elsif environment.portal_community - return environment.portal_community - end + return environment if all_env_events + if self.owner.kind_of? Environment + environment.portal_community ? environment.portal_community : environment + else + self.owner end - - environment end def events(user = nil) @@ -65,15 +62,15 @@ class EventPlugin::EventBlock < Block def human_time_left(days_left) months_left = (days_left/30.0).round if days_left <= -60 - n_('Started one month ago.', 'Started %d months ago.', -months_left) % -months_left + n_('One month ago', '%d months ago', -months_left) % -months_left elsif days_left < 0 - n_('Started one day ago.', 'Started %d days ago.', -days_left) % -days_left + n_('Yesterday', '%d days ago', -days_left) % -days_left elsif days_left == 0 - _("I happens today.") + _("Today") elsif days_left < 60 - n_('One day left to start.', '%d days left to start.', days_left) % days_left + n_('Tomorrow', '%d days left to start', days_left) % days_left else - n_('One month left to start.', '%d months left to start.', months_left) % months_left + n_('One month left to start', '%d months left to start', months_left) % months_left end end diff --git a/plugins/event/public/style.css b/plugins/event/public/style.css index f73beef..5b18f69 100644 --- a/plugins/event/public/style.css +++ b/plugins/event/public/style.css @@ -119,6 +119,11 @@ background: #D4D4D4; } +.event-plugin_event-block .event .week-day, +.event-plugin_event-block .event .year { + display: none; +} + .event-plugin_event-block .event .duration { display: block; } @@ -184,3 +189,8 @@ .msie8 #content .event-plugin_event-block .event .days-left { float: left; } + +.event-plugin-config-tip { + display: block; + margin-bottom: 3px; +} diff --git a/plugins/event/test/functional/event_block_test.rb b/plugins/event/test/functional/event_block_test.rb index c5eb512..7093779 100644 --- a/plugins/event/test/functional/event_block_test.rb +++ b/plugins/event/test/functional/event_block_test.rb @@ -42,17 +42,17 @@ class HomeControllerTest < ActionController::TestCase should 'see event duration' do @e1a.slug = 'event1a' @e1a.start_date = Date.today - @e1a.end_date = Date.tomorrow + @e1a.end_date = Date.today + 1.day @e1a.save! get :index - assert_select ev + 'time.duration[itemprop="endDate"]', '+1 day' + assert_select ev + 'time.duration[itemprop="endDate"]', /1 day/ @e1a.slug = 'event1a' @e1a.start_date = Date.today - @e1a.end_date = Date.tomorrow+1 + @e1a.end_date = Date.today + 2.day @e1a.save! get :index - assert_select ev + 'time.duration[itemprop="endDate"]', '+2 days' + assert_select ev + 'time.duration[itemprop="endDate"]', /2 days/ end should 'not see event duration for one day events' do diff --git a/plugins/event/test/unit/event_block_test.rb b/plugins/event/test/unit/event_block_test.rb index 13d3165..4b89ccd 100644 --- a/plugins/event/test/unit/event_block_test.rb +++ b/plugins/event/test/unit/event_block_test.rb @@ -19,7 +19,7 @@ class EventPlugin::EventBlockTest < ActiveSupport::TestCase :start_date => Date.today-30) box = fast_create(Box, :owner_id => @p1) - @block = EventPlugin::EventBlock.new(:limit => 99, :box => box) + @block = EventPlugin::EventBlock.new(:limit => 99, :future_only => false, :box => box) end def set_portal(env, portal) @@ -78,9 +78,7 @@ class EventPlugin::EventBlockTest < ActiveSupport::TestCase end should 'say human left time for an event' do - one_day = @block.human_time_left(Date.tomorrow - Date.today) - - assert_match /One day left/, one_day + assert_match /Tomorrow/, @block.human_time_left(1) assert_match /5 days left/, @block.human_time_left(5) assert_match /30 days left/, @block.human_time_left(30) assert_match /2 months left/, @block.human_time_left(60) @@ -88,13 +86,15 @@ class EventPlugin::EventBlockTest < ActiveSupport::TestCase end should 'say human past time for an event' do - one_day = @block.human_time_left(Date.yesterday - Date.today) + assert_match /Yesterday/, @block.human_time_left(-1) + assert_match /5 days ago/, @block.human_time_left(-5) + assert_match /30 days ago/, @block.human_time_left(-30) + assert_match /2 months ago/, @block.human_time_left(-60) + assert_match /3 months ago/, @block.human_time_left(-85) + end - assert_match /One day past/, one_day - assert_match /5 days past/, @block.human_time_left(-5) - assert_match /30 days past/, @block.human_time_left(-30) - assert_match /2 months past/, @block.human_time_left(-60) - assert_match /3 months past/, @block.human_time_left(-85) + should 'say human present time for an event' do + assert_match /Today/, @block.human_time_left(0) end should 'write formatable data in html' do diff --git a/plugins/event/views/blocks/event.html.erb b/plugins/event/views/blocks/event.html.erb index 09ebb0e..431eea2 100644 --- a/plugins/event/views/blocks/event.html.erb +++ b/plugins/event/views/blocks/event.html.erb @@ -1,7 +1,7 @@ <%= block_title(block.title) %>