@@ -1,91 +1,99 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class IssueCategoriesController < ApplicationController |
|
19 | 19 | menu_item :settings |
|
20 | 20 | model_object IssueCategory |
|
21 | before_filter :find_model_object, :except => :new | |
|
22 | before_filter :find_project_from_association, :except => :new | |
|
23 | before_filter :find_project, :only => :new | |
|
21 | before_filter :find_model_object, :except => [:new, :create] | |
|
22 | before_filter :find_project_from_association, :except => [:new, :create] | |
|
23 | before_filter :find_project, :only => [:new, :create] | |
|
24 | 24 | before_filter :authorize |
|
25 | 25 | |
|
26 | verify :method => :post, :only => :destroy | |
|
27 | ||
|
28 | 26 | def new |
|
29 | 27 | @category = @project.issue_categories.build(params[:category]) |
|
30 | if request.post? | |
|
31 | if @category.save | |
|
32 | respond_to do |format| | |
|
33 | format.html do | |
|
34 | flash[:notice] = l(:notice_successful_create) | |
|
35 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project | |
|
36 | end | |
|
37 |
|
|
|
38 | # IE doesn't support the replace_html rjs method for select box options | |
|
39 | render(:update) {|page| page.replace "issue_category_id", | |
|
40 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') | |
|
41 | } | |
|
42 | end | |
|
28 | end | |
|
29 | ||
|
30 | verify :method => :post, :only => :create | |
|
31 | def create | |
|
32 | @category = @project.issue_categories.build(params[:category]) | |
|
33 | if @category.save | |
|
34 | respond_to do |format| | |
|
35 | format.html do | |
|
36 | flash[:notice] = l(:notice_successful_create) | |
|
37 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project | |
|
43 | 38 | end |
|
44 | else | |
|
45 | respond_to do |format| | |
|
46 | format.html | |
|
47 | format.js do | |
|
48 | render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } | |
|
49 |
|
|
|
39 | format.js do | |
|
40 | # IE doesn't support the replace_html rjs method for select box options | |
|
41 | render(:update) {|page| page.replace "issue_category_id", | |
|
42 | content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]') | |
|
43 | } | |
|
44 | end | |
|
45 | end | |
|
46 | else | |
|
47 | respond_to do |format| | |
|
48 | format.html { render :action => 'new'} | |
|
49 | format.js do | |
|
50 | render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) } | |
|
50 | 51 | end |
|
51 | 52 | end |
|
52 | 53 | end |
|
53 | 54 | end |
|
54 | 55 | |
|
55 | 56 | def edit |
|
56 | if request.post? and @category.update_attributes(params[:category]) | |
|
57 | end | |
|
58 | ||
|
59 | verify :method => :put, :only => :update | |
|
60 | def update | |
|
61 | if @category.update_attributes(params[:category]) | |
|
57 | 62 | flash[:notice] = l(:notice_successful_update) |
|
58 | 63 | redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project |
|
64 | else | |
|
65 | render :action => 'edit' | |
|
59 | 66 | end |
|
60 | 67 | end |
|
61 | 68 | |
|
69 | verify :method => :delete, :only => :destroy | |
|
62 | 70 | def destroy |
|
63 | 71 | @issue_count = @category.issues.size |
|
64 | 72 | if @issue_count == 0 |
|
65 | 73 | # No issue assigned to this category |
|
66 | 74 | @category.destroy |
|
67 | 75 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' |
|
68 | 76 | return |
|
69 | 77 | elsif params[:todo] |
|
70 | 78 | reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign' |
|
71 | 79 | @category.destroy(reassign_to) |
|
72 | 80 | redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' |
|
73 | 81 | return |
|
74 | 82 | end |
|
75 | 83 | @categories = @project.issue_categories - [@category] |
|
76 | 84 | end |
|
77 | 85 | |
|
78 | 86 | private |
|
79 | 87 | # Wrap ApplicationController's find_model_object method to set |
|
80 | 88 | # @category instead of just @issue_category |
|
81 | 89 | def find_model_object |
|
82 | 90 | super |
|
83 | 91 | @category = @object |
|
84 | 92 | end |
|
85 | 93 | |
|
86 | 94 | def find_project |
|
87 | 95 | @project = Project.find(params[:project_id]) |
|
88 | 96 | rescue ActiveRecord::RecordNotFound |
|
89 | 97 | render_404 |
|
90 | 98 | end |
|
91 | 99 | end |
@@ -1,16 +1,16 | |||
|
1 | 1 | <h2><%=l(:label_issue_category)%>: <%=h @category.name %></h2> |
|
2 | 2 | |
|
3 | <% form_tag({}) do %> | |
|
3 | <% form_tag(issue_category_path(@category), :method => :delete) do %> | |
|
4 | 4 | <div class="box"> |
|
5 | 5 | <p><strong><%= l(:text_issue_category_destroy_question, @issue_count) %></strong></p> |
|
6 | 6 | <p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_issue_category_destroy_assignments) %></label><br /> |
|
7 | 7 | <% if @categories.size > 0 %> |
|
8 | 8 | <label><%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_issue_category_reassign_to) %></label>: |
|
9 | 9 | <%= label_tag "reassign_to_id", l(:description_issue_category_reassign), :class => "hidden-for-sighted" %> |
|
10 | 10 | <%= select_tag 'reassign_to_id', options_from_collection_for_select(@categories, 'id', 'name') %></p> |
|
11 | 11 | <% end %> |
|
12 | 12 | </div> |
|
13 | 13 | |
|
14 | 14 | <%= submit_tag l(:button_apply) %> |
|
15 | 15 | <%= link_to l(:button_cancel), :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' %> |
|
16 | 16 | <% end %> |
@@ -1,6 +1,6 | |||
|
1 | 1 | <h2><%=l(:label_issue_category)%></h2> |
|
2 | 2 | |
|
3 |
<% labelled_tabular_form_for :category, @category, :url => |
|
|
3 | <% labelled_tabular_form_for :category, @category, :url => issue_category_path(@category), :html => {:method => :put} do |f| %> | |
|
4 | 4 | <%= render :partial => 'issue_categories/form', :locals => { :f => f } %> |
|
5 | 5 | <%= submit_tag l(:button_save) %> |
|
6 | 6 | <% end %> |
@@ -1,6 +1,6 | |||
|
1 | 1 | <h2><%=l(:label_issue_category_new)%></h2> |
|
2 | 2 | |
|
3 |
<% labelled_tabular_form_for :category, @category, :url => |
|
|
3 | <% labelled_tabular_form_for :category, @category, :url => project_issue_categories_path(@project) do |f| %> | |
|
4 | 4 | <%= render :partial => 'issue_categories/form', :locals => { :f => f } %> |
|
5 | 5 | <%= submit_tag l(:button_create) %> |
|
6 | 6 | <% end %> |
@@ -1,50 +1,50 | |||
|
1 | 1 | <% fields_for :issue, @issue, :builder => TabularFormBuilder do |f| %> |
|
2 | 2 | |
|
3 | 3 | <div class="splitcontentleft"> |
|
4 | 4 | <% if @issue.new_record? || @allowed_statuses.any? %> |
|
5 | 5 | <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p> |
|
6 | 6 | <% else %> |
|
7 | 7 | <p><label><%= l(:field_status) %></label> <%= h(@issue.status.name) %></p> |
|
8 | 8 | <% end %> |
|
9 | 9 | |
|
10 | 10 | <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), {:required => true}, :disabled => !@issue.leaf? %></p> |
|
11 | 11 | <p><%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to), :include_blank => true %></p> |
|
12 | 12 | <% unless @project.issue_categories.empty? %> |
|
13 | 13 | <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %> |
|
14 | 14 | <%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'), |
|
15 | 15 | l(:label_issue_category_new), |
|
16 | 16 | 'category[name]', |
|
17 |
{:controller => 'issue_categories', :action => ' |
|
|
17 | {:controller => 'issue_categories', :action => 'create', :project_id => @project}, | |
|
18 | 18 | :title => l(:label_issue_category_new), |
|
19 | 19 | :tabindex => 199) if authorize_for('issue_categories', 'new') %></p> |
|
20 | 20 | <% end %> |
|
21 | 21 | <% unless @issue.assignable_versions.empty? %> |
|
22 | 22 | <p><%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version), :include_blank => true %> |
|
23 | 23 | <%= prompt_to_remote(image_tag('add.png', :style => 'vertical-align: middle;'), |
|
24 | 24 | l(:label_version_new), |
|
25 | 25 | 'version[name]', |
|
26 | 26 | {:controller => 'versions', :action => 'create', :project_id => @project}, |
|
27 | 27 | :title => l(:label_version_new), |
|
28 | 28 | :tabindex => 200) if authorize_for('versions', 'new') %> |
|
29 | 29 | </p> |
|
30 | 30 | <% end %> |
|
31 | 31 | </div> |
|
32 | 32 | |
|
33 | 33 | <div class="splitcontentright"> |
|
34 | 34 | <% if User.current.allowed_to?(:manage_subtasks, @project) %> |
|
35 | 35 | <p id="parent_issue"><%= f.text_field :parent_issue_id, :size => 10 %></p> |
|
36 | 36 | <div id="parent_issue_candidates" class="autocomplete"></div> |
|
37 | 37 | <%= javascript_tag "observeParentIssueField('#{auto_complete_issues_path(:id => @issue, :project_id => @project) }')" %> |
|
38 | 38 | <% end %> |
|
39 | 39 | <p><%= f.text_field :start_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_start_date') if @issue.leaf? %></p> |
|
40 | 40 | <p><%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf? %><%= calendar_for('issue_due_date') if @issue.leaf? %></p> |
|
41 | 41 | <p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf? %> <%= l(:field_hours) %></p> |
|
42 | 42 | <% if @issue.leaf? && Issue.use_field_for_done_ratio? %> |
|
43 | 43 | <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p> |
|
44 | 44 | <% end %> |
|
45 | 45 | </div> |
|
46 | 46 | |
|
47 | 47 | <div style="clear:both;"> </div> |
|
48 | 48 | <%= render :partial => 'issues/form_custom_fields' %> |
|
49 | 49 | |
|
50 | 50 | <% end %> |
@@ -1,27 +1,29 | |||
|
1 | 1 | <% if @project.issue_categories.any? %> |
|
2 | 2 | <table class="list"> |
|
3 | 3 | <thead><tr> |
|
4 | 4 | <th><%= l(:label_issue_category) %></th> |
|
5 | 5 | <th><%= l(:field_assigned_to) %></th> |
|
6 | 6 | <th></th> |
|
7 | 7 | </tr></thead> |
|
8 | 8 | <tbody> |
|
9 | 9 | <% for category in @project.issue_categories %> |
|
10 | 10 | <% unless category.new_record? %> |
|
11 | 11 | <tr class="<%= cycle 'odd', 'even' %>"> |
|
12 | 12 | <td><%=h(category.name) %></td> |
|
13 | 13 | <td><%=h(category.assigned_to.name) if category.assigned_to %></td> |
|
14 | 14 | <td class="buttons"> |
|
15 | <%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %> | |
|
16 |
<%= link_to |
|
|
15 | <% if User.current.allowed_to?(:manage_categories, @project) %> | |
|
16 | <%= link_to l(:button_edit), edit_issue_category_path(category), :class => 'icon icon-edit' %> | |
|
17 | <%= link_to l(:button_delete), issue_category_path(category), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> | |
|
18 | <% end %> | |
|
17 | 19 | </td> |
|
18 | 20 | </tr> |
|
19 | 21 | <% end %> |
|
20 | 22 | <% end %> |
|
21 | 23 | </tbody> |
|
22 | 24 | </table> |
|
23 | 25 | <% else %> |
|
24 | 26 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
25 | 27 | <% end %> |
|
26 | 28 | |
|
27 |
<p><%= link_to |
|
|
29 | <p><%= link_to l(:label_issue_category_new), new_project_issue_category_path(@project) if User.current.allowed_to?(:manage_categories, @project) %></p> |
@@ -1,258 +1,255 | |||
|
1 | 1 | ActionController::Routing::Routes.draw do |map| |
|
2 | 2 | # Add your own custom routes here. |
|
3 | 3 | # The priority is based upon order of creation: first created -> highest priority. |
|
4 | 4 | |
|
5 | 5 | # Here's a sample route: |
|
6 | 6 | # map.connect 'products/:id', :controller => 'catalog', :action => 'view' |
|
7 | 7 | # Keep in mind you can assign values other than :controller and :action |
|
8 | 8 | |
|
9 | 9 | map.home '', :controller => 'welcome' |
|
10 | 10 | |
|
11 | 11 | map.signin 'login', :controller => 'account', :action => 'login' |
|
12 | 12 | map.signout 'logout', :controller => 'account', :action => 'logout' |
|
13 | 13 | |
|
14 | 14 | map.connect 'roles/workflow/:id/:role_id/:tracker_id', :controller => 'roles', :action => 'workflow' |
|
15 | 15 | map.connect 'help/:ctrl/:page', :controller => 'help' |
|
16 | 16 | |
|
17 | 17 | map.with_options :controller => 'time_entry_reports', :action => 'report',:conditions => {:method => :get} do |time_report| |
|
18 | 18 | time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report' |
|
19 | 19 | time_report.connect 'projects/:project_id/issues/:issue_id/time_entries/report.:format' |
|
20 | 20 | time_report.connect 'projects/:project_id/time_entries/report' |
|
21 | 21 | time_report.connect 'projects/:project_id/time_entries/report.:format' |
|
22 | 22 | time_report.connect 'time_entries/report' |
|
23 | 23 | time_report.connect 'time_entries/report.:format' |
|
24 | 24 | end |
|
25 | 25 | |
|
26 | 26 | map.bulk_edit_time_entry 'time_entries/bulk_edit', |
|
27 | 27 | :controller => 'timelog', :action => 'bulk_edit', :conditions => { :method => :get } |
|
28 | 28 | map.bulk_update_time_entry 'time_entries/bulk_edit', |
|
29 | 29 | :controller => 'timelog', :action => 'bulk_update', :conditions => { :method => :post } |
|
30 | 30 | map.time_entries_context_menu '/time_entries/context_menu', |
|
31 | 31 | :controller => 'context_menus', :action => 'time_entries' |
|
32 | 32 | # TODO: wasteful since this is also nested under issues, projects, and projects/issues |
|
33 | 33 | map.resources :time_entries, :controller => 'timelog' |
|
34 | 34 | |
|
35 | 35 | map.connect 'projects/:id/wiki', :controller => 'wikis', :action => 'edit', :conditions => {:method => :post} |
|
36 | 36 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :get} |
|
37 | 37 | map.connect 'projects/:id/wiki/destroy', :controller => 'wikis', :action => 'destroy', :conditions => {:method => :post} |
|
38 | 38 | |
|
39 | 39 | map.with_options :controller => 'messages' do |messages_routes| |
|
40 | 40 | messages_routes.with_options :conditions => {:method => :get} do |messages_views| |
|
41 | 41 | messages_views.connect 'boards/:board_id/topics/new', :action => 'new' |
|
42 | 42 | messages_views.connect 'boards/:board_id/topics/:id', :action => 'show' |
|
43 | 43 | messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit' |
|
44 | 44 | end |
|
45 | 45 | messages_routes.with_options :conditions => {:method => :post} do |messages_actions| |
|
46 | 46 | messages_actions.connect 'boards/:board_id/topics/new', :action => 'new' |
|
47 | 47 | messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply' |
|
48 | 48 | messages_actions.connect 'boards/:board_id/topics/:id/:action', :action => /edit|destroy/ |
|
49 | 49 | end |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | map.with_options :controller => 'boards' do |board_routes| |
|
53 | 53 | board_routes.with_options :conditions => {:method => :get} do |board_views| |
|
54 | 54 | board_views.connect 'projects/:project_id/boards', :action => 'index' |
|
55 | 55 | board_views.connect 'projects/:project_id/boards/new', :action => 'new' |
|
56 | 56 | board_views.connect 'projects/:project_id/boards/:id', :action => 'show' |
|
57 | 57 | board_views.connect 'projects/:project_id/boards/:id.:format', :action => 'show' |
|
58 | 58 | board_views.connect 'projects/:project_id/boards/:id/edit', :action => 'edit' |
|
59 | 59 | end |
|
60 | 60 | board_routes.with_options :conditions => {:method => :post} do |board_actions| |
|
61 | 61 | board_actions.connect 'projects/:project_id/boards', :action => 'new' |
|
62 | 62 | board_actions.connect 'projects/:project_id/boards/:id/:action', :action => /edit|destroy/ |
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | 66 | map.with_options :controller => 'documents' do |document_routes| |
|
67 | 67 | document_routes.with_options :conditions => {:method => :get} do |document_views| |
|
68 | 68 | document_views.connect 'projects/:project_id/documents', :action => 'index' |
|
69 | 69 | document_views.connect 'projects/:project_id/documents/new', :action => 'new' |
|
70 | 70 | document_views.connect 'documents/:id', :action => 'show' |
|
71 | 71 | document_views.connect 'documents/:id/edit', :action => 'edit' |
|
72 | 72 | end |
|
73 | 73 | document_routes.with_options :conditions => {:method => :post} do |document_actions| |
|
74 | 74 | document_actions.connect 'projects/:project_id/documents', :action => 'new' |
|
75 | 75 | document_actions.connect 'documents/:id/:action', :action => /destroy|edit/ |
|
76 | 76 | end |
|
77 | 77 | end |
|
78 | 78 | |
|
79 | 79 | map.resources :issue_moves, :only => [:new, :create], :path_prefix => '/issues', :as => 'move' |
|
80 | 80 | map.resources :queries, :except => [:show] |
|
81 | 81 | |
|
82 | 82 | # Misc issue routes. TODO: move into resources |
|
83 | 83 | map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes', :action => 'issues' |
|
84 | 84 | map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue' # TODO: would look nicer as /issues/:id/preview |
|
85 | 85 | map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues' |
|
86 | 86 | map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index' |
|
87 | 87 | map.bulk_edit_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_edit', :conditions => { :method => :get } |
|
88 | 88 | map.bulk_update_issue 'issues/bulk_edit', :controller => 'issues', :action => 'bulk_update', :conditions => { :method => :post } |
|
89 | 89 | map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new', :id => /\d+/, :conditions => { :method => :post } |
|
90 | 90 | map.connect '/issues/:id/destroy', :controller => 'issues', :action => 'destroy', :conditions => { :method => :post } # legacy |
|
91 | 91 | |
|
92 | 92 | map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes| |
|
93 | 93 | gantts_routes.connect '/projects/:project_id/issues/gantt' |
|
94 | 94 | gantts_routes.connect '/projects/:project_id/issues/gantt.:format' |
|
95 | 95 | gantts_routes.connect '/issues/gantt.:format' |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes| |
|
99 | 99 | calendars_routes.connect '/projects/:project_id/issues/calendar' |
|
100 | 100 | calendars_routes.connect '/issues/calendar' |
|
101 | 101 | end |
|
102 | 102 | |
|
103 | 103 | map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports| |
|
104 | 104 | reports.connect 'projects/:id/issues/report', :action => 'issue_report' |
|
105 | 105 | reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details' |
|
106 | 106 | end |
|
107 | 107 | |
|
108 | 108 | # Following two routes conflict with the resources because #index allows POST |
|
109 | 109 | map.connect '/issues', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
110 | 110 | map.connect '/issues/create', :controller => 'issues', :action => 'index', :conditions => { :method => :post } |
|
111 | 111 | |
|
112 | 112 | map.resources :issues, :member => { :edit => :post }, :collection => {} do |issues| |
|
113 | 113 | issues.resources :time_entries, :controller => 'timelog' |
|
114 | 114 | issues.resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] |
|
115 | 115 | end |
|
116 | 116 | |
|
117 | 117 | map.resources :issues, :path_prefix => '/projects/:project_id', :collection => { :create => :post } do |issues| |
|
118 | 118 | issues.resources :time_entries, :controller => 'timelog' |
|
119 | 119 | end |
|
120 | 120 | |
|
121 | 121 | map.connect 'projects/:id/members/new', :controller => 'members', :action => 'new' |
|
122 | 122 | |
|
123 | 123 | map.with_options :controller => 'users' do |users| |
|
124 | 124 | users.connect 'users/:id/edit/:tab', :action => 'edit', :tab => nil, :conditions => {:method => :get} |
|
125 | 125 | |
|
126 | 126 | users.with_options :conditions => {:method => :post} do |user_actions| |
|
127 | 127 | user_actions.connect 'users/:id/memberships', :action => 'edit_membership' |
|
128 | 128 | user_actions.connect 'users/:id/memberships/:membership_id', :action => 'edit_membership' |
|
129 | 129 | user_actions.connect 'users/:id/memberships/:membership_id/destroy', :action => 'destroy_membership' |
|
130 | 130 | end |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | map.resources :users, :member => { |
|
134 | 134 | :edit_membership => :post, |
|
135 | 135 | :destroy_membership => :post |
|
136 | 136 | } |
|
137 | 137 | |
|
138 | 138 | # For nice "roadmap" in the url for the index action |
|
139 | 139 | map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index' |
|
140 | 140 | |
|
141 | 141 | map.all_news 'news', :controller => 'news', :action => 'index' |
|
142 | 142 | map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index' |
|
143 | 143 | map.preview_news '/news/preview', :controller => 'previews', :action => 'news' |
|
144 | 144 | map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post} |
|
145 | 145 | map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete} |
|
146 | 146 | |
|
147 | 147 | map.resources :projects, :member => { |
|
148 | 148 | :copy => [:get, :post], |
|
149 | 149 | :settings => :get, |
|
150 | 150 | :modules => :post, |
|
151 | 151 | :archive => :post, |
|
152 | 152 | :unarchive => :post |
|
153 | 153 | } do |project| |
|
154 | 154 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
155 | 155 | project.resources :files, :only => [:index, :new, :create] |
|
156 | 156 | project.resources :versions, :shallow => true, :collection => {:close_completed => :put}, :member => {:status_by => :post} |
|
157 | 157 | project.resources :news, :shallow => true |
|
158 | 158 | project.resources :time_entries, :controller => 'timelog', :path_prefix => 'projects/:project_id' |
|
159 | 159 | project.resources :queries, :only => [:new, :create] |
|
160 | project.resources :issue_categories, :shallow => true | |
|
160 | 161 | |
|
161 | 162 | project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get} |
|
162 | 163 | project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get} |
|
163 | 164 | project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil |
|
164 | 165 | project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff' |
|
165 | 166 | project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate' |
|
166 | 167 | project.resources :wiki, :except => [:new, :create], :member => { |
|
167 | 168 | :rename => [:get, :post], |
|
168 | 169 | :history => :get, |
|
169 | 170 | :preview => :any, |
|
170 | 171 | :protect => :post, |
|
171 | 172 | :add_attachment => :post |
|
172 | 173 | }, :collection => { |
|
173 | 174 | :export => :get, |
|
174 | 175 | :date_index => :get |
|
175 | 176 | } |
|
176 | 177 | |
|
177 | 178 | end |
|
178 | 179 | |
|
179 | 180 | # Destroy uses a get request to prompt the user before the actual DELETE request |
|
180 | 181 | map.project_destroy_confirm 'projects/:id/destroy', :controller => 'projects', :action => 'destroy', :conditions => {:method => :get} |
|
181 | 182 | |
|
182 | 183 | # TODO: port to be part of the resources route(s) |
|
183 | 184 | map.with_options :controller => 'projects' do |project_mapper| |
|
184 | 185 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
|
185 | 186 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' |
|
186 | 187 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
187 | 188 | end |
|
188 | 189 | end |
|
189 | 190 | |
|
190 | 191 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
|
191 | 192 | activity.connect 'projects/:id/activity' |
|
192 | 193 | activity.connect 'projects/:id/activity.:format' |
|
193 | 194 | activity.connect 'activity', :id => nil |
|
194 | 195 | activity.connect 'activity.:format', :id => nil |
|
195 | 196 | end |
|
196 | 197 | |
|
197 | map.with_options :controller => 'issue_categories' do |categories| | |
|
198 | categories.connect 'projects/:project_id/issue_categories/new', :action => 'new' | |
|
199 | end | |
|
200 | ||
|
201 | 198 | map.with_options :controller => 'repositories' do |repositories| |
|
202 | 199 | repositories.with_options :conditions => {:method => :get} do |repository_views| |
|
203 | 200 | repository_views.connect 'projects/:id/repository', :action => 'show' |
|
204 | 201 | repository_views.connect 'projects/:id/repository/edit', :action => 'edit' |
|
205 | 202 | repository_views.connect 'projects/:id/repository/statistics', :action => 'stats' |
|
206 | 203 | repository_views.connect 'projects/:id/repository/revisions', :action => 'revisions' |
|
207 | 204 | repository_views.connect 'projects/:id/repository/revisions.:format', :action => 'revisions' |
|
208 | 205 | repository_views.connect 'projects/:id/repository/revisions/:rev', :action => 'revision' |
|
209 | 206 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff', :action => 'diff' |
|
210 | 207 | repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format', :action => 'diff' |
|
211 | 208 | repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path', :action => 'entry', :format => 'raw', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
212 | 209 | repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path', :requirements => { :rev => /[a-z0-9\.\-_]+/ } |
|
213 | 210 | repository_views.connect 'projects/:id/repository/raw/*path', :action => 'entry', :format => 'raw' |
|
214 | 211 | # TODO: why the following route is required? |
|
215 | 212 | repository_views.connect 'projects/:id/repository/entry/*path', :action => 'entry' |
|
216 | 213 | repository_views.connect 'projects/:id/repository/:action/*path' |
|
217 | 214 | end |
|
218 | 215 | |
|
219 | 216 | repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post} |
|
220 | 217 | end |
|
221 | 218 | |
|
222 | 219 | map.connect 'attachments/:id', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
223 | 220 | map.connect 'attachments/:id.:format', :controller => 'attachments', :action => 'show', :id => /\d+/ |
|
224 | 221 | map.connect 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/ |
|
225 | 222 | map.connect 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/ |
|
226 | 223 | |
|
227 | 224 | map.resources :groups |
|
228 | 225 | |
|
229 | 226 | #left old routes at the bottom for backwards compat |
|
230 | 227 | map.connect 'trackers.:format', :controller => 'trackers', :action => 'index' |
|
231 | 228 | map.connect 'issue_statuses.:format', :controller => 'issue_statuses', :action => 'index' |
|
232 | 229 | map.connect 'projects/:project_id/issues/:action', :controller => 'issues' |
|
233 | 230 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
|
234 | 231 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
|
235 | 232 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
|
236 | 233 | map.connect 'wiki/:id/:page/:action', :page => nil, :controller => 'wiki' |
|
237 | 234 | map.connect 'projects/:project_id/news/:action', :controller => 'news' |
|
238 | 235 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ |
|
239 | 236 | map.with_options :controller => 'repositories' do |omap| |
|
240 | 237 | omap.repositories_show 'repositories/browse/:id/*path', :action => 'browse' |
|
241 | 238 | omap.repositories_changes 'repositories/changes/:id/*path', :action => 'changes' |
|
242 | 239 | omap.repositories_diff 'repositories/diff/:id/*path', :action => 'diff' |
|
243 | 240 | omap.repositories_entry 'repositories/entry/:id/*path', :action => 'entry' |
|
244 | 241 | omap.repositories_entry 'repositories/annotate/:id/*path', :action => 'annotate' |
|
245 | 242 | omap.connect 'repositories/revision/:id/:rev', :action => 'revision' |
|
246 | 243 | end |
|
247 | 244 | |
|
248 | 245 | map.with_options :controller => 'sys' do |sys| |
|
249 | 246 | sys.connect 'sys/projects.:format', :action => 'projects', :conditions => {:method => :get} |
|
250 | 247 | sys.connect 'sys/projects/:id/repository.:format', :action => 'create_project_repository', :conditions => {:method => :post} |
|
251 | 248 | end |
|
252 | 249 | |
|
253 | 250 | # Install the default route as the lowest priority. |
|
254 | 251 | map.connect ':controller/:action/:id' |
|
255 | 252 | map.connect 'robots.txt', :controller => 'welcome', :action => 'robots' |
|
256 | 253 | # Used for OpenID |
|
257 | 254 | map.root :controller => 'account', :action => 'login' |
|
258 | 255 | end |
@@ -1,237 +1,237 | |||
|
1 | 1 | require 'redmine/access_control' |
|
2 | 2 | require 'redmine/menu_manager' |
|
3 | 3 | require 'redmine/activity' |
|
4 | 4 | require 'redmine/search' |
|
5 | 5 | require 'redmine/custom_field_format' |
|
6 | 6 | require 'redmine/mime_type' |
|
7 | 7 | require 'redmine/core_ext' |
|
8 | 8 | require 'redmine/themes' |
|
9 | 9 | require 'redmine/hook' |
|
10 | 10 | require 'redmine/plugin' |
|
11 | 11 | require 'redmine/notifiable' |
|
12 | 12 | require 'redmine/wiki_formatting' |
|
13 | 13 | require 'redmine/scm/base' |
|
14 | 14 | |
|
15 | 15 | begin |
|
16 | 16 | require_library_or_gem 'RMagick' unless Object.const_defined?(:Magick) |
|
17 | 17 | rescue LoadError |
|
18 | 18 | # RMagick is not available |
|
19 | 19 | end |
|
20 | 20 | |
|
21 | 21 | if RUBY_VERSION < '1.9' |
|
22 | 22 | require 'faster_csv' |
|
23 | 23 | else |
|
24 | 24 | require 'csv' |
|
25 | 25 | FCSV = CSV |
|
26 | 26 | end |
|
27 | 27 | |
|
28 | 28 | Redmine::Scm::Base.add "Subversion" |
|
29 | 29 | Redmine::Scm::Base.add "Darcs" |
|
30 | 30 | Redmine::Scm::Base.add "Mercurial" |
|
31 | 31 | Redmine::Scm::Base.add "Cvs" |
|
32 | 32 | Redmine::Scm::Base.add "Bazaar" |
|
33 | 33 | Redmine::Scm::Base.add "Git" |
|
34 | 34 | Redmine::Scm::Base.add "Filesystem" |
|
35 | 35 | |
|
36 | 36 | Redmine::CustomFieldFormat.map do |fields| |
|
37 | 37 | fields.register Redmine::CustomFieldFormat.new('string', :label => :label_string, :order => 1) |
|
38 | 38 | fields.register Redmine::CustomFieldFormat.new('text', :label => :label_text, :order => 2) |
|
39 | 39 | fields.register Redmine::CustomFieldFormat.new('int', :label => :label_integer, :order => 3) |
|
40 | 40 | fields.register Redmine::CustomFieldFormat.new('float', :label => :label_float, :order => 4) |
|
41 | 41 | fields.register Redmine::CustomFieldFormat.new('list', :label => :label_list, :order => 5) |
|
42 | 42 | fields.register Redmine::CustomFieldFormat.new('date', :label => :label_date, :order => 6) |
|
43 | 43 | fields.register Redmine::CustomFieldFormat.new('bool', :label => :label_boolean, :order => 7) |
|
44 | 44 | fields.register Redmine::CustomFieldFormat.new('user', :label => :label_user, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 8) |
|
45 | 45 | fields.register Redmine::CustomFieldFormat.new('version', :label => :label_version, :only => %w(Issue TimeEntry Version Project), :edit_as => 'list', :order => 9) |
|
46 | 46 | end |
|
47 | 47 | |
|
48 | 48 | # Permissions |
|
49 | 49 | Redmine::AccessControl.map do |map| |
|
50 | 50 | map.permission :view_project, {:projects => [:show], :activities => [:index]}, :public => true |
|
51 | 51 | map.permission :search_project, {:search => :index}, :public => true |
|
52 | 52 | map.permission :add_project, {:projects => [:new, :create]}, :require => :loggedin |
|
53 | 53 | map.permission :edit_project, {:projects => [:settings, :edit, :update]}, :require => :member |
|
54 | 54 | map.permission :select_project_modules, {:projects => :modules}, :require => :member |
|
55 | 55 | map.permission :manage_members, {:projects => :settings, :members => [:new, :edit, :destroy, :autocomplete_for_member]}, :require => :member |
|
56 | 56 | map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member |
|
57 | 57 | map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member |
|
58 | 58 | |
|
59 | 59 | map.project_module :issue_tracking do |map| |
|
60 | 60 | # Issue categories |
|
61 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :edit, :destroy]}, :require => :member | |
|
61 | map.permission :manage_categories, {:projects => :settings, :issue_categories => [:new, :create, :edit, :update, :destroy]}, :require => :member | |
|
62 | 62 | # Issues |
|
63 | 63 | map.permission :view_issues, {:issues => [:index, :show], |
|
64 | 64 | :auto_complete => [:issues], |
|
65 | 65 | :context_menus => [:issues], |
|
66 | 66 | :versions => [:index, :show, :status_by], |
|
67 | 67 | :journals => [:index, :diff], |
|
68 | 68 | :queries => :index, |
|
69 | 69 | :reports => [:issue_report, :issue_report_details]} |
|
70 | 70 | map.permission :add_issues, {:issues => [:new, :create, :update_form]} |
|
71 | 71 | map.permission :edit_issues, {:issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], :journals => [:new]} |
|
72 | 72 | map.permission :manage_issue_relations, {:issue_relations => [:index, :show, :create, :destroy]} |
|
73 | 73 | map.permission :manage_subtasks, {} |
|
74 | 74 | map.permission :set_issues_private, {} |
|
75 | 75 | map.permission :set_own_issues_private, {}, :require => :loggedin |
|
76 | 76 | map.permission :add_issue_notes, {:issues => [:edit, :update], :journals => [:new]} |
|
77 | 77 | map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
|
78 | 78 | map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
|
79 | 79 | map.permission :move_issues, {:issue_moves => [:new, :create]}, :require => :loggedin |
|
80 | 80 | map.permission :delete_issues, {:issues => :destroy}, :require => :member |
|
81 | 81 | # Queries |
|
82 | 82 | map.permission :manage_public_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :member |
|
83 | 83 | map.permission :save_queries, {:queries => [:new, :create, :edit, :update, :destroy]}, :require => :loggedin |
|
84 | 84 | # Watchers |
|
85 | 85 | map.permission :view_issue_watchers, {} |
|
86 | 86 | map.permission :add_issue_watchers, {:watchers => :new} |
|
87 | 87 | map.permission :delete_issue_watchers, {:watchers => :destroy} |
|
88 | 88 | end |
|
89 | 89 | |
|
90 | 90 | map.project_module :time_tracking do |map| |
|
91 | 91 | map.permission :log_time, {:timelog => [:new, :create, :edit, :update, :bulk_edit, :bulk_update]}, :require => :loggedin |
|
92 | 92 | map.permission :view_time_entries, :timelog => [:index, :show], :time_entry_reports => [:report] |
|
93 | 93 | map.permission :edit_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy, :bulk_edit, :bulk_update]}, :require => :member |
|
94 | 94 | map.permission :edit_own_time_entries, {:timelog => [:new, :create, :edit, :update, :destroy,:bulk_edit, :bulk_update]}, :require => :loggedin |
|
95 | 95 | map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | map.project_module :news do |map| |
|
99 | 99 | map.permission :manage_news, {:news => [:new, :create, :edit, :update, :destroy], :comments => [:destroy]}, :require => :member |
|
100 | 100 | map.permission :view_news, {:news => [:index, :show]}, :public => true |
|
101 | 101 | map.permission :comment_news, {:comments => :create} |
|
102 | 102 | end |
|
103 | 103 | |
|
104 | 104 | map.project_module :documents do |map| |
|
105 | 105 | map.permission :manage_documents, {:documents => [:new, :edit, :destroy, :add_attachment]}, :require => :loggedin |
|
106 | 106 | map.permission :view_documents, :documents => [:index, :show, :download] |
|
107 | 107 | end |
|
108 | 108 | |
|
109 | 109 | map.project_module :files do |map| |
|
110 | 110 | map.permission :manage_files, {:files => [:new, :create]}, :require => :loggedin |
|
111 | 111 | map.permission :view_files, :files => :index, :versions => :download |
|
112 | 112 | end |
|
113 | 113 | |
|
114 | 114 | map.project_module :wiki do |map| |
|
115 | 115 | map.permission :manage_wiki, {:wikis => [:edit, :destroy]}, :require => :member |
|
116 | 116 | map.permission :rename_wiki_pages, {:wiki => :rename}, :require => :member |
|
117 | 117 | map.permission :delete_wiki_pages, {:wiki => :destroy}, :require => :member |
|
118 | 118 | map.permission :view_wiki_pages, :wiki => [:index, :show, :special, :date_index] |
|
119 | 119 | map.permission :export_wiki_pages, :wiki => [:export] |
|
120 | 120 | map.permission :view_wiki_edits, :wiki => [:history, :diff, :annotate] |
|
121 | 121 | map.permission :edit_wiki_pages, :wiki => [:edit, :update, :preview, :add_attachment] |
|
122 | 122 | map.permission :delete_wiki_pages_attachments, {} |
|
123 | 123 | map.permission :protect_wiki_pages, {:wiki => :protect}, :require => :member |
|
124 | 124 | end |
|
125 | 125 | |
|
126 | 126 | map.project_module :repository do |map| |
|
127 | 127 | map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member |
|
128 | 128 | map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
|
129 | 129 | map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
130 | 130 | map.permission :commit_access, {} |
|
131 | 131 | end |
|
132 | 132 | |
|
133 | 133 | map.project_module :boards do |map| |
|
134 | 134 | map.permission :manage_boards, {:boards => [:new, :edit, :destroy]}, :require => :member |
|
135 | 135 | map.permission :view_messages, {:boards => [:index, :show], :messages => [:show]}, :public => true |
|
136 | 136 | map.permission :add_messages, {:messages => [:new, :reply, :quote]} |
|
137 | 137 | map.permission :edit_messages, {:messages => :edit}, :require => :member |
|
138 | 138 | map.permission :edit_own_messages, {:messages => :edit}, :require => :loggedin |
|
139 | 139 | map.permission :delete_messages, {:messages => :destroy}, :require => :member |
|
140 | 140 | map.permission :delete_own_messages, {:messages => :destroy}, :require => :loggedin |
|
141 | 141 | end |
|
142 | 142 | |
|
143 | 143 | map.project_module :calendar do |map| |
|
144 | 144 | map.permission :view_calendar, :calendars => [:show, :update] |
|
145 | 145 | end |
|
146 | 146 | |
|
147 | 147 | map.project_module :gantt do |map| |
|
148 | 148 | map.permission :view_gantt, :gantts => [:show, :update] |
|
149 | 149 | end |
|
150 | 150 | end |
|
151 | 151 | |
|
152 | 152 | Redmine::MenuManager.map :top_menu do |menu| |
|
153 | 153 | menu.push :home, :home_path |
|
154 | 154 | menu.push :my_page, { :controller => 'my', :action => 'page' }, :if => Proc.new { User.current.logged? } |
|
155 | 155 | menu.push :projects, { :controller => 'projects', :action => 'index' }, :caption => :label_project_plural |
|
156 | 156 | menu.push :administration, { :controller => 'admin', :action => 'index' }, :if => Proc.new { User.current.admin? }, :last => true |
|
157 | 157 | menu.push :help, Redmine::Info.help_url, :last => true |
|
158 | 158 | end |
|
159 | 159 | |
|
160 | 160 | Redmine::MenuManager.map :account_menu do |menu| |
|
161 | 161 | menu.push :login, :signin_path, :if => Proc.new { !User.current.logged? } |
|
162 | 162 | menu.push :register, { :controller => 'account', :action => 'register' }, :if => Proc.new { !User.current.logged? && Setting.self_registration? } |
|
163 | 163 | menu.push :my_account, { :controller => 'my', :action => 'account' }, :if => Proc.new { User.current.logged? } |
|
164 | 164 | menu.push :logout, :signout_path, :if => Proc.new { User.current.logged? } |
|
165 | 165 | end |
|
166 | 166 | |
|
167 | 167 | Redmine::MenuManager.map :application_menu do |menu| |
|
168 | 168 | # Empty |
|
169 | 169 | end |
|
170 | 170 | |
|
171 | 171 | Redmine::MenuManager.map :admin_menu do |menu| |
|
172 | 172 | menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural |
|
173 | 173 | menu.push :users, {:controller => 'users'}, :caption => :label_user_plural |
|
174 | 174 | menu.push :groups, {:controller => 'groups'}, :caption => :label_group_plural |
|
175 | 175 | menu.push :roles, {:controller => 'roles'}, :caption => :label_role_and_permissions |
|
176 | 176 | menu.push :trackers, {:controller => 'trackers'}, :caption => :label_tracker_plural |
|
177 | 177 | menu.push :issue_statuses, {:controller => 'issue_statuses'}, :caption => :label_issue_status_plural, |
|
178 | 178 | :html => {:class => 'issue_statuses'} |
|
179 | 179 | menu.push :workflows, {:controller => 'workflows', :action => 'edit'}, :caption => :label_workflow |
|
180 | 180 | menu.push :custom_fields, {:controller => 'custom_fields'}, :caption => :label_custom_field_plural, |
|
181 | 181 | :html => {:class => 'custom_fields'} |
|
182 | 182 | menu.push :enumerations, {:controller => 'enumerations'} |
|
183 | 183 | menu.push :settings, {:controller => 'settings'} |
|
184 | 184 | menu.push :ldap_authentication, {:controller => 'ldap_auth_sources', :action => 'index'}, |
|
185 | 185 | :html => {:class => 'server_authentication'} |
|
186 | 186 | menu.push :plugins, {:controller => 'admin', :action => 'plugins'}, :last => true |
|
187 | 187 | menu.push :info, {:controller => 'admin', :action => 'info'}, :caption => :label_information_plural, :last => true |
|
188 | 188 | end |
|
189 | 189 | |
|
190 | 190 | Redmine::MenuManager.map :project_menu do |menu| |
|
191 | 191 | menu.push :overview, { :controller => 'projects', :action => 'show' } |
|
192 | 192 | menu.push :activity, { :controller => 'activities', :action => 'index' } |
|
193 | 193 | menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id, |
|
194 | 194 | :if => Proc.new { |p| p.shared_versions.any? } |
|
195 | 195 | menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural |
|
196 | 196 | menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, |
|
197 | 197 | :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } |
|
198 | 198 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt |
|
199 | 199 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar |
|
200 | 200 | menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural |
|
201 | 201 | menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural |
|
202 | 202 | menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id, |
|
203 | 203 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
204 | 204 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
205 | 205 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
206 | 206 | menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id |
|
207 | 207 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
208 | 208 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
209 | 209 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
|
210 | 210 | end |
|
211 | 211 | |
|
212 | 212 | Redmine::Activity.map do |activity| |
|
213 | 213 | activity.register :issues, :class_name => %w(Issue Journal) |
|
214 | 214 | activity.register :changesets |
|
215 | 215 | activity.register :news |
|
216 | 216 | activity.register :documents, :class_name => %w(Document Attachment) |
|
217 | 217 | activity.register :files, :class_name => 'Attachment' |
|
218 | 218 | activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false |
|
219 | 219 | activity.register :messages, :default => false |
|
220 | 220 | activity.register :time_entries, :default => false |
|
221 | 221 | end |
|
222 | 222 | |
|
223 | 223 | Redmine::Search.map do |search| |
|
224 | 224 | search.register :issues |
|
225 | 225 | search.register :news |
|
226 | 226 | search.register :documents |
|
227 | 227 | search.register :changesets |
|
228 | 228 | search.register :wiki_pages |
|
229 | 229 | search.register :messages |
|
230 | 230 | search.register :projects |
|
231 | 231 | end |
|
232 | 232 | |
|
233 | 233 | Redmine::WikiFormatting.map do |format| |
|
234 | 234 | format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
|
235 | 235 | end |
|
236 | 236 | |
|
237 | 237 | ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler |
@@ -1,96 +1,116 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../../test_helper', __FILE__) |
|
19 | 19 | require 'issue_categories_controller' |
|
20 | 20 | |
|
21 | 21 | # Re-raise errors caught by the controller. |
|
22 | 22 | class IssueCategoriesController; def rescue_action(e) raise e end; end |
|
23 | 23 | |
|
24 | 24 | class IssueCategoriesControllerTest < ActionController::TestCase |
|
25 | 25 | fixtures :projects, :users, :members, :member_roles, :roles, :enabled_modules, :issue_categories |
|
26 | 26 | |
|
27 | 27 | def setup |
|
28 | 28 | @controller = IssueCategoriesController.new |
|
29 | 29 | @request = ActionController::TestRequest.new |
|
30 | 30 | @response = ActionController::TestResponse.new |
|
31 | 31 | User.current = nil |
|
32 | 32 | @request.session[:user_id] = 2 |
|
33 | 33 | end |
|
34 | 34 | |
|
35 |
def test_ |
|
|
35 | def test_new | |
|
36 | 36 | @request.session[:user_id] = 2 # manager |
|
37 | 37 | get :new, :project_id => '1' |
|
38 | 38 | assert_response :success |
|
39 | 39 | assert_template 'new' |
|
40 | 40 | end |
|
41 | 41 | |
|
42 |
def test_ |
|
|
42 | def test_create | |
|
43 | 43 | @request.session[:user_id] = 2 # manager |
|
44 | 44 | assert_difference 'IssueCategory.count' do |
|
45 |
post : |
|
|
45 | post :create, :project_id => '1', :category => {:name => 'New category'} | |
|
46 | 46 | end |
|
47 | 47 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
48 | 48 | category = IssueCategory.find_by_name('New category') |
|
49 | 49 | assert_not_nil category |
|
50 | 50 | assert_equal 1, category.project_id |
|
51 | 51 | end |
|
52 | 52 | |
|
53 |
def test_ |
|
|
53 | def test_create_failure | |
|
54 | @request.session[:user_id] = 2 | |
|
55 | post :create, :project_id => '1', :category => {:name => ''} | |
|
56 | assert_response :success | |
|
57 | assert_template 'new' | |
|
58 | end | |
|
59 | ||
|
60 | def test_edit | |
|
61 | @request.session[:user_id] = 2 | |
|
62 | get :edit, :id => 2 | |
|
63 | assert_response :success | |
|
64 | assert_template 'edit' | |
|
65 | end | |
|
66 | ||
|
67 | def test_update | |
|
54 | 68 | assert_no_difference 'IssueCategory.count' do |
|
55 |
p |
|
|
69 | put :update, :id => 2, :category => { :name => 'Testing' } | |
|
56 | 70 | end |
|
57 | 71 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
58 | 72 | assert_equal 'Testing', IssueCategory.find(2).name |
|
59 | 73 | end |
|
60 | 74 | |
|
61 |
def test_ |
|
|
62 |
p |
|
|
75 | def test_update_failure | |
|
76 | put :update, :id => 2, :category => { :name => '' } | |
|
77 | assert_response :success | |
|
78 | assert_template 'edit' | |
|
79 | end | |
|
80 | ||
|
81 | def test_update_not_found | |
|
82 | put :update, :id => 97, :category => { :name => 'Testing' } | |
|
63 | 83 | assert_response 404 |
|
64 | 84 | end |
|
65 | 85 | |
|
66 | 86 | def test_destroy_category_not_in_use |
|
67 |
|
|
|
87 | delete :destroy, :id => 2 | |
|
68 | 88 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
69 | 89 | assert_nil IssueCategory.find_by_id(2) |
|
70 | 90 | end |
|
71 | 91 | |
|
72 | 92 | def test_destroy_category_in_use |
|
73 |
|
|
|
93 | delete :destroy, :id => 1 | |
|
74 | 94 | assert_response :success |
|
75 | 95 | assert_template 'destroy' |
|
76 | 96 | assert_not_nil IssueCategory.find_by_id(1) |
|
77 | 97 | end |
|
78 | 98 | |
|
79 | 99 | def test_destroy_category_in_use_with_reassignment |
|
80 | 100 | issue = Issue.find(:first, :conditions => {:category_id => 1}) |
|
81 |
|
|
|
101 | delete :destroy, :id => 1, :todo => 'reassign', :reassign_to_id => 2 | |
|
82 | 102 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
83 | 103 | assert_nil IssueCategory.find_by_id(1) |
|
84 | 104 | # check that the issue was reassign |
|
85 | 105 | assert_equal 2, issue.reload.category_id |
|
86 | 106 | end |
|
87 | 107 | |
|
88 | 108 | def test_destroy_category_in_use_without_reassignment |
|
89 | 109 | issue = Issue.find(:first, :conditions => {:category_id => 1}) |
|
90 |
|
|
|
110 | delete :destroy, :id => 1, :todo => 'nullify' | |
|
91 | 111 | assert_redirected_to '/projects/ecookbook/settings/categories' |
|
92 | 112 | assert_nil IssueCategory.find_by_id(1) |
|
93 | 113 | # check that the issue category was nullified |
|
94 | 114 | assert_nil issue.reload.category_id |
|
95 | 115 | end |
|
96 | 116 | end |
General Comments 0
You need to be logged in to leave comments.
Login now