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/MethodLength rubocop:disable Metrics/AbcSize.
-
#index ⇒ Object
GET /requests.
- #show ⇒ Object
Methods inherited from ApplicationController
#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #require_admin_user
Instance Method Details
#approve ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/requests_controller.rb', line 37 def approve if current_user.superuser || current_user.sysadmin || current_user.trainer @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." 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 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 |
#index ⇒ Object
GET /requests
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/requests_controller.rb', line 6 def index return head :forbidden unless Flipflop.new_project_request_wizard? 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 33 |
# File 'app/controllers/requests_controller.rb', line 22 def show if current_user.superuser || current_user.sysadmin || current_user.trainer @request_model = Request.find(params[:id]) ("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 |