Behold the OrderedHashed meetings!

pull/6827/head
Felix Schäfer 14 years ago
parent ea0298a764
commit b0f7005849
  1. 12
      app/controllers/meetings_controller.rb
  2. 12
      app/models/meeting.rb
  3. 17
      app/views/meetings/index.html.erb

@ -7,7 +7,17 @@ class MeetingsController < ApplicationController
before_filter :authorize
def index
@meetings = @project.meetings.find(:all, :order => 'start_time DESC')
# Wo sollen Meetings ohne Termin hin?
@meetings_by_start_year_month_date = ActiveSupport::OrderedHash.new
@project.meetings.all.group_by(&:start_year).each do |year,meetings|
@meetings_by_start_year_month_date[year] = ActiveSupport::OrderedHash.new
meetings.group_by(&:start_month).each do |month,meetings|
@meetings_by_start_year_month_date[year][month] = ActiveSupport::OrderedHash.new
meetings.group_by(&:start_date).each do |date,meetings|
@meetings_by_start_year_month_date[year][month][date] = meetings.sort_by {|m| m.start_time}.reverse
end
end
end
end
def show

@ -14,6 +14,18 @@ class Meeting < ActiveRecord::Base
start_time.to_date if start_time.present?
end
def start_month
start_time.month if start_time.present?
end
def start_year
start_time.year if start_time.present?
end
def end_time
start_time + duration.hours
end
def to_s
title
end

@ -6,17 +6,24 @@
<h2><%= l(:label_meeting_plural)%></h2>
<% if @meetings.empty? -%>
<% if @meetings_by_start_year_month_date.empty? -%>
<p class="nodata"><%= l(:label_no_data) %></p>
<% else -%>
<div class="meetings">
<% @meetings.each do |meeting| -%>
<% @meetings_by_start_year_month_date.sort.reverse.each do |year,meetings_by_start_month_date| -%>
<% meetings_by_start_month_date.sort.reverse.each do |month,meetings_by_start_date| -%>
<h3 class="month_year"><%= "#{month_name(month)} #{year}" %></h3>
<% meetings_by_start_date.sort.reverse.each do |date,meetings| -%>
<h3 class="date"><%= format_activity_day(date) %></h3>
<% meetings.each do |meeting| -%>
<div class="meeting" id="meeting-<%= meeting.id %>">
<h3><%= format_time meeting.start_time %>: <%= link_to h(meeting.title), :controller => 'meetings', :action => 'show', :id => meeting %></h3>
<p class="author"><%= authoring meeting.created_at, meeting.author %></p>
<p><strong><%= l(:field_location) %></strong>: <%=h meeting.location %> - <strong><%= l(:field_duration) %></strong>: <%= l_hours(meeting.duration) %></p>
<span class="time"><%= format_time meeting.start_time, false %>-<%= format_time meeting.end_time, false %></span> <%= link_to h(meeting.title), :controller => 'meetings', :action => 'show', :id => meeting %>
<p><strong><%= l(:field_location) %></strong>: <%=h meeting.location %>
<p><strong><%= l(:field_participants) %></strong> (<%= meeting.participants.count %>): <%= meeting.participants.sort.join(", ") %></p>
</div>
<% end -%>
<% end -%>
<% end -%>
<% end -%>
</div>
<% end -%>
Loading…
Cancel
Save