2014-03-23 00:22:25 +00:00
|
|
|
class VersionsController < ApplicationController
|
|
|
|
before_filter :get_article
|
|
|
|
|
|
|
|
def index
|
|
|
|
@versions = @article.versions
|
2014-03-31 21:33:16 +00:00
|
|
|
render 'articles/history'
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@version = @article.versions.find params[:id]
|
|
|
|
@nobody = true
|
2014-03-31 21:33:16 +00:00
|
|
|
render 'articles/version'
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
raise AccessError unless @article.can_update? cuser
|
|
|
|
@version = @article.versions.find params[:id]
|
|
|
|
@nobody = true
|
|
|
|
|
|
|
|
if @article.revert_to! @version.version
|
|
|
|
flash[:notice] = t(:articles_revert, :version => @version.version)
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to @article
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_article
|
|
|
|
@article = Article.find(params[:article_id])
|
|
|
|
end
|
|
|
|
end
|