noosfero | [event_plugin] displaying profile events
Daniela Feitosa
gitlab at gitlab.com
Thu Feb 12 00:42:08 BRST 2015
Daniela Feitosa pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/af25f7a4ec4269ab53804a99c1e7ff60d5fa6a93">af25f7a4</a> by Daniela Feitosa
[event_plugin] displaying profile events
Also:
- By default, list only future events
- Replacing strings describing the number of days left/past to the event
- Removed br tags and added margin on elements from edit block view
- Only display option "Show all environment events" if there's another option
- Fixed tests
See merge request !400
- - - - -
Changes:
=====================================
plugins/event/lib/event_plugin/event_block.rb
=====================================
--- 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
=====================================
plugins/event/public/style.css
=====================================
--- 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;
+}
=====================================
plugins/event/test/functional/event_block_test.rb
=====================================
--- 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
=====================================
plugins/event/test/unit/event_block_test.rb
=====================================
--- 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
=====================================
plugins/event/views/blocks/event.html.erb
=====================================
--- a/plugins/event/views/blocks/event.html.erb
+++ b/plugins/event/views/blocks/event.html.erb
@@ -1,7 +1,7 @@
<%= block_title(block.title) %>
<ul class="events">
- <% block.events(@user).map do |event| %>
+ <% block.events(user).map do |event| %>
<% days_left = ( event.start_date - Date.today ).round %>
<li itemscope="itemscope" itemtype="http://data-vocabulary.org/Event" class="event">
<%= render(
=====================================
plugins/event/views/profile_design/event_plugin/_event_block.html.erb
=====================================
--- a/plugins/event/views/profile_design/event_plugin/_event_block.html.erb
+++ b/plugins/event/views/profile_design/event_plugin/_event_block.html.erb
@@ -1,23 +1,24 @@
<%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 4) %>
-<%= labelled_check_box(_('Show all environment events'), "block[all_env_events]", "1", @block.all_env_events) %>
-<br>
-<small><%=
- if @profile
- if @profile.person?
- _("(Don't check to show only your events)")
- else
- _("(Don't check to show only %s events)") % @profile.name
- end
- elsif environment.portal_community
- _("(Don't check to show only the environment events)")
- end
-%></small>
-<br>
+<% unless @block.owner.kind_of?(Environment) && !@block.owner.portal_community %>
+ <%= labelled_check_box(_('Show all environment events'), "block[all_env_events]", "1", @block.all_env_events) %>
-<%= labelled_form_field _('Limit of days to display'),
- text_field(:block, :date_distance_limit, :size => 4) %>
-<small>(<%=_('Only show events on this limit of days.')%>)</small>
-<br><br>
+ <small class='event-plugin-config-tip'>
+ <%= if @block.owner.kind_of?(Profile)
+ if @block.owner.person?
+ _("(Don't check to show only your events)")
+ else
+ _("(Don't check to show only %s events)") % @profile.name
+ end
+ elsif environment.portal_community
+ _("(Don't check to show only %s events)") % link_to(environment.portal_community.name, environment.portal_community.url)
+ end
+ %>
+ </small>
+<% end %>
<%= labelled_check_box(_('Only show future events'), "block[future_only]", "1", @block.future_only) %>
+
+<%= labelled_form_field _('Limit of days to display'),
+ text_field(:block, :date_distance_limit, :size => 4) %>
+<small class='event-plugin-config-tip'>(<%=_('Only show events in this interval of days.')%>)</small>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150212/f94e9fbd/attachment.html>
More information about the Noosfero-dev
mailing list