|
|
|
@ -20,22 +20,24 @@
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
class LogController < ApplicationController
|
|
|
|
|
|
|
|
|
|
before_filter :require_login, :only => [ :undo ]
|
|
|
|
|
before_filter :require_login, only: [:undo]
|
|
|
|
|
before_filter :find_course, only: [:index]
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
if @course
|
|
|
|
|
@log_entries = @course.log_entries.paginate(:page => params[:page], :per_page => 30, :order => "created_at desc")
|
|
|
|
|
@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,
|
|
|
|
|
:conditions => [ "course_id not in (select id from courses where hidden = ?)", true],
|
|
|
|
|
:order => "created_at desc")
|
|
|
|
|
@log_entries = LogEntry.paginate(page: params[:page], per_page: 30,
|
|
|
|
|
conditions: ["course_id not in (select id from courses where hidden = ?)", true],
|
|
|
|
|
order: "created_at desc")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.rss { response.content_type = Mime::RSS }
|
|
|
|
|
format.xml { render :xml => @log_entries }
|
|
|
|
|
format.xml { render xml: @log_entries }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -45,19 +47,19 @@ class LogController < ApplicationController
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html do
|
|
|
|
|
redirect_to course_event_url(@log_entry.course, @log_entry.target_id) if @log_entry.kind_of?(EventDeleteLogEntry)
|
|
|
|
|
redirect_to course_attachment_url(@log_entry.course, @log_entry.target_id) if @log_entry.kind_of?(AttachmentDeleteLogEntry)
|
|
|
|
|
redirect_to course_news_instance_url(@log_entry.course, @log_entry.target_id) if @log_entry.kind_of?(NewsDeleteLogEntry)
|
|
|
|
|
redirect_to course_wiki_instance_url(@log_entry.course, @log_entry.target_id) if @log_entry.kind_of?(WikiDeleteLogEntry)
|
|
|
|
|
redirect_to course_event_url(@log_entry.course, @log_entry.target_id) if @log_entry.is_a?(EventDeleteLogEntry)
|
|
|
|
|
redirect_to course_attachment_url(@log_entry.course, @log_entry.target_id) if @log_entry.is_a?(AttachmentDeleteLogEntry)
|
|
|
|
|
redirect_to course_news_instance_url(@log_entry.course, @log_entry.target_id) if @log_entry.is_a?(NewsDeleteLogEntry)
|
|
|
|
|
redirect_to course_wiki_instance_url(@log_entry.course, @log_entry.target_id) if @log_entry.is_a?(WikiDeleteLogEntry)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
|
|
def find_course
|
|
|
|
|
unless params[:course_id].nil?
|
|
|
|
|
params[:course_id] = Course.find(:first, :conditions => ['short_name = ?', params[:course_id]], :order => 'period desc').id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
|
|
|
|
|
@course = Course.find(params[:course_id])
|
|
|
|
|
if params[:course_id]
|
|
|
|
|
@course = Course.from_param(params[:course_id])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|