Class: LeadItemsController
- Inherits:
- 
      ApplicationController
      
        - Object
- ActionController::Base
- ApplicationController
- LeadItemsController
 
- Defined in:
- app/controllers/lead_items_controller.rb
Constant Summary
Constants included from ProjectsHelper
ProjectsHelper::CLASSIFIER, ProjectsHelper::CLASSIFIER_ANNOTATION
Instance Method Summary collapse
- #add_lead_items_to_lead ⇒ Object
- #add_otu_index ⇒ Object
- 
  
    
      #create  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    POST /lead_items or /lead_items.json. 
- 
  
    
      #destroy  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    DELETE /lead_items/1 or /lead_items/1.json. 
- #destroy_item_in_children ⇒ Object
- 
  
    
      #edit  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /lead_items/1/edit. 
- 
  
    
      #index  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /lead_items or /lead_items.json. 
- 
  
    
      #lead_item_params  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    Only allow a list of trusted parameters through. 
- 
  
    
      #new  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /lead_items/new. 
- #remove_otu_index ⇒ Object
- 
  
    
      #set_lead_item  ⇒ Object 
    
    
  
  
  
  
  private
  
  
  
  
    Use callbacks to share common setup or constraints between actions. 
- 
  
    
      #show  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    GET /lead_items/1 or /lead_items/1.json. 
- 
  
    
      #update  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    PATCH/PUT /lead_items/1 or /lead_items/1.json. 
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
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, #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
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
#add_lead_items_to_lead ⇒ Object
| 75 76 77 78 79 80 81 82 83 84 85 | # File 'app/controllers/lead_items_controller.rb', line 75 def add_lead_items_to_lead parent = Lead.find(params[:parent_id]) otu_ids = params[:otu_ids] exclusive = params[:exclusive_otu_ids] || [] add_new_to_first_child = params[:add_new_to_first_child] || false added = LeadItem.add_items_to_lead(parent, otu_ids, exclusive, add_new_to_first_child) if !added render json: parent.errors, status: :unprocessable_entity end end | 
#add_otu_index ⇒ Object
| 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | # File 'app/controllers/lead_items_controller.rb', line 87 def add_otu_index @lead = Lead.find(params[:lead_id]) added = LeadItem.add_otu_index_for_lead( @lead, params[:otu_id], params[:exclusive] ) if !added render json: @lead.errors, status: :unprocessable_entity return end @lead_item_otus = @lead.parent.apportioned_lead_item_otus render partial: 'leads/lead_item_otus', locals: { lead_item_otus: @lead_item_otus, lead: @lead } end | 
#create ⇒ Object
POST /lead_items or /lead_items.json
| 24 25 26 27 28 29 30 31 32 33 34 35 36 | # File 'app/controllers/lead_items_controller.rb', line 24 def create @lead_item = LeadItem.new(lead_item_params) respond_to do |format| if @lead_item.save format.html { redirect_to @lead_item, notice: 'Lead item was successfully created.' } format.json { render :show, status: :created, location: @lead_item } else format.html { render :new, status: :unprocessable_entity } format.json { render json: @lead_item.errors, status: :unprocessable_entity } end end end | 
#destroy ⇒ Object
DELETE /lead_items/1 or /lead_items/1.json
| 52 53 54 55 56 57 58 59 | # File 'app/controllers/lead_items_controller.rb', line 52 def destroy @lead_item.destroy! respond_to do |format| format.html { redirect_to lead_items_path, status: :see_other, notice: 'Lead item was successfully destroyed.' } format.json { head :no_content } end end | 
#destroy_item_in_children ⇒ Object
| 61 62 63 64 65 66 67 68 69 70 71 72 73 | # File 'app/controllers/lead_items_controller.rb', line 61 def destroy_item_in_children lead_ids = Lead.find(params[:parent_id]).children.map(&:id) # Only one child should ever have the lead_item we're looking for, the # following is just the most economical way of finding and destroying it. begin LeadItem .where(lead_id: lead_ids, otu_id: params[:otu_id]) .destroy_all rescue ActiveRecord::RecordNotDestroyed => e errors.add(:base, "Destroy lead item failed! '#{e}'") return false end end | 
#edit ⇒ Object
GET /lead_items/1/edit
| 20 21 | # File 'app/controllers/lead_items_controller.rb', line 20 def edit end | 
#index ⇒ Object
GET /lead_items or /lead_items.json
| 7 8 | # File 'app/controllers/lead_items_controller.rb', line 7 def index end | 
#lead_item_params ⇒ Object (private)
Only allow a list of trusted parameters through.
| 122 123 124 | # File 'app/controllers/lead_items_controller.rb', line 122 def lead_item_params params.require(:lead_item).permit(:lead_id, :otu_id, :project_id, :created_by_id, :updated_by_id, :position) end | 
#new ⇒ Object
GET /lead_items/new
| 15 16 17 | # File 'app/controllers/lead_items_controller.rb', line 15 def new @lead_item = LeadItem.new end | 
#remove_otu_index ⇒ Object
| 102 103 104 105 106 107 108 109 110 111 112 113 | # File 'app/controllers/lead_items_controller.rb', line 102 def remove_otu_index @lead = Lead.find(params[:lead_id]) removed = LeadItem.remove_otu_index_for_lead(@lead, params[:otu_id]) if !removed render json: @lead.errors, status: :unprocessable_entity return end @lead_item_otus = @lead.parent.apportioned_lead_item_otus render partial: 'leads/lead_item_otus', locals: { lead_item_otus: @lead_item_otus, lead: @lead } end | 
#set_lead_item ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
| 117 118 119 | # File 'app/controllers/lead_items_controller.rb', line 117 def set_lead_item @lead_item = LeadItem.find(params[:id]) end | 
#show ⇒ Object
GET /lead_items/1 or /lead_items/1.json
| 11 12 | # File 'app/controllers/lead_items_controller.rb', line 11 def show end | 
#update ⇒ Object
PATCH/PUT /lead_items/1 or /lead_items/1.json
| 39 40 41 42 43 44 45 46 47 48 49 | # File 'app/controllers/lead_items_controller.rb', line 39 def update respond_to do |format| if @lead_item.update(lead_item_params) format.html { redirect_to @lead_item, notice: 'Lead item was successfully updated.' } format.json { render :show, status: :ok, location: @lead_item } else format.html { render :edit, status: :unprocessable_entity } format.json { render json: @lead_item.errors, status: :unprocessable_entity } end end end |