Class: RepositoriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RepositoriesController
- Defined in:
- app/controllers/repositories_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #autocomplete ⇒ Object
- #autocomplete_params ⇒ Object private
-
#create ⇒ Object
POST /repositories POST /repositories.json.
-
#destroy ⇒ Object
DELETE /repositories/1 DELETE /repositories/1.json.
-
#download ⇒ Object
GET /repositories/download.
-
#edit ⇒ Object
GET /repositories/1/edit.
-
#index ⇒ Object
GET /repositories GET /repositories.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /repositories/new.
- #repository_params ⇒ Object private
- #search ⇒ Object
-
#select_options ⇒ Object
GET /repositories/select_options.
- #set_repository ⇒ Object private
-
#show ⇒ Object
GET /repositories/1 GET /repositories/1.json.
-
#update ⇒ Object
PATCH/PUT /repositories/1 PATCH/PUT /repositories/1.json.
Methods included from DataControllerConfiguration::SharedDataControllerConfiguration
Methods included from RedirectHelper
Methods included from RequestType
Methods included from LogRecent
Methods included from Cookies
#digest_cookie, #digested_cookie_exists?
Methods included from Whitelist
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
Methods included from TokenAuthentication
#intercept_project, #intercept_user, #intercept_user_or_project, #project_token_authenticate, #token_authenticate
Instance Method Details
#autocomplete ⇒ Object
80 81 82 |
# File 'app/controllers/repositories_controller.rb', line 80 def autocomplete @repositories = ::Queries::Repository::Autocomplete.new(params[:term], **autocomplete_params).autocomplete end |
#autocomplete_params ⇒ Object (private)
96 97 98 |
# File 'app/controllers/repositories_controller.rb', line 96 def autocomplete_params params.permit(alternate_value_type: []).merge(project_id: sessions_current_project_id).to_h.symbolize_keys end |
#create ⇒ Object
POST /repositories POST /repositories.json
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/repositories_controller.rb', line 30 def create @repository = Repository.new(repository_params) respond_to do |format| if @repository.save format.html { redirect_to @repository, notice: 'Repository was successfully created.' } format.json { render action: 'show', status: :created, location: @repository } else format.html { render action: 'new' } format.json { render json: @repository.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /repositories/1 DELETE /repositories/1.json
60 61 62 63 64 65 66 |
# File 'app/controllers/repositories_controller.rb', line 60 def destroy @repository.destroy respond_to do |format| format.html { redirect_to repositories_url } format.json { head :no_content } end end |
#download ⇒ Object
GET /repositories/download
85 86 87 |
# File 'app/controllers/repositories_controller.rb', line 85 def download send_data Export::CSV.generate_csv(Repository.all), type: 'text', filename: "repositories_#{DateTime.now}.tsv" end |
#edit ⇒ Object
GET /repositories/1/edit
25 26 |
# File 'app/controllers/repositories_controller.rb', line 25 def edit end |
#index ⇒ Object
GET /repositories GET /repositories.json
8 9 10 11 12 |
# File 'app/controllers/repositories_controller.rb', line 8 def index @repositories = Repository.limit(20) @recent_objects = Repository.order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
68 69 70 |
# File 'app/controllers/repositories_controller.rb', line 68 def list @repositories = Repository.order(:id).page(params[:page]) #.per(10) #.per(3) end |
#new ⇒ Object
GET /repositories/new
20 21 22 |
# File 'app/controllers/repositories_controller.rb', line 20 def new @repository = Repository.new end |
#repository_params ⇒ Object (private)
105 106 107 |
# File 'app/controllers/repositories_controller.rb', line 105 def repository_params params.require(:repository).permit(:name, :url, :acronym, :status, :institutional_LSID, :is_index_herbariorum) end |
#search ⇒ Object
72 73 74 75 76 77 78 |
# File 'app/controllers/repositories_controller.rb', line 72 def search if params[:id].blank? redirect_to repositories_path, alert: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to repository_path(params[:id]) end end |
#select_options ⇒ Object
GET /repositories/select_options
90 91 92 |
# File 'app/controllers/repositories_controller.rb', line 90 def @repositories = Repository.select_optimized(sessions_current_user_id, sessions_current_project_id) end |
#set_repository ⇒ Object (private)
100 101 102 103 |
# File 'app/controllers/repositories_controller.rb', line 100 def set_repository @repository = Repository.find(params[:id]) @recent_object = @repository end |
#show ⇒ Object
GET /repositories/1 GET /repositories/1.json
16 17 |
# File 'app/controllers/repositories_controller.rb', line 16 def show end |
#update ⇒ Object
PATCH/PUT /repositories/1 PATCH/PUT /repositories/1.json
46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/repositories_controller.rb', line 46 def update respond_to do |format| if @repository.update(repository_params) format.html { redirect_to @repository, notice: 'Repository was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @repository.errors, status: :unprocessable_entity } end end end |