Class: Mygengo::JobsController
- Inherits:
-
MygengoController
- Object
- MygengoController
- Mygengo::JobsController
- Defined in:
- lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb
Constant Summary collapse
- URL_REGEXP =
/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
Instance Method Summary collapse
- #approve ⇒ Object
-
#create ⇒ Object
POST /jobs POST /jobs.xml.
-
#destroy ⇒ Object
DELETE /jobs/1 DELETE /jobs/1.xml.
-
#edit ⇒ Object
GET /jobs/1/edit.
-
#index ⇒ Object
GET /jobs GET /jobs.xml.
-
#new ⇒ Object
GET /jobs/new GET /jobs/new.xml.
- #purchase ⇒ Object
- #reject ⇒ Object
- #reject_form ⇒ Object
- #review_form ⇒ Object
- #revise ⇒ Object
- #revise_form ⇒ Object
-
#revision ⇒ Object
GET /jobs/1 GET /jobs/1.xml.
-
#show ⇒ Object
GET /jobs/1 GET /jobs/1.xml.
-
#update ⇒ Object
PUT /jobs/1 PUT /jobs/1.xml.
Instance Method Details
#approve ⇒ Object
119 120 121 122 123 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 119 def approve @job = Mugen::Job.approve(params[:id]) redirect_to mygengo_jobs_path end |
#create ⇒ Object
POST /jobs POST /jobs.xml
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 94 def create params[:job]['body_src'] = sanitize(params[:job]['body_src']) if params[:job]['callback_url'].empty? || !params[:job]['callback_url'].match(URL_REGEXP) params[:job].delete('callback_url') end flag = Mugen::Job.create(params[:job]) redirect_to mygengo_jobs_path end |
#destroy ⇒ Object
DELETE /jobs/1 DELETE /jobs/1.xml
139 140 141 142 143 144 145 146 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 139 def destroy @job = Mugen::Job.delete(params[:id]) respond_to do |format| format.html { redirect_to(mygengo_jobs_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /jobs/1/edit
88 89 90 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 88 def edit @job = Mugen::Job.find(params[:id]) end |
#index ⇒ Object
GET /jobs GET /jobs.xml
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 6 def index @job_ids = Mugen::Jobs.all if @job_ids @jobs = @job_ids.collect {|j| Mugen::Job.find(j['job_id']).merge('comments' => Mugen::Job.comments(j['job_id'])) } respond_to do |format| format.html # index.html.erb format.xml { render :xml => @jobs } end else redirect_to mygengo_account_index_path end end |
#new ⇒ Object
GET /jobs/new GET /jobs/new.xml
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 74 def new @job = Mugen::Job @languages = Mugen::Service.languages @language_pairs = Mugen::Service.language_pairs @language_src = @languages.collect { |lp| [ lp["language"], lp['lc'] ] }.uniq.sort @language_tgt = @languages.collect { |lp| [ lp["language"], lp['lc'] ] }.uniq.sort respond_to do |format| format.html # new.html.erb format.xml { render :xml => @job } end end |
#purchase ⇒ Object
113 114 115 116 117 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 113 def purchase @job = Mugen::Job.purchase(params[:id]) redirect_to mygengo_jobs_path end |
#reject ⇒ Object
131 132 133 134 135 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 131 def reject @job = Mugen::Job.reject(params[:id], params[:job]) redirect_to mygengo_jobs_path end |
#reject_form ⇒ Object
46 47 48 49 50 51 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 46 def reject_form @job = Mugen::Job.find(params[:id]) @preview = Mugen::Job.preview(@job['job_id']) @comments = Mugen::Job.comments(@job['job_id']) @job.merge!('comments' => @comments) end |
#review_form ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 38 def review_form @job = Mugen::Job.find(params[:id]) @preview = Mugen::Job.preview(@job['job_id']) @comments = Mugen::Job.comments(@job['job_id']) @job.merge!('comments' => @comments) @feedback = Mugen::Job.feedback(@job['job_id']) end |
#revise ⇒ Object
125 126 127 128 129 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 125 def revise @job = Mugen::Job.revise(params[:id], params[:job]) redirect_to mygengo_jobs_path end |
#revise_form ⇒ Object
53 54 55 56 57 58 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 53 def revise_form @job = Mugen::Job.find(params[:id]) @preview = Mugen::Job.preview(@job['job_id']) @comments = Mugen::Job.comments(@job['job_id']) @job.merge!('comments' => @comments) end |
#revision ⇒ Object
GET /jobs/1 GET /jobs/1.xml
62 63 64 65 66 67 68 69 70 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 62 def revision @job = Mugen::Job.find(params[:job_id]) @revision = Mugen::Job.revision(params[:job_id], params[:id]) respond_to do |format| format.html {} format.xml { render :xml => @job } end end |
#show ⇒ Object
GET /jobs/1 GET /jobs/1.xml
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/mugen/templates/app/controllers/mygengo/jobs_controller.rb', line 23 def show @job = Mugen::Job.find(params[:id]) @preview = Mugen::Job.preview(@job['job_id']) @comments = Mugen::Job.comments(@job['job_id']) @job.merge!('comments' => @comments) @feedback = Mugen::Job.feedback(@job['job_id']) @revisions = Mugen::Job.revisions(@job['job_id']) @revisions = [@revisions] if @revisions.is_a?(Hash) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @job } end end |