diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 14:12:11 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-07-30 14:12:11 +0400 |
commit | 048a21974ef56285099eb4b54b6ca1e6fd7e3e8c (patch) | |
tree | 128dcb441241a59c8aa0206e2f5510a7ae2c9fc4 /app/controllers | |
parent | 81aebaa189586d4384fff92324fc9ec5bd8d8962 (diff) |
Add create/update to Labels controller
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/labels_controller.rb | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index d2c5e90b257..4d0723a26df 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -1,7 +1,8 @@ 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 @@ class Projects::LabelsController < Projects::ApplicationController @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 @@ class Projects::LabelsController < Projects::ApplicationController 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 |