From c168bb62df03f970ca964c31f3c753a3be1da6d0 Mon Sep 17 00:00:00 2001 From: Alinson Santos Date: Sun, 6 Sep 2009 20:34:35 -0300 Subject: [PATCH] Ordem correta --- app/controllers/log_controller.rb | 4 ++-- app/models/course.rb | 3 +++ app/models/log_entry/wiki_log_entry.rb | 2 +- app/views/log/index.html.haml | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/log_controller.rb b/app/controllers/log_controller.rb index 6c1700c..dcbbd86 100644 --- a/app/controllers/log_controller.rb +++ b/app/controllers/log_controller.rb @@ -20,9 +20,9 @@ class LogController < ApplicationController def index if @course - @log_entries = @course.log_entries.paginate(:page => params[:page], :per_page => 30) + @log_entries = @course.log_entries.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc") else - @log_entries = LogEntry.paginate(:page => params[:page], :per_page => 30) + @log_entries = LogEntry.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc") end respond_to do |format| diff --git a/app/models/course.rb b/app/models/course.rb index 9e29db6..a0d1f82 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -40,6 +40,9 @@ class Course < ActiveRecord::Base has_many :wiki_pages, :order => "position", :dependent => :destroy + + has_and_belongs_to_many :users, + :order => "last_seen desc" # Validacao generate_validations diff --git a/app/models/log_entry/wiki_log_entry.rb b/app/models/log_entry/wiki_log_entry.rb index 342ed6c..bce6907 100644 --- a/app/models/log_entry/wiki_log_entry.rb +++ b/app/models/log_entry/wiki_log_entry.rb @@ -30,7 +30,7 @@ class WikiDeleteLogEntry < WikiLogEntry end def undo!(current_user) wiki_page.update_attribute(:deleted_at, nil) - wiki_page.update_attribute(:position, wiki_page.course.wiki_pages.maximum(:position) + 1) + wiki_page.update_attribute(:position, (wiki_page.course.wiki_pages.maximum(:position)||0) + 1) WikiRestoreLogEntry.create!(:target_id => wiki_page.id, :user_id => current_user.id, :course => wiki_page.course) end end diff --git a/app/views/log/index.html.haml b/app/views/log/index.html.haml index 94e4063..7a80eb8 100644 --- a/app/views/log/index.html.haml +++ b/app/views/log/index.html.haml @@ -15,9 +15,9 @@ .date = tz(entry.created_at).strftime("%H:%M") %img.avatar{:src => gravatar_url_for(entry.user.email, 27)} - = "Disciplina " + link_to(h(entry.course.full_name), course_url(entry.course)) - %br =link_to truncate(h(entry.user.display_name), :length => 20), user_url(entry.user.id) = render(:partial => 'log/log_entry', :locals => { :entry => entry }) + %br + = "Disciplina " + link_to(h(entry.course.full_name), course_url(entry.course)) = will_paginate @log_entries