Skip to content
Snippets Groups Projects
Commit f7f8b9d0 authored by Douglas A. C's avatar Douglas A. C
Browse files

Rendering "complaint_reason" alongside "complaint" when the latter is requested.

parent 816e2001
No related branches found
No related tags found
No related merge requests found
......@@ -34,22 +34,22 @@ class V1::ComplaintsController < ApplicationController
# GET /v1/coplaints/1
# GET /v1/coplaints/1.json
def show
render json: @complaint
render :json => @complaint, :include => {:complaint_reason => {:except => [:updated_at, :created_at]}}
end
# POST v1/complaints
# POST v1/complaints.json
def create
@complaint = Complaint.new(complaint_params)
cp_params = complaint_params
@lo = LearningObject.find(cp_params[:complainable_id])
params = complaint_params
@complaint = Complaint.new(params)
@lo = LearningObject.find(params[:complainable_id])
if @complaint.save
ComplaintsMailer.new_complaint_received(@complaint, @current_user).deliver_now
#Uncomment the line below if an arbitrary number of complaints are necessary to suspend a LO.
# if (Complaint.where(complainable_id: cp_params[:complainable_id]).count >= 5)
# if (Complaint.where(complainable_id: params[:complainable_id]).count >= 5)
@lo.suspended!
render json: @complaint, status: :created
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment