labels_controller.rb 677 Bytes
Newer Older
1
class Projects::LabelsController < Projects::ApplicationController
randx's avatar
randx committed
2 3
  before_filter :module_enabled

4
  before_filter :authorize_labels!
randx's avatar
randx committed
5 6 7 8

  respond_to :js, :html

  def index
9
    @labels = @project.labels
randx's avatar
randx committed
10 11
  end

12
  def generate
13
    Gitlab::IssuesLabels.generate(@project)
14

15 16 17 18
    if params[:redirect] == 'issues'
      redirect_to project_issues_path(@project)
    elsif params[:redirect] == 'merge_requests'
      redirect_to project_merge_requests_path(@project)
19 20
    else
      redirect_to project_labels_path(@project)
21
    end
22 23
  end

randx's avatar
randx committed
24 25 26
  protected

  def module_enabled
27 28 29
    unless @project.issues_enabled || @project.merge_requests_enabled
      return render_404
    end
randx's avatar
randx committed
30 31
  end
end