Class: RequestsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- RequestsController
- Defined in:
- app/controllers/requests_controller.rb
Instance Method Summary collapse
-
#approve ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity.
-
#index ⇒ Object
GET /requests.
- #show ⇒ Object
Methods inherited from ApplicationController
#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #render_not_found, #require_admin_user
Instance Method Details
#approve ⇒ Object
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/MethodLength rubocop:disable Metrics/PerceivedComplexity rubocop:disable Metrics/CyclomaticComplexity
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 64 65 66 67 |
# File 'app/controllers/requests_controller.rb', line 39 def approve if eligible_to_approve @request_model = Request.find(params[:id]) if @request_model.valid_to_submit? project = @request_model.approve(current_user) @request_model.destroy! = "The request has been approved and this project was created in the TigerData web portal. The request has been processed and deleted." TigerdataMailer.with(project_id: project.id, approver: current_user).project_creation.deliver_later redirect_to project_path(project.id), notice: else redirect_to new_project_review_and_submit_path(@request_model) end else = "You do not have access to this page." flash[:notice] = redirect_to dashboard_path end rescue StandardError => ex if ex.is_a?(Mediaflux::SessionExpired) || ex.cause.is_a?(Mediaflux::SessionExpired) raise elsif ex.is_a?(ProjectCreate::ProjectCreateError) && ex..include?("Session expired for token") raise Mediaflux::SessionExpired else Rails.logger.error "Error approving request #{params[:id]}. Details: #{ex.}" Honeybadger.notify "Error approving request #{params[:id]}. Details: #{ex.}" flash[:notice] = "Error approving request #{params[:id]}" redirect_to request_path(@request_model) end end |
#index ⇒ Object
GET /requests
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/requests_controller.rb', line 6 def index if current_user.eligible_sysadmin? ("Project Requests - All") @draft_requests = Request.where(state: Request::DRAFT).map do |request| request.project_title = "no title set" if request.project_title.blank? request end @submitted_requests = Request.where(state: Request::SUBMITTED) else = "You do not have access to this page." flash[:notice] = redirect_to dashboard_path end end |
#show ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/requests_controller.rb', line 21 def show if current_user.developer || current_user.sysadmin || current_user.trainer @request_model = Request.find(params[:id]) @request_presenter = RequestPresenter.new(@request_model) ("Requests", requests_path) (@request_model.project_title, request_path(@request_model)) render :show else = "You do not have access to this page." flash[:notice] = redirect_to dashboard_path end end |