mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-15 20:54:03 +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,17 +1,17 @@
|
|||
module Admin
|
||||
class VersionsController < Admin::BaseController
|
||||
skip_authorization_check
|
||||
load_resource :conference, find_by: :short_title
|
||||
load_and_authorize_resource class: PaperTrail::Version
|
||||
|
||||
def index
|
||||
authorize! :index, PaperTrail::Version.new(item_type: 'User')
|
||||
conf_ids_for_organizer = current_user.is_admin? ? Conference.pluck(:id) : Conference.with_role(:organizer, current_user).pluck(:id)
|
||||
@versions = PaperTrail::Version.where(["conference_id IN (?) OR item_type = 'User'", conf_ids_for_organizer])
|
||||
@conf_ids_with_role = current_user.is_admin? ? Conference.pluck(:short_title) : Conference.with_role([:organizer, :cfp, :info_desk], current_user).pluck(:short_title)
|
||||
|
||||
return if @conference.blank?
|
||||
authorize! :index, PaperTrail::Version.new(conference_id: @conference.id)
|
||||
@versions = @versions.where(conference_id: @conference.id)
|
||||
end
|
||||
|
||||
def revert_attribute
|
||||
@version = PaperTrail::Version.find(params[:id])
|
||||
authorize! :revert_attribute, @version
|
||||
|
||||
if params[:attribute] && @version.changeset.reject{ |_, values| values[0].blank? && values[1].blank? }.keys.include?(params[:attribute])
|
||||
if @version.item[params[:attribute]] == @version.changeset[params[:attribute]][0]
|
||||
flash[:error] = 'The item is already in the state that you are trying to revert it back to'
|
||||
|
|
@ -33,9 +33,6 @@ module Admin
|
|||
end
|
||||
|
||||
def revert_object
|
||||
@version = PaperTrail::Version.find(params[:id])
|
||||
authorize! :revert_object, @version
|
||||
|
||||
if @version.event != 'create'
|
||||
if @version.reify.save
|
||||
flash[:notice] = 'The selected change was successfully reverted'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue