Class: DocumentationController

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

Constant Summary

Constants included from ProjectsHelper

ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION

Instance Method Summary collapse

Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration

#annotator_params

Methods included from RedirectHelper

#destroy_redirect

Methods included from RequestType

#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

Methods included from ProjectsHelper

#cumulative_gb_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_matches, #project_tag, #projects_list, #projects_search_form, #taxonworks_classification, #week_in_review_graphs

Methods included from Api::Intercept

#intercept_api

Methods included from TokenAuthentication

#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate

Instance Method Details

#createObject

POST /documentation POST /documentation.json



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

def create
  @documentation = Documentation.new(documentation_params)

  respond_to do |format|
    if @documentation.save
      format.html { redirect_to url_for(@documentation.metamorphosize),
                                notice: 'Documentation was successfully created.' }
      format.json { render action: 'show', status: :created, location: @documentation }
    else
      format.html { render action: 'new' }
      format.json { render json: @documentation.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /documentation/1 DELETE /documentation/1.json



69
70
71
72
73
74
75
# File 'app/controllers/documentation_controller.rb', line 69

def destroy
  @documentation.destroy
  respond_to do |format|
    format.html { redirect_to documentation_index_url, notice: 'Documentation was successfully destroyed.' }
    format.json { head :no_content }
  end
end

#documentation_paramsObject (private)



102
103
104
105
106
107
# File 'app/controllers/documentation_controller.rb', line 102

def documentation_params
  params.require(:documentation).permit(
    :documentation_object_id, :documentation_object_type, :document_id, :annotated_global_entity, :position,
    document_attributes: [:document_file, :is_public]
  )
end

#downloadObject

GET /documentation/download

documentation_download_index is the route name, for some inflection bug reason


91
92
93
94
# File 'app/controllers/documentation_controller.rb', line 91

def download
  send_data Export::CSV.generate_csv(
    Documentation.where(project_id: sessions_current_project_id)), type: 'text', filename: "documentation_#{DateTime.now}.tsv"
end

#editObject

GET /documentation/1/edit



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

def edit
end

#indexObject

GET /documentation GET /documentation.json



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

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

#listObject



77
78
79
# File 'app/controllers/documentation_controller.rb', line 77

def list
  @documentation = Documentation.with_project_id(sessions_current_project_id).order(:id).page(params[:page]) #.per(10)
end

#newObject

GET /documentation/new



27
28
29
# File 'app/controllers/documentation_controller.rb', line 27

def new
  @documentation = Documentation.new
end

#searchObject



81
82
83
84
85
86
87
# File 'app/controllers/documentation_controller.rb', line 81

def search
  if params[:id].blank?
    redirect_to documentation_path, alert: 'You must select an item from the list with a click or tab press before clicking show.'
  else
    redirect_to documentation_path(params[:id])
  end
end

#set_documentationObject (private)



98
99
100
# File 'app/controllers/documentation_controller.rb', line 98

def set_documentation
  @documentation = Documentation.where(project_id: sessions_current_project_id).find(params[:id])
end

#showObject

GET /documentation/1 GET /documentation/1.json



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

def show
end

#updateObject

PATCH/PUT /documentation/1 PATCH/PUT /documentation/1.json



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

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