From caff86b411f9e7023659a6d52d35ecb5c1d7ff91 Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Fri, 16 Oct 2015 15:48:18 -0300 Subject: [PATCH] Add software events block --- src/noosfero-spb/software_communities/lib/software_communities_plugin.rb | 3 ++- src/noosfero-spb/software_communities/lib/software_events_block.rb | 28 ++++++++++++++++++++++++++++ src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb | 11 +++++++++++ src/noosfero-spb/software_communities/views/blocks/software_events.html.erb | 18 ++++++++++++++++++ 4 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 src/noosfero-spb/software_communities/lib/software_events_block.rb create mode 100644 src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb create mode 100644 src/noosfero-spb/software_communities/views/blocks/software_events.html.erb diff --git a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb index d11c176..8b685bb 100644 --- a/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb +++ b/src/noosfero-spb/software_communities/lib/software_communities_plugin.rb @@ -43,7 +43,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin SoftwareHighlightsBlock => { :type => [Environment] }, SoftwareTabDataBlock => {:type => [Community], :position => 1}, WikiBlock => {:type => [Community]}, - StatisticBlock => { :type => [Community] } + StatisticBlock => { :type => [Community] }, + SoftwareEventsBlock => { :type => [Community], :position => 1 } } end diff --git a/src/noosfero-spb/software_communities/lib/software_events_block.rb b/src/noosfero-spb/software_communities/lib/software_events_block.rb new file mode 100644 index 0000000..ca5ec33 --- /dev/null +++ b/src/noosfero-spb/software_communities/lib/software_events_block.rb @@ -0,0 +1,28 @@ +class SoftwareEventsBlock < Block + + def self.description + _('Software community events') + end + + def help + _('This block displays the software community events in a list.') + end + + def content(args={}) + today = DateTime.now.beginning_of_day + events = self.owner.events.where("start_date >= ? AND end_date >= ?", today, today).order(:start_date) + + block = self + + lambda do |object| + render( + :file => 'blocks/software_events', + :locals => { :block => block, :events => events } + ) + end + end + + def cacheable? + false + end +end diff --git a/src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb b/src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb new file mode 100644 index 0000000..c1f1bea --- /dev/null +++ b/src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb @@ -0,0 +1,11 @@ +
+
+ +
+ <%= event.start_date.strftime "%m/%d" %> +
+ +
+ <%= link_to event.title, event.url %> +
+
diff --git a/src/noosfero-spb/software_communities/views/blocks/software_events.html.erb b/src/noosfero-spb/software_communities/views/blocks/software_events.html.erb new file mode 100644 index 0000000..7bde8fc --- /dev/null +++ b/src/noosfero-spb/software_communities/views/blocks/software_events.html.erb @@ -0,0 +1,18 @@ +
+ <% if not events.empty? %> + + + + <% else %> +
+ <%= _("This community does not have any events yet") %> +
+ <% end %> +
\ No newline at end of file -- libgit2 0.21.2