Class: PlanMyStuff::Issues::TakesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PlanMyStuff::Issues::TakesController
- Defined in:
- app/controllers/plan_my_stuff/issues/takes_controller.rb
Overview
Moves an issue’s pipeline ProjectItem to “Started” via PlanMyStuff::Pipeline.take!. Backs the “Take” button on the mounted issue show view (T-RC-017). The primary UI path for a dev picking up work on an issue they’ve been assigned to.
Instance Method Summary collapse
-
#create ⇒ Object
POST /issues/:issue_id/take.
-
#destroy ⇒ Object
DELETE /issues/:issue_id/take.
Instance Method Details
#create ⇒ Object
POST /issues/:issue_id/take
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/plan_my_stuff/issues/takes_controller.rb', line 13 def create issue_number = params[:issue_id].to_i repo = params[:repo] issue = PlanMyStuff::Issue.find(issue_number, repo: repo) guard_already_taken!(issue) project_item = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue_number) project_item ||= add_to_pipeline(issue) PlanMyStuff::Pipeline.take!(project_item) assign_current_user(project_item) flash[:success] ||= "Issue ##{issue_number} taken." redirect_to(plan_my_stuff.issue_path(issue_number, repo: repo)) rescue ArgumentError, PlanMyStuff::Error => e pms_handle_rescue(e) flash[:error] = e. redirect_to(plan_my_stuff.issue_path(issue_number, repo: repo)) end |
#destroy ⇒ Object
DELETE /issues/:issue_id/take
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/plan_my_stuff/issues/takes_controller.rb', line 35 def destroy issue_number = params[:issue_id].to_i repo = params[:repo] issue = PlanMyStuff::Issue.find(issue_number, repo: repo) login = current_user_login guard_release!(issue, login) remaining = issue.assignees - [login] project_item = PlanMyStuff::Pipeline::IssueLinker.find_project_item(issue_number) if project_item.present? if remaining.empty? issue.update!(assignees: []) project_item.destroy! else project_item.assign!(remaining) end else issue.update!(assignees: remaining) end flash[:success] = "Issue ##{issue_number} released." redirect_to(plan_my_stuff.issue_path(issue_number, repo: repo)) rescue ArgumentError, PlanMyStuff::Error => e pms_handle_rescue(e) flash[:error] = e. redirect_to(plan_my_stuff.issue_path(issue_number, repo: repo)) end |