Feature #2009 » manual-changeset-relation.patch
| app/controllers/changeset_relations_controller.rb | ||
|---|---|---|
|
class ChangesetRelationsController < ApplicationController
|
||
|
before_filter :find_project, :authorize
|
||
|
|
||
|
def new
|
||
|
@changeset = Changeset.find(:first, :conditions => {:revision => params[:changeset][:revision], :repository_id => @project.repository})
|
||
|
if @changeset.nil?
|
||
|
@changeset = Changeset.new(:revision => params[:changeset][:revision])
|
||
|
@changeset.errors.add l(:revision_not_found_error)
|
||
|
else
|
||
|
@changeset.issues << @issue
|
||
|
@changeset.save if request.post?
|
||
|
end
|
||
|
@issue.reload
|
||
|
respond_to do |format|
|
||
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||
|
format.js do
|
||
|
render :update do |page|
|
||
|
page.replace_html "changeset_list", :partial => 'issues/changeset_list', :locals => { :changesets => @issue.changesets}
|
||
|
page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets}
|
||
|
if @changeset.errors.empty?
|
||
|
page << "$('changeset_revision').value = ''"
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
def destroy
|
||
|
changeset = Changeset.find(params[:id])
|
||
|
if request.post? && ! changeset.nil? && changeset.issues.include?(@issue)
|
||
|
changeset.issues.delete(@issue)
|
||
|
@issue.reload
|
||
|
end
|
||
|
respond_to do |format|
|
||
|
format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
|
||
|
format.js do
|
||
|
render(:update) do |page|
|
||
|
page.replace_html "changeset_list", :partial => 'issues/changeset_list', :locals => { :changesets => @issue.changesets}
|
||
|
page.replace_html "issue-changesets-list", :partial => 'issues/changesets', :locals => { :changesets => @issue.changesets}
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
private
|
||
|
def find_project
|
||
|
@issue = Issue.find(params[:issue_id])
|
||
|
@project = @issue.project
|
||
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
end
|
||
| app/helpers/changeset_relations_helper.rb | ||
|---|---|---|
|
module ChangesetRelationsHelper
|
||
|
end
|
||
| app/views/changeset_relations/_form.html.erb | ||
|---|---|---|
|
<%= error_messages_for 'changeset' %>
|
||
|
<p><%= l(:label_revision) %> <%= f.text_field :revision, :size => 6 %>
|
||
|
<%= submit_tag l(:button_add) %>
|
||
|
<%= toggle_link l(:button_cancel), 'new-changeset-form'%>
|
||
|
</p>
|
||
|
<%= javascript_tag "setPredecessorFieldsVisibility();" %>
|
||
| app/views/issues/_changeset_list.rhtml | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<% if authorize_for('changeset_relations', 'new') %>
|
||
|
<%= toggle_link l(:button_add), 'new-changeset-form'%>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<p><strong><%=l(:label_associated_revisions)%></strong></p>
|
||
|
<% if changesets.any? %>
|
||
|
<table style="width:100%">
|
||
|
<% changesets.each do |changeset| %>
|
||
|
<tr>
|
||
|
<td><%= link_to("#{l(:label_revision)} #{changeset.revision}",
|
||
|
:controller => 'repositories', :action => 'revision', :id => changeset.project, :rev => changeset.revision) %>
|
||
|
</td>
|
||
|
<td><%= h changeset.author %></td>
|
||
|
<td><%= h truncate changeset.comments.split("\n").first, :length => 40 %></td>
|
||
|
<td><%= format_date(changeset.committed_on) %></td>
|
||
|
<td><%= link_to_remote(image_tag('delete.png'), { :url => {:controller => 'changeset_relations', :action => 'destroy', :issue_id => @issue, :id => changeset},
|
||
|
:method => :post
|
||
|
}, :title => l(:label_changeset_delete)) if authorize_for('changeset_relations', 'destroy') %>
|
||
|
</td>
|
||
|
</tr>
|
||
|
<% end %>
|
||
|
</table>
|
||
|
<% end %>
|
||
|
<% remote_form_for(:changeset, @changeset,
|
||
|
:url => {:controller => 'changeset_relations', :action => 'new', :issue_id => @issue},
|
||
|
:method => :post,
|
||
|
:html => {:id => 'new-changeset-form', :style => (@changeset ? '' : 'display: none;')}) do |f| %>
|
||
|
<%= render :partial => 'changeset_relations/form', :locals => {:f => f}%>
|
||
|
<% end %>
|
||
| app/views/issues/show.rhtml | ||
|---|---|---|
|
</div>
|
||
|
<% end %>
|
||
|
<% if !@project.repository.nil? && (authorize_for('changeset_relations', 'new') || @changesets.relations.any?) %>
|
||
|
<hr />
|
||
|
<div id="changeset_list">
|
||
|
<%= render :partial => 'changeset_list', :locals => { :changesets => @changesets} %>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<% if User.current.allowed_to?(:add_issue_watchers, @project) ||
|
||
|
(@issue.watchers.any? && User.current.allowed_to?(:view_issue_watchers, @project)) %>
|
||
|
<hr />
|
||
| ... | ... | |
|
<% if @changesets.any? && User.current.allowed_to?(:view_changesets, @project) %>
|
||
|
<div id="issue-changesets">
|
||
|
<h3><%=l(:label_associated_revisions)%></h3>
|
||
|
<div id="issue-changesets-list">
|
||
|
<%= render :partial => 'changesets', :locals => { :changesets => @changesets} %>
|
||
|
</div>
|
||
|
</div>
|
||
|
<% end %>
|
||
|
<% if @journals.any? %>
|
||
| config/locales/de.yml | ||
|---|---|---|
|
label_view_all_revisions: View all revisions
|
||
|
label_tag: Tag
|
||
|
label_branch: Branch
|
||
|
revision_not_found_error: Revision nicht gefunden im SCM des Projektes
|
||
| config/locales/en.yml | ||
|---|---|---|
|
enumeration_issue_priorities: Issue priorities
|
||
|
enumeration_doc_categories: Document categories
|
||
|
enumeration_activities: Activities (time tracking)
|
||
|
revision_not_found_error: Revision not found at project SCM
|
||
| db/migrate/20090821144826_add_manage_changeset_relations_permission.rb | ||
|---|---|---|
|
class AddManageChangesetRelationsPermission < ActiveRecord::Migration
|
||
|
def self.up
|
||
|
Role.find(:all).each do |r|
|
||
|
r.add_permission!(:manage_changeset_relations) if r.has_permission?(:manage_issue_relations)
|
||
|
end
|
||
|
end
|
||
|
def self.down
|
||
|
Role.find(:all).each do |r|
|
||
|
r.remove_permission!(:manage_changeset_relations)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| lib/redmine.rb | ||
|---|---|---|
|
map.permission :add_issues, {:issues => :new}
|
||
|
map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit]}
|
||
|
map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
|
||
|
map.permission :manage_changeset_relations, {:changeset_relations => [:new, :destroy]}
|
||
|
map.permission :add_issue_notes, {:issues => [:edit, :reply]}
|
||
|
map.permission :edit_issue_notes, {:journals => :edit}, :require => :loggedin
|
||
|
map.permission :edit_own_issue_notes, {:journals => :edit}, :require => :loggedin
|
||
| test/functional/changeset_relations_controller_test.rb | ||
|---|---|---|
|
require 'test_helper'
|
||
|
class ChangesetRelationsControllerTest < ActionController::TestCase
|
||
|
# Replace this with your real tests.
|
||
|
test "the truth" do
|
||
|
assert true
|
||
|
end
|
||
|
end
|
||