Commit 0ecc2dc82cf2bf5da15e2ce3bbf19c53d1a6b201
1 parent
ec878130
Exists in
master
and in
61 other branches
Add software events block
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
4 changed files
with
59 additions
and
1 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
| @@ -43,7 +43,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | @@ -43,7 +43,8 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin | ||
| 43 | SoftwareHighlightsBlock => { :type => [Environment] }, | 43 | SoftwareHighlightsBlock => { :type => [Environment] }, |
| 44 | SoftwareTabDataBlock => {:type => [Community], :position => 1}, | 44 | SoftwareTabDataBlock => {:type => [Community], :position => 1}, |
| 45 | WikiBlock => {:type => [Community]}, | 45 | WikiBlock => {:type => [Community]}, |
| 46 | - StatisticBlock => { :type => [Community] } | 46 | + StatisticBlock => { :type => [Community] }, |
| 47 | + SoftwareEventsBlock => { :type => [Community], :position => 1 } | ||
| 47 | } | 48 | } |
| 48 | end | 49 | end |
| 49 | 50 |
src/noosfero-spb/software_communities/lib/software_events_block.rb
0 → 100644
| @@ -0,0 +1,28 @@ | @@ -0,0 +1,28 @@ | ||
| 1 | +class SoftwareEventsBlock < Block | ||
| 2 | + | ||
| 3 | + def self.description | ||
| 4 | + _('Software community events') | ||
| 5 | + end | ||
| 6 | + | ||
| 7 | + def help | ||
| 8 | + _('This block displays the software community events in a list.') | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + def content(args={}) | ||
| 12 | + today = DateTime.now.beginning_of_day | ||
| 13 | + events = self.owner.events.where("start_date >= ? AND end_date >= ?", today, today).order(:start_date) | ||
| 14 | + | ||
| 15 | + block = self | ||
| 16 | + | ||
| 17 | + lambda do |object| | ||
| 18 | + render( | ||
| 19 | + :file => 'blocks/software_events', | ||
| 20 | + :locals => { :block => block, :events => events } | ||
| 21 | + ) | ||
| 22 | + end | ||
| 23 | + end | ||
| 24 | + | ||
| 25 | + def cacheable? | ||
| 26 | + false | ||
| 27 | + end | ||
| 28 | +end |
src/noosfero-spb/software_communities/views/blocks/_software_events_list_item.html.erb
0 → 100644
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +<div class="software-events-list-item"> | ||
| 2 | + <div class="software-events-list-item-calendar"></div> | ||
| 3 | + | ||
| 4 | + <div class="software-events-list-item-date"> | ||
| 5 | + <%= event.start_date.strftime "%m/%d" %> | ||
| 6 | + </div> | ||
| 7 | + | ||
| 8 | + <div class="software-events-list-item-title"> | ||
| 9 | + <%= link_to event.title, event.url %> | ||
| 10 | + </div> | ||
| 11 | +</div> |
src/noosfero-spb/software_communities/views/blocks/software_events.html.erb
0 → 100644
| @@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
| 1 | +<div class="software-community-events-block"> | ||
| 2 | + <% if not events.empty? %> | ||
| 3 | + | ||
| 4 | + <ul class="software-community-events-list"> | ||
| 5 | + <% events.each do |event| %> | ||
| 6 | + <li> | ||
| 7 | + <%= render :partial=>"blocks/software_events_list_item", | ||
| 8 | + :locals => {:event => event} %> | ||
| 9 | + </li> | ||
| 10 | + <% end %> | ||
| 11 | + </ul> | ||
| 12 | + | ||
| 13 | + <% else %> | ||
| 14 | + <div class="software-community-events-no-event"> | ||
| 15 | + <%= _("This community does not have any events yet") %> | ||
| 16 | + </div> | ||
| 17 | + <% end %> | ||
| 18 | +</div> | ||
| 0 | \ No newline at end of file | 19 | \ No newline at end of file |