issue relations import

git-svn-id: http://redmine.rubyforge.org/svn/branches/work@163 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-01-13 14:27:15 +00:00
parent bc9eb65c98
commit d0a0e46660
7 changed files with 94 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
class IssueRelation < ActiveRecord::Base
belongs_to :issue
belongs_to :issue_to, :class_name => 'Issue', :foreign_key => 'issue_to_id'
TYPES = { "ES" => { :name => :label_rel_end_to_start, :order => 1 },
"EE" => { :name => :label_rel_end_to_end, :order => 2 },
"SS" => { :name => :label_rel_start_to_start, :order => 3 },
"SE" => { :name => :label_rel_start_to_end, :order => 4 }
}.freeze
validates_presence_of :issue, :issue_to, :relation_type, :delay
validates_inclusion_of :relation_type, :in => TYPES.keys
validates_numericality_of :delay, :allow_nil => true
def validate
errors.add :issue_to_id, :activerecord_error_invalid if issue_id == issue_to_id
end
end

View File

@@ -0,0 +1,49 @@
<h2><%= @issue.tracker.name %> #<%= @issue.id %> - <%=h @issue.subject %></h2>
<table class="list">
<thead>
<th></th>
<th>Task</th>
<th>Debut</th>
<th>Fin</th>
<th>Type</th>
<th>Retard</th>
</thead>
<tbody>
<tr><th colspan="6">Predecesseurs</th></tr>
<% @issue.relations_from.each do |relation| %>
<tr class="<%= cycle 'odd', 'even' %>">
<td style="width:20px;"><%= image_tag 'relation_from.png' %></td>
<td><%= relation.issue_id %>: <%= relation.issue.subject %></td>
<td align="center"><%= format_date(relation.issue.start_date) %></td>
<td align="center"><%= format_date(relation.issue.due_date) %></td>
<td align="center"><%= l(IssueRelation::TYPES[relation.relation_type][:name]) %></td>
<td align="center"><%= relation.delay %> jours</td>
</tr>
<% end %>
<tr><th colspan="6">Successeurs</th></tr>
<% @issue.relations_to.each do |relation| %>
<tr class="<%= cycle 'odd', 'even' %>">
<td style="width:20px;"><%= image_tag 'relation_to.png' %></td>
<td><%= relation.issue_to_id %>: <%= relation.issue_to.subject %></td>
<td align="center"><%= format_date(relation.issue_to.start_date) %></td>
<td align="center"><%= format_date(relation.issue_to.due_date) %></td>
<td align="center"><%= l(IssueRelation::TYPES[relation.relation_type][:name]) %></td>
<td align="center"><%= relation.delay %> jours</td>
</tr>
<% end %>
</tbody>
</table>
<br />
<p><strong>Nouveau predecesseur</strong></p>
<% form_for :relation, @relation, :url => { :action => 'add_predecessor', :id => @issue } do |f| %>
<%= error_messages_for 'relation' %>
<p>
<%= f.text_field :issue_id, :required => true %>
<%= f.select :relation_type, relation_types_for_select, :required => true %>
<%= f.text_field :delay, :required => true, :size => 3 %> jours
<%= submit_tag l(:button_add) %>
</p>
<% end %>

View File

@@ -0,0 +1,11 @@
class CreateIssueRelations < ActiveRecord::Migration
def self.up
create_table :issue_relations do |t|
# t.column :name, :string
end
end
def self.down
drop_table :issue_relations
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

View File

@@ -0,0 +1,5 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
first:
id: 1
another:
id: 2

View File

@@ -0,0 +1,10 @@
require File.dirname(__FILE__) + '/../test_helper'
class IssueRelationTest < Test::Unit::TestCase
fixtures :issue_relations
# Replace this with your real tests.
def test_truth
assert true
end
end