Feature #2009 » redmine-08x-new.patch
redmine-stable/app/controllers/changeset_relations_controller.rb 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
1 |
class ChangesetRelationsController < ApplicationController |
|
2 | ||
3 | ||
4 |
before_filter :find_project, :authorize |
|
5 |
|
|
6 |
def new |
|
7 |
@changeset = Changeset.find(:first, :conditions => {:revision => params[:changeset][:revision], :repository_id => @project.repository}) |
|
8 |
if @changeset.nil? |
|
9 |
@changeset = Changeset.new(:revision => params[:changeset][:revision]) |
|
10 |
@changeset.errors.add l(:revision_not_found_error) |
|
11 |
else |
|
12 |
@changeset.issues << @issue |
|
13 |
@changeset.save if request.post? |
|
14 |
end |
|
15 |
@issue.reload |
|
16 |
respond_to do |format| |
|
17 |
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
18 |
format.js do |
|
19 |
render :update do |page| |
|
20 |
page.replace_html "changeset_list", :partial => 'issues/changeset_list', :locals => { :changesets => @issue.changesets} |
|
21 |
page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets} |
|
22 |
if @changeset.errors.empty? |
|
23 |
page << "$('changeset_revision').value = ''" |
|
24 |
end |
|
25 |
end |
|
26 |
end |
|
27 |
end |
|
28 |
end |
|
29 |
|
|
30 |
def destroy |
|
31 |
changeset = Changeset.find(params[:id]) |
|
32 |
if request.post? && ! changeset.nil? && changeset.issues.include?(@issue) |
|
33 |
changeset.issues.delete(@issue) |
|
34 |
@issue.reload |
|
35 |
end |
|
36 |
respond_to do |format| |
|
37 |
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue } |
|
38 |
format.js do |
|
39 |
render(:update) do |page| |
|
40 |
page.replace_html "changeset_list", :partial => 'issues/changeset_list', :locals => { :changesets => @issue.changesets} |
|
41 |
page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets} |
|
42 |
end |
|
43 |
end |
|
44 |
end |
|
45 |
end |
|
46 | ||
47 | ||
48 |
private |
|
49 |
def find_project |
|
50 |
@issue = Issue.find(params[:issue_id]) |
|
51 |
@project = @issue.project |
|
52 |
rescue ActiveRecord::RecordNotFound |
|
53 |
render_404 |
|
54 |
end |
|
55 |
end |
redmine-stable/app/controllers/issues_controller.rb 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
98 | 98 |
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") |
99 | 99 |
@journals.each_with_index {|j,i| j.indice = i+1} |
100 | 100 |
@journals.reverse! if User.current.wants_comments_in_reverse_order? |
101 |
@changesets = @issue.changesets |
|
102 |
@changesets.reverse! if User.current.wants_comments_in_reverse_order? |
|
101 | 103 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
102 | 104 |
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
103 | 105 |
@priorities = Enumeration::get_values('IPRI') |
redmine-stable/app/helpers/changeset_relations_helper.rb 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
1 |
module ChangesetRelationsHelper |
|
2 |
end |
redmine-stable/app/views/changeset_relations/_form.html.erb 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
1 |
<%= error_messages_for 'changeset' %> |
|
2 | ||
3 |
<p><%= l(:label_revision) %> <%= f.text_field :revision, :size => 6 %> |
|
4 |
<%= submit_tag l(:button_add) %> |
|
5 |
<%= toggle_link l(:button_cancel), 'new-changeset-form'%> |
|
6 |
</p> |
|
7 | ||
8 |
<%= javascript_tag "setPredecessorFieldsVisibility();" %> |
redmine-stable/app/views/issues/_changeset_list.rhtml 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
1 |
<div class="contextual"> |
|
2 |
<% if authorize_for('changeset_relations', 'new') %> |
|
3 |
<%= toggle_link l(:button_add), 'new-changeset-form'%> |
|
4 |
<% end %> |
|
5 |
</div> |
|
6 | ||
7 |
<p><strong><%=l(:label_associated_revisions)%></strong></p> |
|
8 | ||
9 |
<% if changesets.any? %> |
|
10 |
<table style="width:100%"> |
|
11 |
<% changesets.each do |changeset| %> |
|
12 |
<tr> |
|
13 |
<td><%= link_to("#{l(:label_revision)} #{changeset.revision}", |
|
14 |
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %> |
|
15 |
</td> |
|
16 |
<td><%= h changeset.author %></td> |
|
17 |
<td><%= h truncate(changeset.comments.split("\n").first, 60) %></td> |
|
18 |
<td><%= format_date(changeset.committed_on) %></td> |
|
19 |
<td><%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'changeset_relations', :action => 'destroy', :issue_id => @issue, :id => changeset}, |
|
20 |
:method => :post |
|
21 |
}, :title => l(:label_changeset_delete)) if authorize_for('changeset_relations', 'destroy') %> |
|
22 |
</td> |
|
23 |
</tr> |
|
24 |
<% end %> |
|
25 |
</table> |
|
26 |
<% end %> |
|
27 | ||
28 |
<% remote_form_for(:changeset, @changeset, |
|
29 |
:url => {:controller => 'changeset_relations', :action => 'new', :issue_id => @issue}, |
|
30 |
:method => :post, |
|
31 |
:html => {:id => 'new-changeset-form', :style => (@changeset ? '' : 'display: none;')}) do |f| %> |
|
32 |
<%= render :partial => 'changeset_relations/form', :locals => {:f => f}%> |
|
33 |
<% end %> |
redmine-stable/app/views/issues/show.rhtml 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
78 | 78 |
</div> |
79 | 79 |
<% end %> |
80 | 80 | |
81 |
<% if !@project.repository.nil? && (authorize_for('changeset_relations', 'new') || @issue.changesets.any?) %> |
|
82 |
<hr /> |
|
83 |
<div id="changeset_list"> |
|
84 |
<%= render :partial => 'changeset_list', :locals => { :changesets => @issue.changesets} %> |
|
85 |
</div> |
|
86 |
<% end %> |
|
87 | ||
81 | 88 |
<% if User.current.allowed_to?(:add_issue_watchers, @project) || |
82 | 89 |
(@issue.watchers.any? && User.current.allowed_to?(:view_issue_watchers, @project)) %> |
83 | 90 |
<hr /> |
... | ... | |
91 | 98 |
<% if @issue.changesets.any? && User.current.allowed_to?(:view_changesets, @project) %> |
92 | 99 |
<div id="issue-changesets"> |
93 | 100 |
<h3><%=l(:label_associated_revisions)%></h3> |
101 |
<div id="issue-changesets-list"> |
|
94 | 102 |
<%= render :partial => 'changesets', :locals => { :changesets => @issue.changesets} %> |
95 | 103 |
</div> |
104 |
</div> |
|
96 | 105 |
<% end %> |
97 | 106 | |
98 | 107 |
<% if @journals.any? %> |
redmine-stable/db/migrate/102_add_manage_changeset_relations_permission.rb 2009-09-30 20:10:45.000000000 +0200 | ||
---|---|---|
1 |
class AddManageChangesetRelationsPermission < ActiveRecord::Migration |
|
2 |
def self.up |
|
3 |
Role.find(:all).each do |r| |
|
4 |
r.add_permission!(:manage_changeset_relations) if r.has_permission?(:manage_issue_relations) |
|
5 |
end |
|
6 |
end |
|
7 | ||
8 |
def self.down |
|
9 |
Role.find(:all).each do |r| |
|
10 |
r.remove_permission!(:manage_changeset_relations) |
|
11 |
end |
|
12 |
end |
|
13 |
end |
redmine-stable/lang/en.yml 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
702 | 702 |
enumeration_issue_priorities: Issue priorities |
703 | 703 |
enumeration_doc_categories: Document categories |
704 | 704 |
enumeration_activities: Activities (time tracking) |
705 |
revision_not_found_error: Revision not found at project SCM |
redmine-stable/lib/redmine.rb 2009-09-30 20:10:44.000000000 +0200 | ||
---|---|---|
37 | 37 |
map.permission :add_issues, {:issues => :new} |
38 | 38 |
map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]} |
39 | 39 |
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]} |
40 |
map.permission :manage_changeset_relations, {:changeset_relations => [:new, :destroy]} |
|
40 | 41 |
map.permission :add_issue_notes, {:issues => [:edit, :reply]} |
41 | 42 |
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin |
42 | 43 |
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin |
redmine-stable/test/functional/changeset_relations_controller_test.rb 2009-09-30 20:10:45.000000000 +0200 | ||
---|---|---|
1 |
require 'test_helper' |
|
2 | ||
3 |
class ChangesetRelationsControllerTest < ActionController::TestCase |
|
4 |
# Replace this with your real tests. |
|
5 |
test "the truth" do |
|
6 |
assert true |
|
7 |
end |
|
8 |
end |