Show conference changelog

Use load_and_authorize_resource in versions controlller
Add conference specifc route to revision history page
Users with role can view revision_history only for the versions they have access to
Handle versions where conference_id is not set (records before papertrail was introduced)
This commit is contained in:
Nishanth Vijayan 2016-08-06 17:22:53 +05:30 committed by Shlok Srivastava
parent 5985daf677
commit 68788ce9fc
13 changed files with 240 additions and 141 deletions

View file

@ -98,25 +98,6 @@ module ApplicationHelper
.reverse.sub(',', ' dna ').reverse
end
# Recieves a model_name and id
# Returns nil if model_name is invalid
# Returns object in its current state if its alive
# Otherwise Returns object state just before deletion
def current_or_last_object_state(model_name, id)
return nil unless id.present? && model_name.present?
begin
object = model_name.constantize.find_by(id: id)
rescue NameError
return nil
end
if object.nil?
object_last_version = PaperTrail::Version.where(item_type: model_name, item_id: id).last
object = object_last_version.reify if object_last_version
end
object
end
def normalize_array_length(hashmap, length)
hashmap.each do |_, value|
if value.length < length