Class: PlanMyStuff::TestingProjectsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PlanMyStuff::TestingProjectsController
- Defined in:
- app/controllers/plan_my_stuff/testing_projects_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /testing_projects.
-
#edit ⇒ Object
GET /testing_projects/:id/edit.
-
#new ⇒ Object
GET /testing_projects/new.
-
#show ⇒ Object
GET /testing_projects/:id.
-
#update ⇒ Object
PATCH/PUT /testing_projects/:id.
Instance Method Details
#create ⇒ Object
POST /testing_projects
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/plan_my_stuff/testing_projects_controller.rb', line 12 def create @project = PMS::TestingProject.create!( title: testing_project_params[:title], description: testing_project_params[:description], subject_urls: parse_subject_urls(testing_project_params[:subject_urls]), due_date: parse_due_date(testing_project_params[:due_date]), deadline_miss_reason: testing_project_params[:deadline_miss_reason], user: pms_current_user, ) flash[:success] = 'Testing project was successfully created.' redirect_to(plan_my_stuff.testing_project_path(@project.number)) rescue PMS::ValidationError => e @project = PMS::TestingProject.new(title: testing_project_params[:title]) flash.now[:error] = e. render(:new, status: PMS.unprocessable_status) end |
#edit ⇒ Object
GET /testing_projects/:id/edit
39 40 41 |
# File 'app/controllers/plan_my_stuff/testing_projects_controller.rb', line 39 def edit @project = PMS::TestingProject.find(params[:id].to_i) end |
#new ⇒ Object
GET /testing_projects/new
6 7 8 9 |
# File 'app/controllers/plan_my_stuff/testing_projects_controller.rb', line 6 def new @project = PMS::TestingProject.new @project..subject_urls = [params[:subject_url]] if params[:subject_url].present? end |
#show ⇒ Object
GET /testing_projects/:id
31 32 33 34 35 36 |
# File 'app/controllers/plan_my_stuff/testing_projects_controller.rb', line 31 def show @project = PMS::TestingProject.find(params[:id].to_i) @statuses = @project.statuses.pluck(:name) @items_by_status = @project.items.group_by(&:status) @support_user = support_user? end |
#update ⇒ Object
PATCH/PUT /testing_projects/:id
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/controllers/plan_my_stuff/testing_projects_controller.rb', line 44 def update @project = PMS::TestingProject.find(params[:id].to_i) @project.update!( title: testing_project_params[:title], description: testing_project_params[:description], metadata: { subject_urls: parse_subject_urls(testing_project_params[:subject_urls]), due_date: parse_due_date(testing_project_params[:due_date]), deadline_miss_reason: testing_project_params[:deadline_miss_reason], }, ) flash[:success] = 'Testing project was successfully updated.' redirect_to(plan_my_stuff.testing_project_path(@project.number)) rescue PMS::StaleObjectError flash.now[:error] = 'Testing project was modified by someone else. Please review the latest changes and try again.' render(:edit, status: PMS.unprocessable_status) rescue PMS::ValidationError => e flash.now[:error] = e. render(:edit, status: PMS.unprocessable_status) end |