BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f108153c
Commit
f108153c
authored
Jul 07, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove update|admin_pipeline_schedule from Project, and grant it in PipelineSchedule
parent
1ee9f7db
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
22 deletions
+16
-22
pipeline_schedules_controller.rb
app/controllers/projects/pipeline_schedules_controller.rb
+4
-0
pipeline_schedule_policy.rb
app/policies/ci/pipeline_schedule_policy.rb
+5
-16
project_policy.rb
app/policies/project_policy.rb
+0
-2
_pipeline_schedule.html.haml
.../projects/pipeline_schedules/_pipeline_schedule.html.haml
+1
-1
pipeline_schedules.rb
lib/api/pipeline_schedules.rb
+6
-3
No files found.
app/controllers/projects/pipeline_schedules_controller.rb
View file @
f108153c
...
...
@@ -73,4 +73,8 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
def
authorize_update_pipeline_schedule!
return
access_denied!
unless
can?
(
current_user
,
:update_pipeline_schedule
,
schedule
)
end
def
authorize_admin_pipeline_schedule!
return
access_denied!
unless
can?
(
current_user
,
:admin_pipeline_schedule
,
schedule
)
end
end
app/policies/ci/pipeline_schedule_policy.rb
View file @
f108153c
...
...
@@ -2,24 +2,13 @@ module Ci
class
PipelineSchedulePolicy
<
PipelinePolicy
alias_method
:pipeline_schedule
,
:subject
condition
(
:
protected_action
)
do
owned_by_developer?
&&
owned_by_another?
condition
(
:
owner_of_schedule
)
do
can?
(
:developer_access
)
&&
pipeline_schedule
.
owned_by?
(
@user
)
end
rule
{
protected_action
}.
prevent
:update_pipeline_schedule
private
def
owned_by_developer?
return
false
unless
@user
pipeline_schedule
.
project
.
team
.
developer?
(
@user
)
end
def
owned_by_another?
return
false
unless
@user
!
pipeline_schedule
.
owned_by?
(
@user
)
rule
{
can?
(
:master_access
)
|
owner_of_schedule
}.
policy
do
enable
:update_pipeline_schedule
enable
:admin_pipeline_schedule
end
end
end
app/policies/project_policy.rb
View file @
f108153c
...
...
@@ -162,7 +162,6 @@ class ProjectPolicy < BasePolicy
enable
:create_pipeline
enable
:update_pipeline
enable
:create_pipeline_schedule
enable
:update_pipeline_schedule
enable
:create_merge_request
enable
:create_wiki
enable
:push_code
...
...
@@ -188,7 +187,6 @@ class ProjectPolicy < BasePolicy
enable
:admin_build
enable
:admin_container_image
enable
:admin_pipeline
enable
:admin_pipeline_schedule
enable
:admin_environment
enable
:admin_deployment
enable
:admin_pages
...
...
app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml
View file @
f108153c
...
...
@@ -26,7 +26,7 @@
=
pipeline_schedule
.
owner
&
.
name
%td
.pull-right.btn-group
-
if
can?
(
current_user
,
:update_pipeline_schedule
,
@project
)
&&
!
pipeline_schedule
.
owned_by?
(
current_user
)
-
if
can?
(
current_user
,
:update_pipeline_schedule
,
pipeline_schedule
)
=
link_to
take_ownership_pipeline_schedule_path
(
pipeline_schedule
),
method: :post
,
title:
s_
(
'PipelineSchedules|Take ownership'
),
class:
'btn'
do
=
s_
(
'PipelineSchedules|Take ownership'
)
-
if
can?
(
current_user
,
:update_pipeline_schedule
,
pipeline_schedule
)
...
...
lib/api/pipeline_schedules.rb
View file @
f108153c
...
...
@@ -74,9 +74,10 @@ module API
optional
:active
,
type:
Boolean
,
desc:
'The activation of pipeline schedule'
end
put
':id/pipeline_schedules/:pipeline_schedule_id'
do
authorize!
:
update
_pipeline_schedule
,
user_project
authorize!
:
read
_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
update
(
declared_params
(
include_missing:
false
))
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
...
...
@@ -92,9 +93,10 @@ module API
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
end
post
':id/pipeline_schedules/:pipeline_schedule_id/take_ownership'
do
authorize!
:
update
_pipeline_schedule
,
user_project
authorize!
:
read
_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:update_pipeline_schedule
,
pipeline_schedule
if
pipeline_schedule
.
own!
(
current_user
)
present
pipeline_schedule
,
with:
Entities
::
PipelineScheduleDetails
...
...
@@ -110,9 +112,10 @@ module API
requires
:pipeline_schedule_id
,
type:
Integer
,
desc:
'The pipeline schedule id'
end
delete
':id/pipeline_schedules/:pipeline_schedule_id'
do
authorize!
:
admin
_pipeline_schedule
,
user_project
authorize!
:
read
_pipeline_schedule
,
user_project
not_found!
(
'PipelineSchedule'
)
unless
pipeline_schedule
authorize!
:admin_pipeline_schedule
,
pipeline_schedule
status
:accepted
present
pipeline_schedule
.
destroy
,
with:
Entities
::
PipelineScheduleDetails
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment