mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
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:
parent
5985daf677
commit
68788ce9fc
13 changed files with 240 additions and 141 deletions
|
|
@ -1,7 +1,7 @@
|
|||
namespace :data do
|
||||
desc 'Sets conference_id in all pre-existing PaperTrail::Version objects'
|
||||
task set_conference_in_versions: :environment do
|
||||
|
||||
ids_with_failure = []
|
||||
PaperTrail::Version.where(conference_id: nil, item_type: %w[Conference Event]).each do |version|
|
||||
# All pre-existing versions are either of Conference or Event
|
||||
if version.item_type == 'Conference'
|
||||
|
|
@ -9,13 +9,25 @@ namespace :data do
|
|||
|
||||
elsif version.item_type == 'Event'
|
||||
event = (version.item || version.reify || version.next.reify)
|
||||
if event.try(:program)
|
||||
version.update_attributes(conference_id: event.program.conference_id)
|
||||
else
|
||||
puts "Setting conference_id value failed for PaperTrail::Version object with ID=#{version.id}"
|
||||
end
|
||||
|
||||
conference_id = if event.try(:program)
|
||||
event.program.conference_id
|
||||
# Event had attribute conference_id before it was replaced with program_id
|
||||
elsif version.changeset[:conference_id]
|
||||
version.changeset[:conference_id].second
|
||||
elsif version.changeset[:program_id]
|
||||
version.changeset[:program_id].second
|
||||
elsif version.object && (object = YAML.safe_load(version.object))
|
||||
object['conference_id']
|
||||
else
|
||||
ids_with_failure << version.id
|
||||
puts "Setting conference_id value failed for PaperTrail::Version object with ID=#{version.id}"
|
||||
nil
|
||||
end
|
||||
version.update_attributes(conference_id: conference_id)
|
||||
end
|
||||
end
|
||||
puts 'All done!'
|
||||
puts "IDs with failures: #{ids_with_failure}" if ids_with_failure.any?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue