issue_statuses_controller.rb 1.92 KB
Newer Older
1
#-- encoding: UTF-8
2 3
#-- copyright
# ChiliProject is a project management system.
4
#
Holger Just's avatar
Holger Just committed
5
# Copyright (C) 2010-2013 the ChiliProject Team
6
#
7 8 9 10
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
11
#
12 13 14
# See doc/COPYRIGHT.rdoc for more details.
#++

15
class IssueStatusesController < ApplicationController
16
  layout 'admin'
17

18 19
  before_filter :require_admin

20
  verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
21
         :redirect_to => { :action => :index }
22

Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
23
  def index
24
    @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
25
    render :action => "index", :layout => false if request.xhr?
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
26 27 28 29 30 31 32 33 34
  end

  def new
    @issue_status = IssueStatus.new
  end

  def create
    @issue_status = IssueStatus.new(params[:issue_status])
    if @issue_status.save
35
      flash[:notice] = l(:notice_successful_create)
36
      redirect_to :action => 'index'
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
37 38 39 40 41 42 43 44 45 46 47 48
    else
      render :action => 'new'
    end
  end

  def edit
    @issue_status = IssueStatus.find(params[:id])
  end

  def update
    @issue_status = IssueStatus.find(params[:id])
    if @issue_status.update_attributes(params[:issue_status])
49
      flash[:notice] = l(:notice_successful_update)
50
      redirect_to :action => 'index'
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
51 52 53
    else
      render :action => 'edit'
    end
54
  end
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
55 56 57

  def destroy
    IssueStatus.find(params[:id]).destroy
58
    redirect_to :action => 'index'
59
  rescue
60
    flash[:error] = l(:error_unable_delete_issue_status)
61
    redirect_to :action => 'index'
62 63
  end

64 65 66 67 68 69
  def update_issue_done_ratio
    if IssueStatus.update_issue_done_ratios
      flash[:notice] = l(:notice_issue_done_ratios_updated)
    else
      flash[:error] =  l(:error_issue_done_ratios_not_updated)
    end
70
    redirect_to :action => 'index'
71
  end
Jean-Philippe Lang's avatar
Jean-Philippe Lang committed
72
end