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

Complaints can now be geted individually identified by the id code (show) and...

Complaints can now be geted individually identified by the id code (show) and only editors and administrators can see the complaints.
parent 49fc92ee
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,8 @@ class V1::ComplaintsController < ApplicationController ...@@ -21,7 +21,8 @@ class V1::ComplaintsController < ApplicationController
include ::DeletedObjectsController include ::DeletedObjectsController
include ::Paginator include ::Paginator
before_action :authenticate_user!, only: [:create] before_action :set_complaint, only:[:show]
before_action :authenticate_user!, only: [:index, :show, :create]
# GET v1/complaints # GET v1/complaints
# GET v1/complaints.json # GET v1/complaints.json
...@@ -30,6 +31,12 @@ class V1::ComplaintsController < ApplicationController ...@@ -30,6 +31,12 @@ class V1::ComplaintsController < ApplicationController
render json: complaints render json: complaints
end end
# GET /v1/coplaints/1
# GET /v1/coplaints/1.json
def show
render json: @complaint
end
# POST v1/complaints # POST v1/complaints
# POST v1/complaints.json # POST v1/complaints.json
def create def create
...@@ -53,4 +60,7 @@ class V1::ComplaintsController < ApplicationController ...@@ -53,4 +60,7 @@ class V1::ComplaintsController < ApplicationController
params.require(:complaint).permit(:user_id, :description,:complainable_id, :complaint_reason_id, :complainable_type) params.require(:complaint).permit(:user_id, :description,:complainable_id, :complaint_reason_id, :complainable_type)
end end
def set_complaint
@complaint = Complaint.find(params[:id])
end
end end
...@@ -22,4 +22,12 @@ class ComplaintPolicy < ApplicationPolicy ...@@ -22,4 +22,12 @@ class ComplaintPolicy < ApplicationPolicy
def create? def create?
record if user_exists? record if user_exists?
end end
def index?
record if user_can_edit?
end
def show?
record if user_can_edit?
end
end end
...@@ -184,7 +184,7 @@ Rails.application.routes.draw do ...@@ -184,7 +184,7 @@ Rails.application.routes.draw do
end end
end end
resources :complaints, only: [:index, :create], concerns: :deletable resources :complaints, only: [:index, :show, :create], concerns: :deletable
resources :languages, except: [:new, :edit] resources :languages, except: [:new, :edit]
resources :licenses, except: [:new, :edit] resources :licenses, except: [:new, :edit]
resources :mime_types, except: [:new, :edit] resources :mime_types, except: [:new, :edit]
......
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