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
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
80f4a7cb
Commit
80f4a7cb
authored
7 years ago
by
Marcela Ribeiro de Oliveira
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec
parents
48aab44c
66d32638
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/v1/languages_controller.rb
+7
-0
7 additions, 0 deletions
app/controllers/v1/languages_controller.rb
app/controllers/v1/scores_controller.rb
+7
-2
7 additions, 2 deletions
app/controllers/v1/scores_controller.rb
app/policies/score_policy.rb
+40
-0
40 additions, 0 deletions
app/policies/score_policy.rb
with
54 additions
and
2 deletions
app/controllers/v1/languages_controller.rb
+
7
−
0
View file @
80f4a7cb
...
...
@@ -22,6 +22,7 @@ class V1::LanguagesController < ApplicationController
before_action
:authenticate_user!
,
except:
[
:index
,
:show
]
before_action
:set_language
,
only:
[
:show
,
:update
,
:destroy
]
before_action
:authorize!
,
only:
[
:update
,
:destroy
]
# GET /languages
# GET /languages.json
...
...
@@ -40,6 +41,7 @@ class V1::LanguagesController < ApplicationController
# POST /languages.json
def
create
@language
=
Language
.
new
(
language_params
)
authorize
@language
if
@language
.
save
render
json:
@language
,
status: :created
...
...
@@ -77,4 +79,9 @@ class V1::LanguagesController < ApplicationController
def
language_params
params
.
require
(
:language
).
permit
(
:name
,
:code
)
end
def
authorize!
authorize
@language
end
end
This diff is collapsed.
Click to expand it.
app/controllers/v1/scores_controller.rb
+
7
−
2
View file @
80f4a7cb
...
...
@@ -20,8 +20,9 @@
class
V1::ScoresController
<
ApplicationController
include
::
Paginator
before_action
:set_score
,
only:
[
:show
,
:update
]
before_action
:authenticate_user!
,
only:
[
:update
]
before_action
:set_score
,
only:
[
:show
,
:update
]
before_action
:authorize!
,
only:
[
:update
]
# GET v1/scores
# GET v1/scores.json
...
...
@@ -41,7 +42,7 @@ class V1::ScoresController < ApplicationController
# PUT/PATCH /v1/scores/1.json
def
update
if
@score
.
update
(
score_params
)
render
json:
@score
,
status: :ok
render
json:
@score
,
status: :ok
,
:notice
=>
"Score updated."
else
render
json:
@score
.
errors
,
status: :unprocessable_entity
end
...
...
@@ -57,4 +58,8 @@ class V1::ScoresController < ApplicationController
params
.
require
(
:score
).
permit
(
:name
,
:weight
,
:active
,
score_type:
[])
end
def
authorize!
authorize
@score
end
end
This diff is collapsed.
Click to expand it.
app/policies/score_policy.rb
0 → 100644
+
40
−
0
View file @
80f4a7cb
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class
ScorePolicy
<
ApplicationPolicy
def
index?
record
end
def
show?
record
end
def
create?
record
if
user
.
is_admin?
end
def
update?
record
if
user
.
is_admin?
end
def
destroy?
record
if
user
.
is_admin?
end
end
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