Merge pull request #4339 from BrokenEagle/version-reports

Add alternate version comparisons
This commit is contained in:
evazion
2020-03-20 16:32:28 -05:00
committed by GitHub
45 changed files with 559 additions and 304 deletions

View File

@@ -40,6 +40,10 @@ class ApplicationController < ActionController::Base
super
end
def set_version_comparison
params[:type] = %w[previous subsequent current].include?(params[:type]) ? params[:type] : "previous"
end
def model_name
controller_name.classify
end

View File

@@ -2,6 +2,7 @@ class ArtistCommentaryVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
set_version_comparison
@commentary_versions = ArtistCommentaryVersion.paginated_search(params)
@commentary_versions = @commentary_versions.includes(:updater, post: :uploader) if request.format.html?

View File

@@ -2,6 +2,7 @@ class ArtistVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
set_version_comparison
@artist_versions = ArtistVersion.paginated_search(params)
@artist_versions = @artist_versions.includes(:updater, artist: :urls) if request.format.html?

View File

@@ -2,6 +2,7 @@ class NoteVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
set_version_comparison
@note_versions = NoteVersion.paginated_search(params)
@note_versions = @note_versions.includes(:updater) if request.format.html?

View File

@@ -4,6 +4,7 @@ class PoolVersionsController < ApplicationController
around_action :set_timeout
def index
set_version_comparison
@pool_versions = PoolVersion.paginated_search(params)
@pool_versions = @pool_versions.includes(:updater, :pool) if request.format.html?
@@ -19,7 +20,8 @@ class PoolVersionsController < ApplicationController
if params[:other_id]
@other_version = PoolVersion.find(params[:other_id])
else
@other_version = @pool_version.previous
set_version_comparison
@other_version = @pool_version.send(params[:type])
end
end

View File

@@ -6,6 +6,7 @@ class PostVersionsController < ApplicationController
respond_to :js, only: [:undo]
def index
set_version_comparison
@post_versions = PostVersion.paginated_search(params)
if request.format.html?

View File

@@ -1,9 +0,0 @@
class ReportsController < ApplicationController
respond_to :html, :xml, :json
def upload_tags
@user = User.find(params[:user_id])
@upload_reports = Reports::UploadTags.includes(versions: { post: :versions }).for_user(params[:user_id]).order("id desc").paginate(params[:page], :limit => params[:limit])
respond_with(@upload_reports)
end
end

View File

@@ -3,6 +3,7 @@ class WikiPageVersionsController < ApplicationController
layout "sidebar"
def index
set_version_comparison
@wiki_page_versions = WikiPageVersion.paginated_search(params)
@wiki_page_versions = @wiki_page_versions.includes(:updater) if request.format.html?
@@ -16,15 +17,20 @@ class WikiPageVersionsController < ApplicationController
def diff
if params[:thispage].blank? || params[:otherpage].blank?
redirect_back fallback_location: wiki_pages_path, notice: "You must select two versions to diff"
return
end
@thispage = WikiPageVersion.find(params[:thispage])
@otherpage = WikiPageVersion.find(params[:otherpage])
if @thispage.id < @otherpage.id
@thispage, @otherpage = @otherpage, @thispage
page_id = params[:thispage] || params[:otherpage]
if page_id.blank?
redirect_back fallback_location: wiki_pages_path, notice: "You must select at least one version to diff"
return
end
set_version_comparison
@thispage = WikiPageVersion.find(page_id)
@otherpage = @thispage.send(params[:type])
else
@thispage = WikiPageVersion.find(params[:thispage])
@otherpage = WikiPageVersion.find(params[:otherpage])
if @thispage.id < @otherpage.id
@thispage, @otherpage = @otherpage, @thispage
end
end
respond_with([@thispage, @otherpage])