[PATCH conductor] Added pagination to events on instance detail page

Jozef Zigmund jzigmund at redhat.com
Thu Dec 1 18:14:19 UTC 2011


On Thursday 01 December 2011 12:38:07 ifarkas at redhat.com wrote:
> From: Imre Farkas <ifarkas at redhat.com>
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=743605
> ---
>  src/app/controllers/instances_controller.rb |    1 +
>  src/app/models/event.rb                     |    2 ++
>  src/app/views/instances/_history.html.haml  |    4 +++-
>  3 files changed, 6 insertions(+), 1 deletions(-)
> 
> diff --git a/src/app/controllers/instances_controller.rb
> b/src/app/controllers/instances_controller.rb index c493fd0..95cf35d 100644
> --- a/src/app/controllers/instances_controller.rb
> +++ b/src/app/controllers/instances_controller.rb
> @@ -44,6 +44,7 @@ class InstancesController < ApplicationController
>      @tab_captions = [t('instances.tab_captions.properties'),
> t('instances.tab_captions.history'),
> t('instances.tab_captions.permissions')] @details_tab =
> params[:details_tab].blank? ? 'properties' : params[:details_tab]
> save_breadcrumb(instance_path(@instance), @instance.name)
> +    @events = @instance.events.descending_by_created_at.paginate(:page =>
> params[:page] || 1) respond_to do |format|
>        format.html { render :action => 'show'}
>        format.js do
> diff --git a/src/app/models/event.rb b/src/app/models/event.rb
> index 6beb7c3..1855014 100644
> --- a/src/app/models/event.rb
> +++ b/src/app/models/event.rb
> @@ -46,6 +46,7 @@ class Event < ActiveRecord::Base
>    attr_accessor :change_hash # allows us to pass in .changes on the parent
> ("source") object
> 
>    scope :lifetime, where(:status_code => [:first_running, :all_running,
> :some_running, :all_stopped]) +  scope :descending_by_created_at,
> order('created_at DESC')
> 
>    # Notifies the Event API if certain conditions are met
>    def transmit_event
> @@ -117,4 +118,5 @@ class Event < ActiveRecord::Base
>    def change_hash
>      @change_hash || {}
>    end
> +
>  end
> diff --git a/src/app/views/instances/_history.html.haml
> b/src/app/views/instances/_history.html.haml index c4e3349..2facfc3 100644
> --- a/src/app/views/instances/_history.html.haml
> +++ b/src/app/views/instances/_history.html.haml
> @@ -2,7 +2,9 @@
>    = t 'instances.history.history_for'
>    = @instance.name
>  %ul
> -  - @instance.events.each do |event|
> +  - @events.each do |event|
>      %li
>        = @instance.name
>        = event.summary
> +
> += will_paginate @events

ACK & pushed.



More information about the aeolus-devel mailing list