Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
9e30ed42
Commit
9e30ed42
authored
7 years ago
by
Clarissa
Browse files
Options
Downloads
Patches
Plain Diff
SCRUM#275: adding attachments index, to get easier to check
parent
6934ae8f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/v1/learning_objects/attachment_controller.rb
+12
-3
12 additions, 3 deletions
app/controllers/v1/learning_objects/attachment_controller.rb
config/routes.rb
+1
-1
1 addition, 1 deletion
config/routes.rb
with
13 additions
and
4 deletions
app/controllers/v1/learning_objects/attachment_controller.rb
+
12
−
3
View file @
9e30ed42
...
...
@@ -19,10 +19,15 @@
class
V1::LearningObjects::AttachmentController
<
ApplicationController
before_action
:set_objects
before_action
:authenticate_user!
,
only: :update
before_action
:authenticate_user!
,
only:
[
:update
,
:index
]
before_action
:authorize!
,
only: :destroy
before_action
:authorize_update_attachment!
,
only: :update
# GET /learning_objects/:learning_object_id/attachment
def
index
render
json:
@attachment
end
# DELETE /learning_objects/:learning_object_id/attachments/:id
def
destroy
return
render
status: :not_found
if
@learning_object
.
nil?
||
@attachment
.
nil?
...
...
@@ -32,7 +37,7 @@ class V1::LearningObjects::AttachmentController < ApplicationController
render
status: :ok
end
# PUT /learning_objects/:learning_object_id/attachments/:id
def
update
return
render
status: :not_found
if
@learning_object
.
nil?
||
@attachment
.
nil?
...
...
@@ -55,7 +60,11 @@ class V1::LearningObjects::AttachmentController < ApplicationController
def
set_objects
@learning_object
=
LearningObject
.
find
(
attachment_params
[
:learning_object_id
])
@attachment
=
LearningObject
::
Attachment
.
find
(
attachment_params
[
:id
])
if
(
attachment_params
[
:id
].
blank?
)
@attachment
=
@learning_object
.
attachment
else
@attachment
=
LearningObject
::
Attachment
.
find
(
attachment_params
[
:id
])
end
end
def
authorize!
...
...
This diff is collapsed.
Click to expand it.
config/routes.rb
+
1
−
1
View file @
9e30ed42
...
...
@@ -168,7 +168,7 @@ Rails.application.routes.draw do
collection
do
get
'validate'
end
resources
:attachment
,
module:
'learning_objects'
,
only:
[
:destroy
,
:update
],
on: :member
resources
:attachment
,
module:
'learning_objects'
,
only:
[
:destroy
,
:update
,
:index
],
on: :member
end
resources
:institutions
,
concerns: :deletable
do
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment