Class: RequestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/requests_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#add_breadcrumb, #after_sign_in_path_for, #breadcrumbs, #new_session_path, #require_admin_user

Instance Method Details

#approveObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/requests_controller.rb', line 35

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
      stub_message = "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: stub_message
    else
      redirect_to new_project_review_and_submit_path(@request_model)
    end
  else
    error_message = "You do not have access to this page."
    flash[:notice] = error_message
    redirect_to dashboard_path
  end
end

#indexObject

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?
    add_breadcrumb("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
    error_message = "You do not have access to this page."
    flash[:notice] = error_message
    redirect_to dashboard_path
  end
end

#showObject



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])
    add_breadcrumb("Requests", requests_path)
    add_breadcrumb(@request_model.project_title, request_path(@request_model))
    render :show
  else
    error_message = "You do not have access to this page."
    flash[:notice] = error_message
    redirect_to dashboard_path
  end
end