Class: AttributionsController

Inherits:
ApplicationController show all
Includes:
DataControllerConfiguration::ProjectDataControllerConfiguration
Defined in:
app/controllers/attributions_controller.rb

Instance Attribute Summary

Attributes inherited from ApplicationController

#is_data_controller, #is_task_controller, #meta_data, #meta_description, #meta_keywords, #meta_title, #page_title, #site_name

Instance Method Summary (collapse)

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods inherited from ApplicationController

#digest_cookie, #digested_cookie_exists?, #disable_turbolinks, #invalid_object, #is_data_controller?, #is_task_controller?, #log_user_recent_route, #project_matches, #record_not_found, #set_project_from_params

Methods included from Whitelist

#whitelist_constantize

Methods included from ProjectsHelper

#project_link, #project_tag, #projects_list, #projects_search_form

Methods included from InterceptApi

#intercept_api, #token_authenticate

Instance Method Details

- (Object) attribution_params (private)



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/controllers/attributions_controller.rb', line 88

def attribution_params
  params.require(:attribution).permit(
    :copyright_year, :license, :attribution_object_type, :attribution_object_id,
    :annotated_global_entity, :_destroy,
    roles_attributes: [
      :id,
      :_destroy,
      :type,
      :person_id,
      :position,
      person_attributes: [
        :last_name, :first_name, :suffix, :prefix
      ]])
end

- (Object) create

POST /attribution POST /attribution.json



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/attributions_controller.rb', line 37

def create
  @attribution = Attribution.new(attribution_params)

  respond_to do |format|
    if @attribution.save
      format.html { redirect_to @attribution, notice: 'Attribution was successfully created.' }
      format.json { render :show, status: :created, location: @attribution }
    else
      format.html { render :new }
      format.json { render json: @attribution.errors, status: :unprocessable_entity }
    end
  end
end

- (Object) destroy

DELETE /attributions/1 DELETE /attributions/1.json



67
68
69
70
71
72
73
# File 'app/controllers/attributions_controller.rb', line 67

def destroy
  @attribution.destroy
  respond_to do |format|
    format.html { redirect_to attributions_url, notice: 'Attribution was successfully destroyed.' }
    format.json { head :no_content }
  end
end

- (Object) edit

GET /attributions/1/edit



32
33
# File 'app/controllers/attributions_controller.rb', line 32

def edit
end

- (Object) index

GET /attributions GET /attributions.json



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/attributions_controller.rb', line 8

def index
  respond_to do |format|
    format.html do
      @recent_objects = Attribution.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10)
      render '/shared/data/all/index'
    end
    format.json {
      @attributions = Queries::Attribution::Filter.new(params).all.where(project_id: sessions_current_project_id).
      page(params[:page]).per(params[:per] || 500)
    }
  end
end

- (Object) licenses



75
76
77
# File 'app/controllers/attributions_controller.rb', line 75

def licenses
  render json: CREATIVE_COMMONS_LICENSES
end

- (Object) role_types



79
80
81
# File 'app/controllers/attributions_controller.rb', line 79

def role_types
  render json: ['AttributionCreator', 'AttributionOwner', 'AttributionEditor', 'AttributionCopyrightHolder']
end

- (Object) set_attribution (private)



84
85
86
# File 'app/controllers/attributions_controller.rb', line 84

def set_attribution
  @attribution = Attribution.find(params[:id])
end

- (Object) show

GET /attributions/1 GET /attributions/1.json



23
24
# File 'app/controllers/attributions_controller.rb', line 23

def show
end

- (Object) update

PATCH/PUT /attributions/1 PATCH/PUT /attributions/1.json



53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/attributions_controller.rb', line 53

def update
  respond_to do |format|
    if @attribution.update(attribution_params)
      format.html { redirect_to @attribution, notice: 'Attribution was successfully updated.' }
      format.json { render :show, status: :ok, location: @attribution }
    else
      format.html { render :edit }
      format.json { render json: @attribution.errors, status: :unprocessable_entity }
    end
  end
end