Unverified Commit 048a2197 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Add create/update to Labels controller


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ca19cc0e9fa9
class Projects::LabelsController < Projects::ApplicationController
before_filter :module_enabled
before_filter :label, only: [:edit, :update]
before_filter :authorize_labels!
before_filter :authorize_admin_labels!, only: [:edit, :update, :new, :create, :destroy]
respond_to :js, :html
......@@ -9,6 +10,32 @@ def index
@labels = @project.labels
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
Gitlab::IssuesLabels.generate(@project)
......@@ -28,4 +55,16 @@ def module_enabled
return render_404
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
......@@ -164,6 +164,7 @@ def project_master_rules
:modify_merge_request,
:admin_issue,
:admin_milestone,
:admin_label,
:admin_project_snippet,
:admin_team_member,
:admin_merge_request,
......
......@@ -297,7 +297,7 @@
end
end
resources :labels, only: [:index] do
resources :labels, constraints: {id: /\d+/} do
collection do
post :generate
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment