Initial import

This commit is contained in:
2008-03-02 16:04:34 -03:00
commit 5e4951fa47
798 changed files with 59730 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
require 'yaml'
class ApplicationController < ActionController::Base
include AuthenticationSystem
before_filter :startup
around_filter :set_timezone
# Força o login para algumas áreas do sistema
before_filter :require_login, :only => [ :edit, :new, :create, :update, :delete, :destroy, :download ]
protected
def rescue_action(exception)
# Acesso negado
if exception.is_a?(AccessDenied)
respond_to do |format|
format.html { render :file => "#{RAILS_ROOT}/public/401.html", :status => 401 }
format.xml { head 401 }
end
# Erro de validacao
elsif exception.is_a?(ActiveRecord::RecordInvalid)
respond_to do |format|
format.html { render :action => (exception.record.new_record? ? 'new' : 'edit') }
format.xml { render :xml => exception.record.errors, :status => :unprocessable_entity }
end
# Registro nao encontrado
elsif (RAILS_ENV == 'production') and exception.is_a?(ActiveRecord::RecordNotFound)
respond_to do |format|
format.html { render :file => "#{RAILS_ROOT}/public/404.html", :status => 404 }
format.xml { head 404 }
end
# Outras excecoes
else
super
end
end
def set_timezone
#TzTime.zone = session[:user].tz
TzTime.zone = TZInfo::Timezone.get("America/Fortaleza")
yield
TzTime.reset!
end
def startup
if session[:user_id]
@current_user = User.find(session[:user_id])
else
login_by_token
end
@color = App.default_color
@color = @current_user.pref_color if @current_user
@color = params[:color].to_i if params[:color]
end
end

View File

@@ -0,0 +1,105 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class AttachmentsController < ApplicationController
#verify :method => :post, :only => [ :destroy, :create, :update ],
# :redirect_to => { :controller => 'courses', :action => :show }
before_filter :find_attachment, :except => [ :undelete ]
after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
def show
end
def new
end
def create
@attachment.course_id = @course.id
@attachment.description = params[:attachment][:description]
unless params[:attachment][:file].kind_of?(String)
@attachment.file = params[:attachment][:file]
@attachment.file_name = params[:attachment][:file].original_filename
@attachment.content_type = params[:attachment][:file].content_type
end
# Verifica se o arquivo ja esta associado a outro anexo
#file_path = "#{RAILS_ROOT}/public/upload/#{@course.id}/#{@attachment.file_name}"
#@attachment.errors.add("file", "already exists") if File.exists?(file_path)
if @attachment.save
AttachmentCreateLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @course)
flash[:notice] = 'Attachment created'[]
redirect_to :action => 'show', :id => @attachment.id
else
render :action => 'new'
end
end
def edit
end
def update
@attachment.description = params[:attachment][:description]
unless params[:attachment][:file].kind_of?(String)
@attachment.file = params[:attachment][:file]
@attachment.file_name = params[:attachment][:file].original_filename
@attachment.content_type = params[:attachment][:file].content_type
end
if @attachment.save
AttachmentEditLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @course)
@attachment.last_modified = Time.now.utc
flash[:notice] = 'Attachment updated'[]
redirect_to :action => 'show', :id => @attachment.id
else
render :action => 'edit'
end
end
def destroy
@attachment.destroy
flash[:notice] = 'Attachment removed'[]
flash[:undo] = undelete_course_attachment_url(@course, @attachment)
AttachmentDeleteLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @course)
redirect_to :controller => 'courses', :action => 'show', :id => @course
end
def download
send_file("#{RAILS_ROOT}/public/upload/#{@course.id}/#{@attachment.id}",
:filename => @attachment.file_name,
:type => @attachment.content_type,
:disposition => 'attachment',
:streaming => 'true')
end
def undelete
@attachment = Attachment.find_with_deleted(params[:id])
@attachment.update_attribute(:deleted_at, nil)
flash[:notice] = 'Attachment restored'[]
AttachmentRestoreLogEntry.create!(:target_id => @attachment.id, :user => @current_user, :course => @course)
redirect_to course_attachment_url(@attachment.course, @attachment)
end
protected
def find_attachment
params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
@course = Course.find(params[:course_id])
@attachment = params[:id] ? @course.attachments.find(params[:id]) : Attachment.new
end
def cache_sweep
expire_fragment(:controller => 'courses', :action => 'show')
end
end

View File

@@ -0,0 +1,112 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class CoursesController < ApplicationController
before_filter :find_course, :except => [ :index ]
before_filter :require_admin, :only => [ :new, :create, :edit, :update, :destroy ]
before_filter :require_login, :only => [ :enroll, :unenroll ]
after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
def index
@courses = Course.find(:all,
:order => 'period asc, full_name asc',
:conditions => (logged_in? and !@current_user.courses.empty? ? [ 'id not in (?)', @current_user.courses] : ''))
respond_to do |format|
format.html
format.xml { render :xml => @courses }
end
end
def show
respond_to do |format|
format.html
format.xml { render :xml => @course }
end
end
def new
end
def create
@course.save!
flash[:notice] = 'Course created'[]
respond_to do |format|
format.html { redirect_to course_path(@course) }
format.xml { head :created, :location => formatted_course_url(@course, :xml) }
end
end
def edit
end
def update
@course.attributes = params[:course]
@course.save!
flash[:notice] = 'Course updated'[]
respond_to do |format|
format.html { redirect_to course_path(@course) }
format.xml { head :ok }
end
end
def destroy
@course.destroy
flash[:notice] = 'Course removed'[]
respond_to do |format|
format.html { redirect_to courses_path }
format.xml { head :ok }
end
end
def enroll
@current_user.courses << @course
flash[:highlight] = @course.id
respond_to do |format|
format.html { redirect_to courses_path }
format.xml { head :ok }
end
end
def unenroll
@current_user.courses.delete(@course)
flash[:highlight] = @course.id
respond_to do |format|
format.html { redirect_to courses_path }
format.xml { head :ok }
end
end
protected
def find_course
params[:id] = Course.find_by_short_name(params[:id]).id if params[:id] and !params[:id].is_numeric? and !Course.find_by_short_name(params[:id]).nil?
@course = params[:id] ? Course.find(params[:id]) : Course.new(params[:course])
end
def require_admin
raise AccessDenied.new unless admin?
end
def cache_sweep
expire_fragment(:action => 'show', :part => 'right')
expire_fragment(:action => 'show', :part => 'left')
expire_fragment(:action => 'show')
expire_fragment(:action => 'index')
end
end

View File

@@ -0,0 +1,118 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class EventsController < ApplicationController
before_filter :find_event, :except => [ :mini_calendar, :undelete ]
after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
def index
@events = @course.events
respond_to do |format|
format.html
format.xml { render :xml => @events }
format.ics { response.content_type = Mime::ICS; render :text => Event.to_ical([@course]) }
end
end
def show
respond_to do |format|
format.html
format.xml { render :xml => @event }
end
end
def new
end
def create
@event.course_id = @course.id
@event.created_by = session[:user_id]
@event.save!
flash[:notice] = 'Event created'[]
EventCreateLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_event_path(@course, @event) }
format.xml { head :created, :location => formatted_course_event_url(@course, @event, :xml) }
end
end
def edit
end
def update
@event.attributes = params[:event]
@event.save!
flash[:notice] = 'Event updated'[]
EventEditLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_event_path(@course, @event) }
format.xml { head :created, :location => formatted_course_event_url(@course, @event, :xml) }
end
end
def destroy
@event.destroy
flash[:notice] = 'Event removed'[]
flash[:undo] = undelete_course_event_url(@course, @event)
EventDeleteLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_events_path(@course) }
format.xml { head :ok }
end
end
# Exibe o widget do calendario
def mini_calendar
@course = Course.find(params[:id])
@year = params[:year].to_i
@month = params[:month].to_i
@ajax = true
@events = @course.events
render :template => 'widgets/calendario', :layout => false
end
def undelete
@event = Event.find_with_deleted(params[:id])
@event.update_attribute(:deleted_at, nil)
flash[:notice] = "Event restored"[]
EventRestoreLogEntry.create!(:target_id => @event.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_event_url(@event.course, @event) }
end
end
protected
def find_event
params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
@course = Course.find(params[:course_id])
@event = params[:id] ? @course.events.find(params[:id]) : Event.new(params[:event])
end
def cache_sweep
expire_fragment(:controller => 'courses', :action => 'show', :part => 'right')
expire_fragment(:action => 'index')
end
end

View File

@@ -0,0 +1,39 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class LogController < ApplicationController
before_filter :find_course
def index
@log_entries = @course.log_entries.find(:all, :limit => 50) #.paginate(:page => params[:page], :per_page => 30)
respond_to do |format|
format.html
end
end
def undo
@log_entry = LogEntry.find(params[:id])
@log_entry.undo!(@current_user)
respond_to do |format|
format.html { redirect_to course_log_url }
end
end
protected
def find_course
params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
@course = Course.find(params[:course_id])
end
end

View File

@@ -0,0 +1,111 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class NewsController < ApplicationController
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
#verify :method => :post, :only => [ :destroy, :create, :update ],
# :redirect_to => { :action => :list }
before_filter :find_new, :except => [ :undelete ]
after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
def index
@news = @course.news
respond_to do |format|
format.html
format.xml { render :xml => @news }
format.rss { response.content_type = Mime::RSS }
end
end
def show
respond_to do |format|
format.html
format.xml { render :xml => @news }
end
end
def new
end
def create
@news.receiver_id = @course.id
@news.sender_id = session[:user_id]
@news.timestamp = Time.now.utc
@news.save!
flash[:notice] = 'News created'[]
NewsCreateLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_news_path(@course, @news) }
format.xml { head :created, :location => formatted_course_news_url(@course, @news, :xml) }
end
end
def edit
end
def update
@news.attributes = params[:news]
@news.save!
flash[:notice] = 'News updated'[]
NewsEditLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_news_path(@course, @news) }
format.xml { head :created, :location => formatted_course_news_url(@course, @news, :xml) }
end
end
def destroy
@news.destroy
flash[:notice] = 'News removed'[]
flash[:undo] = undelete_course_news_url(@course, @news)
NewsDeleteLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_news_index_path(@course) }
format.xml { head :ok }
end
end
def undelete
@news = News.find_with_deleted(params[:id])
@news.update_attribute(:deleted_at, nil)
flash[:notice] = "News restored"[]
NewsRestoreLogEntry.create!(:target_id => @news.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_news_url(@news.course, @news) }
end
end
protected
def find_new
params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
@course = Course.find(params[:course_id])
@news = params[:id] ? @course.news.find(params[:id]) : News.new(params[:news])
end
def cache_sweep
expire_fragment(:controller => 'courses', :action => 'show', :part => 'right')
expire_fragment(:action => 'index')
end
end

View File

@@ -0,0 +1,25 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class StylesheetsController < ApplicationController
layout nil
caches_page :wiki
before_filter :set_headers
private
def set_headers
response.content_type = Mime::CSS
end
end

View File

@@ -0,0 +1,143 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class UsersController < ApplicationController
before_filter :find_user, :only => [ :show, :edit, :update, :destroy, :signup ]
before_filter :require_login, :only => [ :settings ]
before_filter :require_admin, :only => [ :edit, :update, :destroy ]
def index
@users = User.find(:all, :order => 'name')
respond_to do |format|
format.html
format.xml { render :xml => @users }
end
end
def show
respond_to do |format|
format.html
format.xml { render :xml => @user }
end
end
def edit
end
def update
raise AccessDenied.new unless (params[:user][:login] == @user.login)
raise AccessDenied.new unless (params[:user][:admin].nil? or @current_user.admin?)
@user.admin = !params[:user][:admin].nil?
@user.attributes = params[:user]
@user.save!
flash[:notice] = 'User account updated'[]
respond_to do |format|
format.html { redirect_to user_path(@user) }
format.xml { head :ok }
end
end
def destroy
@user.destroy
flash[:notice] = 'User account removed'[]
respond_to do |format|
format.html { redirect_to users_path }
format.xml { head :ok }
end
end
def signup
if request.post?
begin
@user.last_seen = Time.now.utc
@user.save!
setup_session(@user)
flash[:message] = 'User account created'[]
redirect_to user_path(@user)
rescue ActiveRecord::RecordInvalid
flash[:warning] = 'Não foi possível cadastrar a conta.'
end
end
end
def settings
@user = @current_user
if request.post?
@user.attributes = params[:user]
@user.save!
@color = @user.pref_color
flash[:message] = 'Settings updated'[]
redirect_to '/'
end
end
def login
if request.post?
@user = User.find_by_login_and_pass(params[:user][:login], params[:user][:password])
if !@user.nil?
setup_session(@user, (params[:remember_me] == "1"))
@user.update_attribute(:last_seen, Time.now.utc)
flash[:message] = 'Welcome back, {u}'[:login_success, @user.login]
redirect_to_stored
else
flash[:warning] = 'Login failed'
end
end
end
def logout
destroy_session
flash[:message] = 'You have logged out'[:logout_success]
redirect_to '/'
end
def dashboard
@news = []
@events = []
unless @current_user.courses.empty?
@news = News.find(:all, :conditions => [ 'receiver_id in (?)', @current_user.courses ],
:order => 'timestamp desc')
@events = Event.find(:all, :conditions => [ 'course_id in (?) and (date > ?) and (date < ?)',
@current_user.courses, 1.day.ago, 14.days.from_now ], :order => 'date, time')
end
end
# def forgot_password
# if request.post?
# u = User.find_by_email(params[:user][:email])
# if u and u.send_new_password
# flash[:message] = "Uma nova senha foi enviada para o seu email."
# redirect_to :action=>'login'
# else
# flash[:warning] = "Não foi possível gerar uma nova senha."
# end
# end
# end
#Funções do Fórum
protected
def find_user
params[:id] = User.find_by_login(params[:id]).id if params[:id] and !params[:id].is_numeric?
@user = params[:id] ? User.find(params[:id]) : User.new(params[:user])
end
def require_admin
raise AccessDenied.new unless admin? or @current_user == @user
end
end

View File

@@ -0,0 +1,164 @@
# Engenharia de Software 2007.1
# Copyright (C) 2007, Adriano, Alinson, Andre, Rafael e Bustamante
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
class WikiController < ApplicationController
verify :params => :text, :only => :preview, :redirect_to => { :action => :show }
verify :params => [:from, :to], :only => :diff, :redirect_to => { :action => :versions }
after_filter :cache_sweep, :only => [ :create, :update, :destroy ]
before_filter :find_wiki, :except => [ :preview, :undelete ]
before_filter :require_login, :only => [ :new, :create, :edit, :update, :destroy,
:move_up, :move_down, :undelete ]
def index
@wiki_pages = @course.wiki_pages
respond_to do |format|
format.html { redirect_to course_url(@course) }
format.xml { render :xml => @wiki_pages }
end
end
def new
end
def create
@wiki_page.version = 1
@wiki_page.user_id = session[:user_id]
@wiki_page.course_id = @course.id
@wiki_page.description = "Nova página"
@wiki_page.save!
flash[:notice] = "Wiki page created"[]
WikiCreateLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_wiki_path(@course, @wiki_page) }
format.xml { head :created, :location => formatted_course_wiki_url(@course, @wiki_page, :xml) }
end
end
def show
@wiki_page.revert_to(params[:version]) if params[:version]
respond_to do |format|
format.html
format.xml { render :xml => @wiki_page }
format.text { render :text => "# #{@wiki_page.title}\n\n#{@wiki_page.content}" }
end
end
def edit
@wiki_page.revert_to(params[:version]) if params[:version]
@wiki_page.description = params[:description] || ""
end
def update
@wiki_page.attributes = params[:wiki_page]
@wiki_page.user_id = session[:user_id]
@wiki_page.course_id = @course.id
dirty = @wiki_page.dirty?
@wiki_page.save!
WikiEditLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course, :version => @wiki_page.version) if dirty
flash[:notice] = "Wiki page updated"[]
respond_to do |format|
format.html { redirect_to course_wiki_path(@course, @wiki_page) }
format.xml { head :created, :location => formatted_course_wiki_url(@course, @wiki_page, :xml) }
end
end
def destroy
@wiki_page.destroy
flash[:notice] = "Wiki page removed"[]
flash[:undo] = url_for(:course_id => @course, :id => @wiki_page.id, :action => 'undelete')
WikiDeleteLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @course)
respond_to do |format|
format.html { redirect_to course_url(@course) }
format.xml { head :ok }
end
end
def versions
@history_to = params[:to] || @wiki_page.versions.count
@history_from = params[:from] || @wiki_page.versions.count - 1
@offset = params[:offset] || 0
respond_to do |format|
format.html
format.xml
end
end
def preview
@text = params[:text]
render :text => BlueCloth.new(@text).to_html
end
def diff
@to = WikiPage.find_version(params[:id], params[:to])
@from = WikiPage.find_version(params[:id], params[:from])
@diff = WikiPage.diff(@from, @to)
end
def move_up
@wiki_page.move_higher
@wiki_page.save
flash[:highlight] = @wiki_page.id
respond_to do |format|
format.html { redirect_to course_url(@course) }
end
end
def move_down
@wiki_page.move_lower
@wiki_page.save
flash[:highlight] = @wiki_page.id
respond_to do |format|
format.html { redirect_to course_url(@course) }
end
end
def undelete
@wiki_page = WikiPage.find_with_deleted(params[:id])
@wiki_page.update_attribute(:deleted_at, nil)
flash[:notice] = "Wiki page restored"[]
WikiRestoreLogEntry.create!(:target_id => @wiki_page.id, :user => @current_user, :course => @wiki_page.course)
respond_to do |format|
format.html { redirect_to course_wiki_url(@wiki_page.course, @wiki_page) }
end
end
protected
def find_wiki
params[:course_id] = Course.find_by_short_name(params[:course_id]).id if !params[:course_id].is_numeric? and !Course.find_by_short_name(params[:course_id]).nil?
@course = Course.find(params[:course_id])
params[:id] = @course.wiki_pages.find_by_title(params[:id]).id if params[:id] and !params[:id].is_numeric? and !@course.wiki_pages.find_by_title(params[:id]).nil?
@wiki_page = params[:id] ? @course.wiki_pages.find(params[:id]) : WikiPage.new(params[:wiki_page])
end
def cache_sweep
expire_fragment(:controller => 'courses', :action => 'show')
expire_fragment(:action => 'show')
end
end