add per_page option, jump to current date's page if no page is provided, added today link

pull/6827/head
Martin Linkhorst 13 years ago
parent 4c87537050
commit 6db9c7ec30
  1. 15
      app/controllers/meetings_controller.rb
  2. 2
      app/models/meeting.rb
  3. 2
      app/views/meetings/index.html.erb
  4. 39
      features/meetings_index.feature
  5. 20
      features/step_definitions/meeting_steps.rb

@ -18,10 +18,19 @@ class MeetingsController < ApplicationController
# (gibt's momentan nicht, Zeitpunkt ist ein Pflichtfeld)
scope = @project.meetings
@count = scope.count
@limit = 10
@meeting_count = scope.count
@limit = per_page_option
@meetings_pages = Paginator.new self, @count, @limit, params['page']
upcoming_meetings_count = scope.upcoming.count
if upcoming_meetings_count > 0
@page_of_today = 1 + (upcoming_meetings_count-1) / @limit
end
# from params => today's page otherwise => first page as fallback
@page_of_today ||= 1
@page = params['page'] || @page_of_today
@meetings_pages = Paginator.new self, @meeting_count, @limit, @page
@offset = @meetings_pages.current.offset
@meetings_by_start_year_month_date = scope.find_time_sorted(:all,

@ -8,6 +8,8 @@ class Meeting < ActiveRecord::Base
has_many :contents, :class_name => 'MeetingContent', :readonly => true
has_many :participants, :dependent => :destroy, :class_name => 'MeetingParticipant'
named_scope :upcoming, :conditions => ['start_time >= ?', Time.now.beginning_of_day]
attr_accessible :title, :location, :start_time, :duration
acts_as_watchable

@ -31,7 +31,7 @@
</div>
<% end -%>
<p class="pagination"><%= pagination_links_full @meetings_pages %></p>
<p class="pagination"><%= link_to_content_update(l(:label_today), params.merge(:page => @page_of_today)) %> <%= pagination_links_full @meetings_pages, @meeting_count %></p>
<% content_for :header_tags do %>
<%= stylesheet_link_tag 'redmine_meeting', :plugin => 'redmine_meeting' %>

@ -14,7 +14,6 @@ Feature: Show existing meetings
| view_meetings |
And the user "alice" is a "user" in the project "dingens"
@javascript
Scenario: Navigate to the meeting index page with no meetings
When I login as "alice"
And I go to the page for the project "dingens"
@ -22,7 +21,6 @@ Feature: Show existing meetings
Then I should see "Meetings" within "#content"
And I should see "No data to display" within "#content"
@javascript
Scenario: Navigate to the meeting index page with 2 meetings
Given there is 1 meeting in project "dingens" created by "alice" with:
| title | Meeting 1 |
@ -41,4 +39,39 @@ Feature: Show existing meetings
But I should not see "No data to display" within "#content"
# Die Reihenfolge der Meetings muss überprüft werden
# jedes meeting generiert 2 Tags mit der Klasse meeting
And I should see 4 meetings
And I should see 4 meetings
Scenario: Lots of Meetings are split into pages
Given there is 25 meetings in project "dingens" that start 0 days from now with:
| title | Meeting Today |
Given there is 5 meetings in project "dingens" that start -1 days from now with:
| title | Meeting Last Week |
When I login as "alice"
And I go to the page for the project "dingens"
And I click on "Meetings"
# see above: means 25 meetings
Then I should see 50 meetings
And I should see "Meeting Today"
But I should not see "Meeting Last Week"
When I click on "2"
# means 5 meetings
Then I should see 10 meetings
And I should not see "Meeting Today"
But I should see "Meeting Last Week"
Scenario: Jumps to page of current date when no page given
Given there is 27 meetings in project "dingens" that start +7 days from now with:
| title | Meeting Next Week |
Given there is 27 meetings in project "dingens" that start 1 days from now with:
| title | Meeting Tomorrow |
Given there is 27 meetings in project "dingens" that start 0 days from now with:
| title | Meeting Today |
Given there is 27 meetings in project "dingens" that start -7 days from now with:
| title | Meeting Last Week |
When I login as "alice"
And I go to the page for the project "dingens"
And I click on "Meetings"
Then I should see "Meeting Today"
And I should see "Meeting Last Week"
But I should not see "Meeting Tomorrow"
And I should not see "Meeting Next Week"

@ -1,8 +1,18 @@
Given /^there is 1 [Mm]eeting in project "(.+)" created by "(.+)" with:$/ do |project,user,table|
m = Factory.build(:meeting)
m.project = Project.find_by_name(project)
m.author = User.find_by_login(user)
send_table_to_object(m, table)
Given /^there is (\d+) [Mm]eetings? in project "(.+)" created by "(.+)" with:$/ do |count,project,user,table|
count.to_i.times do
m = Factory.build(:meeting)
m.project = Project.find_by_name(project)
m.author = User.find_by_login(user)
send_table_to_object(m, table)
end
end
Given /^there is (\d+) [Mm]eetings? in project "(.+)" that start (.*) days? from now with:$/ do |count,project,time,table|
count.to_i.times do
m = Factory.build(:meeting, :start_time => Time.now + time.to_i.days)
m.project = Project.find_by_name(project)
send_table_to_object(m, table)
end
end
Given /^the [Mm]eeting "(.+)" has 1 agenda with:$/ do |meeting,table|

Loading…
Cancel
Save