Class: PapertrailController
  
  
  
  Constant Summary
  
  
  ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #destroy_redirect
  
  
  
  
  
  
  
  
  
  
  #json_request?
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  Methods included from LogRecent
  #log_user_recent_route
  
  
  
  
  
  
  
  
  
  Methods included from Cookies
  #digest_cookie, #digested_cookie_exists?
  
  
  
  
  
  
  
  
  
  Methods included from Whitelist
  #whitelist_constantize
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  #cumulative_gb_per_year, #cumulative_projects_created_per_year, #document_cumulative_gb_per_year, #document_gb_per_year, #gb_per_year, #image_cumulative_gb_per_year, #image_gb_per_year, #invalid_object, #project_classification, #project_link, #project_login_link, #project_matches, #project_tag, #projects_list, #projects_search_form, #sound_cumulative_gb_per_year, #sound_gb_per_year, #taxonworks_classification, #week_in_review_graphs
  
  
  
  
  
  
  
  
  
  #intercept_api
  
  
  
  
  
  
  
  
  
  
  #intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
  
  
  
  
  
  
  
  
  
  
  
  
    Instance Method Details
    
      
  
  
    #compare  ⇒ Object 
  
  
  
  
    | 
69
70
71
72
73
74
75
76
77
78
79 | # File 'app/controllers/papertrail_controller.rb', line 69
def compare
  klass = whitelist_constantize(params.require(:object_type))
  @object = klass.find(params.require(:object_id))
  if invalid_object(@object)
    record_not_found
  else
    @result = Vendor::Papertrail.compare(@object, compare_params)
    @result ? render('compare') : record_not_found
  end
end | 
 
    
      
  
  
    #compare_params  ⇒ Object  
  
  
  
  
    | 
93
94
95 | # File 'app/controllers/papertrail_controller.rb', line 93
def compare_params
  params.permit(:version_a, :version_b)
end | 
 
    
      
  
  
    #index  ⇒ Object 
  
  
  
  
    | 
4
5
6
7
8
9
10
11
12
13
14
15
16 | # File 'app/controllers/papertrail_controller.rb', line 4
def index
  respond_to do |format|
    format.html {
      redirect_to hub_path, notice: 'You requested a papertrail for nothing.' and return if params[:object_type].blank?
      klass = whitelist_constantize(params.require(:object_type))
      @object = klass.find(params[:object_id])
      record_not_found if invalid_object(@object)
      render :papertrail
    }
        format.json { @versions = papertrail_versions }
  end
end | 
 
    
      
  
  
    #papertrail_versions  ⇒ Object  
  
  
  
  
    | 
83
84
85
86
87
88
89
90 | # File 'app/controllers/papertrail_controller.rb', line 83
def papertrail_versions
  if o = GlobalID::Locator.locate(params.require(:object_global_id))
    render head 404, "content_type" => 'text/plain' if o.respond_to?(:project_id) && o.project_id != sessions_current_project_id
    o.versions
  else
    []
  end
end | 
 
    
      
  
  
    #show  ⇒ Object 
  
  
  
  
    | 
18
19
20
21
22
23
24
25
26 | # File 'app/controllers/papertrail_controller.rb', line 18
def show
  @version = PaperTrail::Version.find(params[:id])
  @object = @version.item
  if invalid_object(@object)
    record_not_found
  else
    render 'papertrail'
  end
end | 
 
    
      
  
  
    #update  ⇒ Object 
  
  
  
  
    | 
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 | # File 'app/controllers/papertrail_controller.rb', line 28
def update
  klass = whitelist_constantize(params.require(:object_type))
  @object = klass.find(params[:object_id])
  if invalid_object(@object)
    record_not_found
  else
    new_attributes = params[:attributes]
    if !new_attributes.nil?
      new_attributes.each do |key, value|
        if @object.has_attribute?(key)
          @object.assign_attributes(Hash[key, value])
        end
      end
    end
    if !@object.changed?
      flash[:notice] = 'No changes made!'
    elsif @object.save
      flash[:notice] = 'Successfully restored!'
    else
      flash[:alert] = 'Unsuccessfully restored!'
    end
    json_resp = { "url": papertrail_path(object_type: @object.class.base_class, object_id: @object.id) }
                if ControlledVocabularyTerm > @object.class
      json_resp['url'] = papertrail_path(object_type: @object.type, object_id: @object.id)
    end
    respond_to do |format|
      format.html { redirect_to(papertrail_path(object_type: @object.type, object_id: @object.id)) }
      format.json { render json: json_resp }
    end
  end
end |