Class: SequencesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SequencesController
- Defined in:
- app/controllers/sequences_controller.rb
Instance Method Summary collapse
- #autocomplete ⇒ Object
- #batch_load ⇒ Object
- #batch_params ⇒ Object private
-
#create ⇒ Object
POST /sequences POST /sequences.json.
- #create_genbank_batch_file_load ⇒ Object
- #create_genbank_batch_load ⇒ Object
- #create_primers_batch_load ⇒ Object
-
#destroy ⇒ Object
DELETE /sequences/1 DELETE /sequences/1.json.
-
#edit ⇒ Object
GET /sequences/1/edit.
-
#index ⇒ Object
GET /sequences GET /sequences.json.
- #list ⇒ Object
-
#new ⇒ Object
GET /sequences/new.
- #preview_genbank_batch_file_load ⇒ Object
- #preview_genbank_batch_load ⇒ Object
- #preview_primers_batch_load ⇒ Object
- #search ⇒ Object
- #select_options ⇒ Object
-
#sequence_params ⇒ Object
private
Never trust parameters from the scary internet, only allow the white list through.
-
#set_sequence ⇒ Object
private
Use callbacks to share common setup or constraints between actions.
-
#show ⇒ Object
GET /sequences/1 GET /sequences/1.json.
-
#update ⇒ Object
PATCH/PUT /sequences/1 PATCH/PUT /sequences/1.json.
Methods included from DataControllerConfiguration::ProjectDataControllerConfiguration
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
#invalid_object, #project_link, #project_matches, #project_tag, #projects_list, #projects_search_form
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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/controllers/sequences_controller.rb', line 79 def autocomplete t = "#{params[:term]}%" @sequences = Sequence.where(project_id: sessions_current_project_id).where('sequence ILIKE ? OR name ILIKE ?', t, t) data = @sequences.collect do |t| l = [t.name, t.sequence[0..10]].compact.join(': ') {id: t.id, label: l, gid: t.to_global_id.to_s, response_values: { params[:method] => t.id }, label_html: l } end render json: data end |
#batch_load ⇒ Object
96 97 |
# File 'app/controllers/sequences_controller.rb', line 96 def batch_load end |
#batch_params ⇒ Object (private)
192 193 194 |
# File 'app/controllers/sequences_controller.rb', line 192 def batch_params params.permit(:namespace, :file, :import_level, files: []).merge(user_id: sessions_current_user_id, project_id: sessions_current_project_id).to_h.symbolize_keys end |
#create ⇒ Object
POST /sequences POST /sequences.json
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/sequences_controller.rb', line 33 def create @sequence = Sequence.new(sequence_params) respond_to do |format| if @sequence.save format.html { redirect_to @sequence, notice: 'Sequence was successfully created.' } format.json { render :show, status: :created, location: @sequence } else format.html { render :new } format.json { render json: @sequence.errors, status: :unprocessable_entity } end end end |
#create_genbank_batch_file_load ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/controllers/sequences_controller.rb', line 110 def create_genbank_batch_file_load if params[:files] && (params[:files][0].tempfile, :batch_file_load_genbank_sequences_md5) @result = BatchFileLoad::Import::Sequences::GenbankInterpreter.new(**batch_params) if @result.create flash[:notice] = "Successfully processed #{@result.total_files_processed} file(s), #{@result.total_records_created} sequences were created." render 'sequences/batch_file_load/genbank/create' and return else flash[:alert] = 'Batch import failed.' end else flash[:alert] = 'File to batch upload must be supplied.' end render :batch_load end |
#create_genbank_batch_load ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/controllers/sequences_controller.rb', line 136 def create_genbank_batch_load if params[:file] && (params[:file].tempfile, :Genbank_sequences_md5) @result = BatchLoad::Import::Sequences::GenbankInterpreter.new(**batch_params) if @result.create flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} sequences were created." render 'sequences/batch_load/genbank/create' and return else flash[:alert] = 'Batch import failed.' end else flash[:alert] = 'File to batch upload must be supplied.' end render :batch_load end |
#create_primers_batch_load ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'app/controllers/sequences_controller.rb', line 162 def create_primers_batch_load if params[:file] && (params[:file].tempfile, :Primers_sequences_md5) @result = BatchLoad::Import::Sequences::PrimersInterpreter.new(**batch_params) if @result.create flash[:notice] = "Successfully proccessed file, #{@result.total_records_created} sequences were created." render 'sequences/batch_load/primers/create' and return else flash[:alert] = 'Batch import failed.' end else flash[:alert] = 'File to batch upload must be supplied.' end render :batch_load end |
#destroy ⇒ Object
DELETE /sequences/1 DELETE /sequences/1.json
63 64 65 66 67 68 69 |
# File 'app/controllers/sequences_controller.rb', line 63 def destroy @sequence.destroy respond_to do |format| format.html { redirect_to sequences_url, notice: 'Sequence was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /sequences/1/edit
24 25 |
# File 'app/controllers/sequences_controller.rb', line 24 def edit end |
#index ⇒ Object
GET /sequences GET /sequences.json
8 9 10 11 |
# File 'app/controllers/sequences_controller.rb', line 8 def index @recent_objects = Sequence.recent_from_project_id(sessions_current_project_id).order(updated_at: :desc).limit(10) render '/shared/data/all/index' end |
#list ⇒ Object
27 28 29 |
# File 'app/controllers/sequences_controller.rb', line 27 def list @sequences = Sequence.with_project_id(sessions_current_project_id).page(params[:page]) end |
#new ⇒ Object
GET /sequences/new
19 20 21 |
# File 'app/controllers/sequences_controller.rb', line 19 def new @sequence = Sequence.new end |
#preview_genbank_batch_file_load ⇒ Object
99 100 101 102 103 104 105 106 107 108 |
# File 'app/controllers/sequences_controller.rb', line 99 def preview_genbank_batch_file_load if params[:files] @result = BatchFileLoad::Import::Sequences::GenbankInterpreter.new(**batch_params) (params[:files][0].tempfile, :batch_file_load_genbank_sequences_md5) render 'sequences/batch_file_load/genbank/preview' else flash[:notice] = 'No file(s) provided!' redirect_to action: :batch_load end end |
#preview_genbank_batch_load ⇒ Object
125 126 127 128 129 130 131 132 133 134 |
# File 'app/controllers/sequences_controller.rb', line 125 def preview_genbank_batch_load if params[:file] @result = BatchLoad::Import::Sequences::GenbankInterpreter.new(**batch_params) (params[:file].tempfile, :Genbank_sequences_md5) render 'sequences/batch_load/genbank/preview' else flash[:notice] = 'No file provided!' redirect_to action: :batch_load end end |
#preview_primers_batch_load ⇒ Object
151 152 153 154 155 156 157 158 159 160 |
# File 'app/controllers/sequences_controller.rb', line 151 def preview_primers_batch_load if params[:file] @result = BatchLoad::Import::Sequences::PrimersInterpreter.new(**batch_params) (params[:file].tempfile, :Primers_sequences_md5) render 'sequences/batch_load/primers/preview' else flash[:notice] = 'No file provided!' redirect_to action: :batch_load end end |
#search ⇒ Object
71 72 73 74 75 76 77 |
# File 'app/controllers/sequences_controller.rb', line 71 def search if params[:id].blank? redirect_to sequences_path, notice: 'You must select an item from the list with a click or tab press before clicking show.' else redirect_to sequence_path(params[:id]) end end |
#select_options ⇒ Object
177 178 179 |
# File 'app/controllers/sequences_controller.rb', line 177 def @sequences = Sequence.select_optimized(sessions_current_user_id, sessions_current_project_id, params[:target]) end |
#sequence_params ⇒ Object (private)
Never trust parameters from the scary internet, only allow the white list through.
188 189 190 |
# File 'app/controllers/sequences_controller.rb', line 188 def sequence_params params.require(:sequence).permit(:name, :sequence, :sequence_type, :created_by_id, :updated_by_id, :project_id) end |
#set_sequence ⇒ Object (private)
Use callbacks to share common setup or constraints between actions.
183 184 185 |
# File 'app/controllers/sequences_controller.rb', line 183 def set_sequence @sequence = Sequence.where(project_id: sessions_current_project_id).find(params[:id]) end |
#show ⇒ Object
GET /sequences/1 GET /sequences/1.json
15 16 |
# File 'app/controllers/sequences_controller.rb', line 15 def show end |
#update ⇒ Object
PATCH/PUT /sequences/1 PATCH/PUT /sequences/1.json
49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/sequences_controller.rb', line 49 def update respond_to do |format| if @sequence.update(sequence_params) format.html { redirect_to @sequence, notice: 'Sequence was successfully updated.' } format.json { render :show, status: :ok, location: @sequence } else format.html { render :edit } format.json { render json: @sequence.errors, status: :unprocessable_entity } end end end |