Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
048a2197
Commit
048a2197
authored
Jul 30, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add create/update to Labels controller
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
81aebaa1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
2 deletions
+42
-2
app/controllers/projects/labels_controller.rb
app/controllers/projects/labels_controller.rb
+40
-1
app/models/ability.rb
app/models/ability.rb
+1
-0
config/routes.rb
config/routes.rb
+1
-1
No files found.
app/controllers/projects/labels_controller.rb
View file @
048a2197
class
Projects::LabelsController
<
Projects
::
ApplicationController
class
Projects::LabelsController
<
Projects
::
ApplicationController
before_filter
:module_enabled
before_filter
:module_enabled
before_filter
:label
,
only:
[
:edit
,
:update
]
before_filter
:authorize_labels!
before_filter
:authorize_labels!
before_filter
:authorize_admin_labels!
,
only:
[
:edit
,
:update
,
:new
,
:create
,
:destroy
]
respond_to
:js
,
:html
respond_to
:js
,
:html
...
@@ -9,6 +10,32 @@ class Projects::LabelsController < Projects::ApplicationController
...
@@ -9,6 +10,32 @@ class Projects::LabelsController < Projects::ApplicationController
@labels
=
@project
.
labels
@labels
=
@project
.
labels
end
end
def
new
@label
=
@project
.
labels
.
new
end
def
create
@label
=
@project
.
labels
.
create
(
label_params
)
if
@label
.
valid?
redirect_to
project_labels_path
(
@project
)
else
render
'new'
end
end
def
edit
end
def
update
if
@label
.
update_attributes
(
label_params
)
redirect_to
project_labels_path
(
@project
)
else
render
'edit'
end
end
def
generate
def
generate
Gitlab
::
IssuesLabels
.
generate
(
@project
)
Gitlab
::
IssuesLabels
.
generate
(
@project
)
...
@@ -28,4 +55,16 @@ class Projects::LabelsController < Projects::ApplicationController
...
@@ -28,4 +55,16 @@ class Projects::LabelsController < Projects::ApplicationController
return
render_404
return
render_404
end
end
end
end
def
label_params
params
.
require
(
:label
).
permit
(
:title
,
:color
)
end
def
label
@label
=
@project
.
labels
.
find
(
params
[
:id
])
end
def
authorize_admin_labels!
return
render_404
unless
can?
(
current_user
,
:admin_label
,
@project
)
end
end
end
app/models/ability.rb
View file @
048a2197
...
@@ -164,6 +164,7 @@ class Ability
...
@@ -164,6 +164,7 @@ class Ability
:modify_merge_request
,
:modify_merge_request
,
:admin_issue
,
:admin_issue
,
:admin_milestone
,
:admin_milestone
,
:admin_label
,
:admin_project_snippet
,
:admin_project_snippet
,
:admin_team_member
,
:admin_team_member
,
:admin_merge_request
,
:admin_merge_request
,
...
...
config/routes.rb
View file @
048a2197
...
@@ -297,7 +297,7 @@ Gitlab::Application.routes.draw do
...
@@ -297,7 +297,7 @@ Gitlab::Application.routes.draw do
end
end
end
end
resources
:labels
,
only:
[
:index
]
do
resources
:labels
,
constraints:
{
id:
/\d+/
}
do
collection
do
collection
do
post
:generate
post
:generate
end
end
...
...
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