Sha256: 85c4db73ae79019ab21bfcddb6e55f5c8908a7555bd579c35f93da0f6eca2f80
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
require 'action_view/helpers/url_helper' class Sidebar include Rails.application.routes.url_helpers include ActionView::Helpers::TagHelper include ERB::Util def initialize(controller) @controller = controller end def blocks(period) @period = period # TODO (uwe): This does not scale! #periods = Period.find(:all).select {|period| period.active_or_future?(true) && period.party.includes?(user)} periods = Period.find_active_or_future(true) blocks = periods.sort_by {|p| p.required_speed}.reverse.map do |period| content = @controller.render_to_string :partial => '/periods/sidebar_block', :locals => {:period => period} { :id => period.id, :title => "#{period.party.name}##{period.position} (#{'%0.1f' % period.required_speed})", :options => {:controller => 'periods', :action => :show, :id => period}, :content => content } end started_tasks = Task.find_started if not started_tasks.empty? links = started_tasks.map do |task| "<li><a href=\"#{url_for(:host => @controller.request.host_with_port, :controller => 'tasks', :action => 'list_started', :id => task.id)}\">#{task.description}</a></li>" end blocks.unshift({ :title => @controller.l(:started_tasks), :options => {:controller => 'tasks', :action => :list_started}, :content => "<ul>#{links}" }) end blocks end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
backlog-0.37.2 | app/models/sidebar.rb |
backlog-0.37.1 | app/models/sidebar.rb |