diff --git a/app/models/issue.rb b/app/models/issue.rb index 3cd67d017..f8837cb6e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -990,13 +990,9 @@ class Issue < ActiveRecord::Base end def to_s - "#{tracker} ##{id}: #{subject}" + "#{tracker} ##{project_index}: #{subject}" end - # 缺陷在项目中的序号 - def inProjectIndex - (self.project.issues.index(self).to_i + 1).to_s - end # Returns a string of css classes that apply to the issue def css_classes @@ -1160,9 +1156,19 @@ class Issue < ActiveRecord::Base "" << self.project.name.to_s << "#" << project_index end - + def project_index - (self.project.issues.index(self).to_i + 1).to_s + if self.project.issues.include?(self) + (self.project.issues.index(self).to_i + 1).to_s + else + issue_index = 1 + self.project.issues.each do |issue| + if self.id > issue.id + ++issue_index + end + end + issue_index.to_s + end end private diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 09db4de97..25d592a24 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -96,8 +96,9 @@ class Mailer < ActionMailer::Base # issue_add(issue) => Mail::Message object # Mailer.issue_add(issue).deliver => sends an email to issue recipients def issue_add(issue) + issue_id = issue.project_index redmine_headers 'Project' => issue.project.identifier, - 'Issue-Id' => (issue.project.issues.index(issue).to_i + 1).to_s, + 'Issue-Id' => issue_id, 'Issue-Author' => issue.author.login redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to message_id issue @@ -108,7 +109,7 @@ class Mailer < ActionMailer::Base cc = issue.watcher_recipients - recipients mail :to => recipients, :cc => cc, - :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue.id}] (#{issue.status.name}) #{issue.subject}" + :subject => "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" end # Builds a Mail::Message object used to email recipients of the edited issue. diff --git a/app/models/project.rb b/app/models/project.rb index f38ad0dd0..5efaf10ab 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -41,7 +41,7 @@ class Project < ActiveRecord::Base has_many :principals, :through => :member_principals, :source => :principal has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" - has_many :issues, :dependent => :destroy, :include => [:status, :tracker] + has_many :issues, :dependent => :destroy, :include => [:status, :tracker] , :order => "id ASC" has_many :issue_changes, :through => :issues, :source => :journals has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC" has_many :time_entries, :dependent => :delete_all diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 59d6720c7..396082854 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -84,7 +84,7 @@ ! - <%= l :label_update_time %> + <%= l :label_create_time %> : <%= format_time(@course.created_at) %> diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index 3d851d442..f0dc88d8b 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -1,4 +1,4 @@ -

<%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %>

+

<%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %>