Patch #8451 ยป redmine-1.1.2-rest-usability-enhancement.patch
| ./app/controllers/enumerations_controller.rb 2011-05-27 09:15:09.600031476 +0200 | ||
|---|---|---|
|
class EnumerationsController < ApplicationController
|
||
|
layout 'admin'
|
||
|
|
||
|
before_filter :require_admin
|
||
|
before_filter :require_admin, :except => [:index, :show]
|
||
|
before_filter :find_enumerations, :only => [:show]
|
||
|
helper :custom_fields
|
||
|
include CustomFieldsHelper
|
||
|
|
||
|
def index
|
||
|
list
|
||
|
render :action => 'list'
|
||
|
@enumerations_pages, @enumerations = paginate :enumerations, :per_page => 10, :order => 'position'
|
||
|
render :action => 'list' if request.xhr?
|
||
|
respond_to do |format|
|
||
|
format.html if User.current.admin?
|
||
|
format.html { render_403 } unless User.current.admin?
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
||
| ... | ... | |
|
def list
|
||
|
end
|
||
|
def show
|
||
|
respond_to do |format|
|
||
|
format.html { render_404 }
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
def new
|
||
|
begin
|
||
|
@enumeration = params[:type].constantize.new
|
||
| ... | ... | |
|
# flash[:error] = 'Unable to delete enumeration'
|
||
|
# redirect_to :action => 'index'
|
||
|
end
|
||
|
private
|
||
|
def find_enumerations
|
||
|
begin
|
||
|
@enumeration = Enumeration.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
@enumeration = Enumeration.find_by_name(params[:id])
|
||
|
if @enumeration.nil?
|
||
|
render_404
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/controllers/issue_categories_controller.rb 2011-05-27 09:15:12.160055868 +0200 | ||
|---|---|---|
|
class IssueCategoriesController < ApplicationController
|
||
|
menu_item :settings
|
||
|
model_object IssueCategory
|
||
|
before_filter :find_model_object, :except => :new
|
||
|
before_filter :find_project_from_association, :except => :new
|
||
|
before_filter :find_issue_categories, :only => :show
|
||
|
before_filter :find_model_object, :except => [:new, :index]
|
||
|
before_filter :find_project_from_association, :except => [:new, :index]
|
||
|
before_filter :find_project, :only => :new
|
||
|
before_filter :authorize
|
||
|
before_filter :authorize, :except => [:index, :show]
|
||
|
|
||
|
verify :method => :post, :only => :destroy
|
||
|
def index
|
||
|
@issue_categories_pages, @issue_categories = paginate :issue_categories, :per_page => 25, :order => "name"
|
||
|
render :action => "index", :layout => false if request.xhr?
|
||
|
respond_to do |format|
|
||
|
format.html if User.current.admin?
|
||
|
format.html { render_403 } unless User.current.admin?
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def new
|
||
|
@category = @project.issue_categories.build(params[:category])
|
||
|
if request.post?
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
end
|
||
|
def show
|
||
|
respond_to do |format|
|
||
|
format.html { render_404 }
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def edit
|
||
|
if request.post? and @category.update_attributes(params[:category])
|
||
| ... | ... | |
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
def find_issue_categories
|
||
|
begin
|
||
|
@issue_categories = IssueCategories.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
@issue_categories = IssueCategories.find_by_name(params[:id])
|
||
|
if @status.nil?
|
||
|
render_404
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/controllers/issue_statuses_controller.rb 2011-05-27 09:15:12.948062250 +0200 | ||
|---|---|---|
|
class IssueStatusesController < ApplicationController
|
||
|
layout 'admin'
|
||
|
|
||
|
before_filter :require_admin
|
||
|
before_filter :require_admin, :except => [:index, :show]
|
||
|
before_filter :find_status, :only => [:show]
|
||
|
verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
|
||
|
:redirect_to => { :action => :index }
|
||
| ... | ... | |
|
def index
|
||
|
@issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
|
||
|
render :action => "index", :layout => false if request.xhr?
|
||
|
respond_to do |format|
|
||
|
format.html if User.current.admin?
|
||
|
format.html { render_403 } unless User.current.admin?
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
def new
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def show
|
||
|
respond_to do |format|
|
||
|
format.html { render_404 }
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
def edit
|
||
|
@issue_status = IssueStatus.find(params[:id])
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
redirect_to :action => 'index'
|
||
|
end
|
||
|
private
|
||
|
def find_status
|
||
|
begin
|
||
|
@status = IssueStatus.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
@status = IssueStatus.find_by_name(params[:id])
|
||
|
if @status.nil?
|
||
|
render_404
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/controllers/trackers_controller.rb 2011-05-27 09:15:08.760030676 +0200 | ||
|---|---|---|
|
class TrackersController < ApplicationController
|
||
|
layout 'admin'
|
||
|
|
||
|
before_filter :require_admin
|
||
|
before_filter :require_admin, :except => [:index, :show]
|
||
|
before_filter :find_trackers, :only => [:show]
|
||
|
verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
|
||
|
def index
|
||
|
@tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position'
|
||
|
render :action => "index", :layout => false if request.xhr?
|
||
|
respond_to do |format|
|
||
|
format.html if User.current.admin?
|
||
|
format.html { render_403 } unless User.current.admin?
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
def new
|
||
| ... | ... | |
|
@projects = Project.find(:all)
|
||
|
end
|
||
|
def show
|
||
|
respond_to do |format|
|
||
|
format.html { render_404 }
|
||
|
format.api
|
||
|
end
|
||
|
end
|
||
|
def edit
|
||
|
@tracker = Tracker.find(params[:id])
|
||
|
if request.post? and @tracker.update_attributes(params[:tracker])
|
||
| ... | ... | |
|
end
|
||
|
redirect_to :action => 'index'
|
||
|
end
|
||
|
private
|
||
|
def find_trackers
|
||
|
begin
|
||
|
@tracker = Tracker.find(params[:id])
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
@tracker = Tracker.find_by_name(params[:id])
|
||
|
if @tracker.nil?
|
||
|
render_404
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/views/enumerations/index.api.rsb 2011-05-27 09:15:29.812057409 +0200 | ||
|---|---|---|
|
api.array :enumerations do
|
||
|
@enumerations.each do |enumeration|
|
||
|
api.enumeration do
|
||
|
api.type enumeration.type
|
||
|
api.name enumeration.name
|
||
|
api.id enumeration.id
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/views/enumerations/show.api.rsb 2011-05-27 09:15:29.892266085 +0200 | ||
|---|---|---|
|
api.enumerations do
|
||
|
api.type @enumeration.type
|
||
|
api.name @enumeration.name
|
||
|
api.id @enumeration.id
|
||
|
end
|
||
| ./app/views/issue_categories/index.api.rsb 2011-05-27 09:15:34.108031357 +0200 | ||
|---|---|---|
|
api.array :issue_categories do
|
||
|
@issue_categories.each do |category|
|
||
|
api.category do
|
||
|
api.name category.name
|
||
|
api.id category.id
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/views/issue_categories/show.api.rsb 2011-05-27 09:15:34.252782323 +0200 | ||
|---|---|---|
|
api.issue_category do
|
||
|
api.name @issue_category.name
|
||
|
api.id @issue_category.id
|
||
|
end
|
||
| ./app/views/issue_statuses/index.api.rsb 2011-05-27 09:15:28.031987862 +0200 | ||
|---|---|---|
|
api.array :issue_statuses do
|
||
|
@issue_statuses.each do |status|
|
||
|
api.status do
|
||
|
api.name status.name
|
||
|
api.id status.id
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/views/issue_statuses/show.api.rsb 2011-05-27 09:15:28.107988399 +0200 | ||
|---|---|---|
|
api.issue_status do
|
||
|
api.name @status.name
|
||
|
api.id @status.id
|
||
|
end
|
||
| ./app/views/trackers/index.api.rsb 2011-05-27 09:15:25.606214785 +0200 | ||
|---|---|---|
|
api.array :trackers do
|
||
|
@trackers.each do |tracker|
|
||
|
api.tracker do
|
||
|
api.name tracker.name
|
||
|
api.id tracker.id
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| ./app/views/trackers/show.api.rsb 2011-05-27 09:15:25.704003712 +0200 | ||
|---|---|---|
|
api.trackers do
|
||
|
api.name @tracker.name
|
||
|
api.id @tracker.id
|
||
|
end
|
||
| ./config/routes.rb 2011-05-27 09:20:40.667987762 +0200 | ||
|---|---|---|
|
reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
|
||
|
end
|
||
|
map.resources :issue_statuses, :only => [:index, :show]
|
||
|
map.resources :issue_categories, :only => [:index, :show]
|
||
|
map.resources :trackers, :only => [:index, :show]
|
||
|
map.resources :enumerations, :only => [:index, :show]
|
||
|
# Following two routes conflict with the resources because #index allows POST
|
||
|
map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
|
||
|
map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post }
|
||