create func apply job
Check out, review, and merge locally
Step 1. Fetch and check out the branch for this merge request
git fetch origin git checkout -b ID5_JObApply origin/ID5_JObApply
Step 2. Review the changes locally
Step 3. Merge the branch and fix any conflicts that come up
git checkout master git merge --no-ff ID5_JObApply
Step 4. Push the result of the merge to GitLab
git push origin master
Note that pushing to GitLab requires write access to this repository.
Tip: You can also checkout merge requests locally by following these guidelines.
-
Ngô Trung Hưng @hungnt
added 1 commit
- a3e9d1b3 - add loading page
added 1 commit * a3e9d1b3 - add loading page [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5069&start_sha=423eef1a654d024137182bd0cebccdc5d3edda27)Toggle commit list -
Ngô Trung Hưng @hungnt
added 1 commit
- 4b9ef5ff - create ID5-6-7-12
added 1 commit * 4b9ef5ff - create ID5-6-7-12 [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5074&start_sha=a3e9d1b3e18902ef5e39c5cb689a954fdfbdd795)Toggle commit list -
Ngô Trung Hưng @hungnt
added 1 commit
- 871a399c - add i18n
added 1 commit * 871a399c - add i18n [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5077&start_sha=4b9ef5ff9d4283df405dbc8b20a2616a6e6ec61d)Toggle commit list -
app/controllers/apply_job_controller.rb 0 → 100644
17 18 def confirm 19 @apply_job = current_user.applied_jobs.new(applied_job_params) 20 @apply_job.cv = current_user.cv if @apply_job.cv.blank? 21 session[:cv_full_path] = @apply_job.cv.path 22 if @apply_job.invalid? 23 errors = [] 24 @apply_job.errors.full_messages.each { |mess| errors << "#{mess}<br>" } 25 flash[:error] = errors.join('<br>').html_safe 26 redirect_to apply_path(job_id: session[:job_id]) 27 end 28 session.delete(:job_id) 29 end 30 31 def done 32 data_apply = current_user.applied_jobs.new(applied_job_params) -
Hoang Phuc Do @phucdh commentedMaster
Nếu user sửa giá trị input của
applied_job_paramsthì có vấn đề gì không ?Vd: apply vào job ID 1, nhưng sửa giá trị input thành job ID 2
Nếu user sửa giá trị input của `applied_job_params` thì có vấn đề gì không ? Vd: apply vào job ID 1, nhưng sửa giá trị input thành job ID 2 -
Ngô Trung Hưng @hungnt commentedMaster
http://localhost:1234/en/apply?job_id=47 dạ nếu user thay params job_id thì nó nhảy qua job khác anh
http://localhost:1234/en/apply?job_id=47 dạ nếu user thay params job_id thì nó nhảy qua job khác anh -
Hoang Phuc Do @phucdh commentedMaster
Lấy trường hợp cụ thể:
- Truy cập http://localhost:1234/en/apply?job_id=47
- Nhập thông tin
- Sang trang confirm
- Hoàn tất apply
Ở bước 3, user inspect html và sửa gía trị của hidden field job_id thành 49. => Ở bước 4 khi tạo apply, giá trị job_id có còn tương ứng với bước 1 không ?
def done data_apply = current_user.applied_jobs.new(applied_job_params) ... enddata_applyđang được khởi tạo từapplied_job_paramscó giá trị được lấy từ input của formTrên view (
app/views/apply_job/confirm.html.erb) thì các giá trị này nằm trong hidden fieldVd:
<%= f.hidden_field(:job_id, value: @apply_job.job_id) %> <%= f.hidden_field(:name, value: @apply_job.name) %>Nếu người dùng cố tình sửa các giá trị trong những hidden field này thì khi submit có vấn đề gì không ?
Lấy trường hợp cụ thể: 1. Truy cập http://localhost:1234/en/apply?job_id=47 2. Nhập thông tin 3. Sang trang confirm 4. Hoàn tất apply Ở bước 3, user inspect html và sửa gía trị của hidden field job_id thành 49. => Ở bước 4 khi tạo apply, giá trị job_id có còn tương ứng với bước 1 không ? ```ruby def done data_apply = current_user.applied_jobs.new(applied_job_params) ... end ``` `data_apply` đang được khởi tạo từ `applied_job_params` có giá trị được lấy từ input của form Trên view (`app/views/apply_job/confirm.html.erb`) thì các giá trị này nằm trong hidden field Vd: ```ruby <%= f.hidden_field(:job_id, value: @apply_job.job_id) %> <%= f.hidden_field(:name, value: @apply_job.name) %> ``` Nếu người dùng cố tình sửa các giá trị trong những hidden field này thì khi submit có vấn đề gì không ? -
Ngô Trung Hưng @hungnt
changed this line in version 6 of the diff
changed this line in version 6 of the diff
changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5092&start_sha=6031ca8727c57d53169397be1a54b176d0b49e7e#8f0267326248c40ab343ad885d03cfb7a7023a35_32_32)Toggle commit list -
Ngô Trung Hưng @hungnt commentedMaster
Dạ e sử dụng session thay vì hidden field
Dạ e sử dụng session thay vì hidden field
Please register or sign in to reply -
-
app/controllers/apply_job_controller.rb 0 → 100644
1 # frozen_string_literal: true 2 3 # Applied jobs controller 4 class ApplyJobController < ApplicationController 5 before_action :authenticate_user!, only: :apply -
Hoang Phuc Do @phucdh commentedMaster
Chỉ
authenticate_user!một action apply, còn các action khác có cần không ?Ví dụ trong action
index, confirm, donecó sử dụngcurrent_user, cũng yêu cầu user đăng nhậpChỉ `authenticate_user!` một action apply, còn các action khác có cần không ? Ví dụ trong action `index, confirm, done` có sử dụng `current_user`, cũng yêu cầu user đăng nhập -
Ngô Trung Hưng @hungnt commentedMaster
dạ v e before_action cho các method cần sử dụng current_user
dạ v e before_action cho các method cần sử dụng current_user -
Ngô Trung Hưng @hungnt
changed this line in version 5 of the diff
changed this line in version 5 of the diff
changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5091&start_sha=871a399c4c068cfe9086a6151bb353c29f8bec90#8f0267326248c40ab343ad885d03cfb7a7023a35_5_5)Toggle commit list
-
-
3 3 # Application controller 4 4 class ApplicationController < ActionController::Base 5 5 protect_from_forgery with: :exception 6 # before_action :debug 6 7 7 8 before_action :configure_permitted_parameters, if: :devise_controller? 8 9 before_action :set_locale 9 10 11 # def debug 12 # puts "ab" 13 # byebug 14 # puts "adcsdcds" 15 # end 10 16 def set_locale 11 locale = params[:locale].to_s.strip.to_sym 17 user_signed_in? ? locale = current_user.language.to_sym : locale = params[:locale].to_s.strip.to_sym -
Hoang Phuc Do @phucdh commentedMasterEdited
locale = (user_signed_in? ? current_user.language : params[:locale].to_s.strip).to_sym```ruby locale = (user_signed_in? ? current_user.language : params[:locale].to_s.strip).to_sym ``` -
Ngô Trung Hưng @hungnt commentedMaster
Thanks anh
Thanks anh -
Ngô Trung Hưng @hungnt
changed this line in version 5 of the diff
changed this line in version 5 of the diff
changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5091&start_sha=871a399c4c068cfe9086a6151bb353c29f8bec90#7dc0dd94f601e507e2a20bad6adcf12a51caa380_17_11)Toggle commit list
-
-
app/views/apply_job/index.html.erb 0 → 100644
1 <div class="container"> 2 <div class="row"> 3 <div class="col-lg-12"> 4 <hr> 5 <div class="box_text_five_jobs"> 6 <span><%= t('apply_job.title') %></span> 7 </div> 8 <hr> 9 </div> 10 <div class="col-lg-12"> 11 <div class="breadcrumb_total_search_pagination_jobs"> 12 <div class="pagination_jobs"> 13 <div id="paginator"> 14 <%= paginate @jobs %> -
Hoang Phuc Do @phucdh commentedMaster
Nếu
@jobslàblankthì có cần đoạn html pagination không ?Nếu `@jobs` là `blank` thì có cần đoạn html pagination không ? -
Ngô Trung Hưng @hungnt commentedMaster
dạ e sửa lại
dạ e sửa lại -
Ngô Trung Hưng @hungnt
changed this line in version 5 of the diff
changed this line in version 5 of the diff
changed this line in [version 5 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5091&start_sha=871a399c4c068cfe9086a6151bb353c29f8bec90#9a317a78ed33706a1951c9bafb2fe7788a05c229_14_10)Toggle commit list
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- 6031ca87 - fix bug
added 1 commit * 6031ca87 - fix bug [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5091&start_sha=871a399c4c068cfe9086a6151bb353c29f8bec90)Toggle commit list -
app/controllers/apply_job_controller.rb 0 → 100644
1 # frozen_string_literal: true 2 3 # Applied jobs controller 4 class ApplyJobController < ApplicationController 5 before_action :authenticate_user! 6 7 def index 8 @jobs = current_user.applied_jobs.page(params[:page]) 9 end 10 11 def apply 12 redirect_to root_path if params[:job_id].blank? 13 @data_apply = current_user.applied_jobs.new(name: current_user.name, email: current_user.email) 14 session[:job_id] = params[:job_id] 15 @job = Job.find(params[:job_id]) -
Van Hau Le @haulv commented
@hungnt
Job.find(params[:job_id])=> apply với job_id ko tồn tại thì điều gì sẽ xảy ra?@hungnt `Job.find(params[:job_id])` => apply với job_id ko tồn tại thì điều gì sẽ xảy ra? -
Ngô Trung Hưng @hungnt commentedMaster
dạ nếu job_id k tồn tại nó sẽ chuyển đến trang 404
dạ nếu job_id k tồn tại nó sẽ chuyển đến trang 404
-
-
app/controllers/apply_job_controller.rb 0 → 100644
19 @apply_job = current_user.applied_jobs.new(applied_job_params) 20 @apply_job.cv = current_user.cv if @apply_job.cv.blank? 21 session[:cache_name] = @apply_job.cv.cache_name 22 if @apply_job.invalid? 23 errors = [] 24 @apply_job.errors.full_messages.each { |mess| errors << "#{mess}<br>" } 25 flash[:error] = errors.join('<br>').html_safe 26 redirect_to apply_path(job_id: session[:job_id]) 27 end 28 session.delete(:job_id) 29 end 30 31 def done 32 data_apply = current_user.applied_jobs.new(applied_job_params) 33 data_apply.cv.retrieve_from_cache!(session[:cache_name]) 34 if data_apply.save -
Van Hau Le @haulv commented
@hungnt
apply_datanhen em! Đặt tên hơi ngược ngược rồi Mà sao ko dùng thằng giá trị apply_data cho send mail? Mà phải đi fetch lại latest job chi vậy?AppliedMailer.applied_job_mail_to(apply_data).deliver_now@hungnt `apply_data` nhen em! Đặt tên hơi ngược ngược rồi Mà sao ko dùng thằng giá trị apply_data cho send mail? Mà phải đi fetch lại latest job chi vậy? ```ruby AppliedMailer.applied_job_mail_to(apply_data).deliver_now ``` -
Ngô Trung Hưng @hungnt commentedMaster
E mới edit lại. Thanks anh
E mới edit lại. Thanks anh -
Ngô Trung Hưng @hungnt
changed this line in version 6 of the diff
changed this line in version 6 of the diff
changed this line in [version 6 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5092&start_sha=6031ca8727c57d53169397be1a54b176d0b49e7e#8f0267326248c40ab343ad885d03cfb7a7023a35_34_32)Toggle commit list
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- 980c93dc - fix hidden field
added 1 commit * 980c93dc - fix hidden field [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5092&start_sha=6031ca8727c57d53169397be1a54b176d0b49e7e)Toggle commit list -
Ngô Trung Hưng @hungnt
added 1 commit
- 2a8fd541 - ..
added 1 commit * 2a8fd541 - .. [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5093&start_sha=980c93dcca67d24a171f688e405fb4c068562574)Toggle commit list -
Ngô Trung Hưng @hungnt
added 1 commit
- e2034040 - fix bug applied_job
added 1 commit * e2034040 - fix bug applied_job [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5094&start_sha=2a8fd541a1817d98d2e724482b213a4d2c647423)Toggle commit list -
9 9 10 10 def my_page 11 11 end 12 13 def set_lang 14 if user_signed_in? 15 if params[:lang] == 'vi' || params[:lang] == 'en' 16 User.update(current_user.id, language: params[:lang]) -
Hoang Phuc Do @phucdh commentedMaster
Cập nhật bảng User mỗi lần access ở đây có cần thiết không ?
Trường hợp nếu
languagecủaUserđã làvihoặcenthì thao tác update ở đây không cần thiếtCập nhật bảng User mỗi lần access ở đây có cần thiết không ? Trường hợp nếu `language` của `User` đã là `vi` hoặc `en` thì thao tác update ở đây không cần thiết -
Ngô Trung Hưng @hungnt commentedMaster
dạ a, e update lại
dạ a, e update lại -
Ngô Trung Hưng @hungnt
changed this line in version 10 of the diff
changed this line in version 10 of the diff
changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5098&start_sha=ec82d0463642773131b71d2ca8577ab66e04e689#28f48e0bc2718ddf87752d15b58a0016c13baf1c_16_12)Toggle commit list
-
-
app/controllers/apply_job_controller.rb 0 → 100644
10 11 def apply 12 return redirect_to root_path if params[:job_id].blank? 13 @data_apply = current_user.applied_jobs.new(name: current_user.name, email: current_user.email) 14 session[:job_id] = params[:job_id] 15 @job = Job.find(params[:job_id]) 16 end 17 18 def confirm 19 @apply_job = current_user.applied_jobs.new(applied_job_params) 20 @apply_job.job_id = session[:job_id] 21 @apply_job.cv = current_user.cv if @apply_job.cv.blank? 22 session[:cache_name] = @apply_job.cv.cache_name 23 if @apply_job.invalid? 24 errors = [] 25 @apply_job.errors.full_messages.each { |mess| errors << "#{mess}<br>" } -
Hoang Phuc Do @phucdh commentedMaster
Việc xử lý render error nên thực hiện trong view, hoặc đưa vào Helper.
Ngoài ra, việc validate apply job phải thực hiện ở trang apply chứ ?
Việc xử lý render error nên thực hiện trong view, hoặc đưa vào Helper. Ngoài ra, việc validate apply job phải thực hiện ở trang apply chứ ? -
Ngô Trung Hưng @hungnt
changed this line in version 10 of the diff
changed this line in version 10 of the diff
changed this line in [version 10 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5098&start_sha=ec82d0463642773131b71d2ca8577ab66e04e689#8f0267326248c40ab343ad885d03cfb7a7023a35_25_24)Toggle commit list
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- ec82d046 - fix bug applied_job
added 1 commit * ec82d046 - fix bug applied_job [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5095&start_sha=e2034040bb9da8b20d562599410faf4bba993f53)Toggle commit list -
Ngô Trung Hưng @hungnt
added 1 commit
- 67ac663b - move render_errors to helper & update method set_lang
added 1 commit
- 67ac663b - move render_errors to helper & update method set_lang
added 1 commit * 67ac663b - move render_errors to helper & update method set_lang [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5098&start_sha=ec82d0463642773131b71d2ca8577ab66e04e689)Toggle commit list -
7 7 render :confirm 8 8 end 9 9 10 def my_page 10 def my_page; end 11 12 def set_lang 13 if user_signed_in? && current_user.language != params[:lang] 14 User.update(current_user.id, language: params[:lang]) if params[:lang] == 'vi' || params[:lang] == 'en' -
Hoang Phuc Do @phucdh commentedMasterEdited
Business logic đưa vào model, vd như sau:
# Controller current_user.update_current_language(params[:lang]) if user_signed_in? # Model VALID_LANG_CODES = %w[vi en] def update_current_language(new_lang) return if new_lang == language or VALID_LANG_CODES.exclude?(new_lang) self.language = new_lang save endBusiness logic đưa vào model, vd như sau: ```ruby # Controller current_user.update_current_language(params[:lang]) if user_signed_in? # Model VALID_LANG_CODES = %w[vi en] def update_current_language(new_lang) return if new_lang == language or VALID_LANG_CODES.exclude?(new_lang) self.language = new_lang save end ``` -
Ngô Trung Hưng @hungnt
changed this line in version 11 of the diff
changed this line in version 11 of the diff
changed this line in [version 11 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5099&start_sha=67ac663bc630ebc3796ad40a4a8d1de89f3ae1fc#28f48e0bc2718ddf87752d15b58a0016c13baf1c_14_13)Toggle commit list
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- 7f10504a - update func set language
added 1 commit * 7f10504a - update func set language [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5099&start_sha=67ac663bc630ebc3796ad40a4a8d1de89f3ae1fc)Toggle commit list -
3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <title>Thank you for applied with VenJOB</title> 7 </head> 8 <body> 9 <div class="container"> 10 <span style="font-size: 18px;"><b>Dear <%= @applied_job.name %></b></span> 11 <div style="font-size: 15px;"> 12 <p>Thank you for applied with VenJOB. Your applied job's information is as follow:</p> 13 <span>Job title: <%= @applied_job.job.name %></span><br> 14 <span>Location: <%= @applied_job.job.cities.map(&:name).join(' ') %></span><br> 15 <span>Company: <%= @applied_job.job.company.name %></span><br><br> 16 <span>Name: <%= @applied_job.name %></span><br> 17 <span>Email: <%= @applied_job.email %></span><br> 18 CV: <%= link_to @applied_job.cv.identifier, root_url(@applied_job.cv.url) , target: '_blank' %> -
Hoang Phuc Do @phucdh commentedMaster
link_to @applied_job```ruby link_to @applied_job ``` -
Ngô Trung Hưng @hungnt
changed this line in version 12 of the diff
changed this line in version 12 of the diff
changed this line in [version 12 of the diff](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5103&start_sha=7f10504a4ba6698a4757ff67c6fd08797800308d#8735ad400a8ad93dcea11ed16b7b9276a88d88bb_18_18)Toggle commit list
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- dc3976f3 - fix view _ribbon
added 1 commit * dc3976f3 - fix view _ribbon [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5103&start_sha=7f10504a4ba6698a4757ff67c6fd08797800308d)Toggle commit list -
39 39 document.getElementById ("label_name_file").innerHTML = this.files[0].name; 40 40 }); 41 41 42 // show & hide password 43 $(".icon_show_password").on('click',function() { 44 $(".input_password").attr('type', 'text'); 45 $(".icon_show_password").css('display', 'none') -
Hoang Phuc Do @phucdh commentedMaster
Chắc có thể sử dụng
.show()và.hide()của jQuery ở đâyChắc có thể sử dụng `.show()` và `.hide()` của jQuery ở đây -
Ngô Trung Hưng @hungnt commentedMaster
Dạ anh
Dạ anh
-
-
Ngô Trung Hưng @hungnt
added 1 commit
- 11225db1 - use show() & hide() in js
added 1 commit * 11225db1 - use show() & hide() in js [Compare with previous version](https://gitlab.zigexn.vn/hungnt/venjob_nth/merge_requests/10/diffs?diff_id=5105&start_sha=dc3976f3ba48a4935df26a8810f2427e04ca0353)Toggle commit list -
Hoang Phuc Do @phucdh
resolved all discussions
resolved all discussions
resolved all discussionsToggle commit list -
Hoang Phuc Do @phucdh
mentioned in commit dbcda2ab
mentioned in commit dbcda2ab
mentioned in commit dbcda2abbab0f036ace2c2cbe17cebcb1c87bea9Toggle commit list -
Hoang Phuc Do @phucdh
merged
merged
mergedToggle commit list