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.
-
#destroy ⇒ Object
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize rubocop:enable Metrics/PerceivedComplexity rubocop:enable 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
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 64 65 |
# File 'app/controllers/requests_controller.rb', line 38 def approve if eligible_to_approve if @request_model.valid_to_submit?(allow_empty_parent_folder: true) 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 |
#destroy ⇒ Object
rubocop:enable Metrics/MethodLength rubocop:enable Metrics/AbcSize rubocop:enable Metrics/PerceivedComplexity rubocop:enable Metrics/CyclomaticComplexity
71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/requests_controller.rb', line 71 def destroy if eligible_to_destroy? @request_model.destroy redirect_to dashboard_path(modal: "confirm_delete_draft") else flash[:notice] = I18n.t(:no_permission_to_delete) redirect_to dashboard_path end end |
#index ⇒ Object
GET /requests
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/requests_controller.rb', line 7 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
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/requests_controller.rb', line 22 def show if current_user.uid == @request_model.requested_by || current_user.developer || current_user.sysadmin || current_user.trainer @request_presenter = RequestPresenter.new(@request_model) ("New Project Request", new_project_project_info_path) render :show else = "You do not have access to this page." flash[:notice] = redirect_to dashboard_path end end |