1.添加文档

2.邮件中缺陷序号计算机制优化
2.项目、课程动态优化
This commit is contained in:
nwb 2014-07-05 13:31:32 +08:00
parent c927bb6fd6
commit eb15edd5ff
10 changed files with 3671 additions and 16 deletions

View File

@ -990,13 +990,9 @@ class Issue < ActiveRecord::Base
end end
def to_s def to_s
"#{tracker} ##{id}: #{subject}" "#{tracker} ##{project_index}: #{subject}"
end 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 # Returns a string of css classes that apply to the issue
def css_classes def css_classes
@ -1160,9 +1156,19 @@ class Issue < ActiveRecord::Base
"" << self.project.name.to_s << "" << self.project.name.to_s <<
"#" << project_index "#" << project_index
end end
def project_index 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 end
private private

View File

@ -96,8 +96,9 @@ class Mailer < ActionMailer::Base
# issue_add(issue) => Mail::Message object # issue_add(issue) => Mail::Message object
# Mailer.issue_add(issue).deliver => sends an email to issue recipients # Mailer.issue_add(issue).deliver => sends an email to issue recipients
def issue_add(issue) def issue_add(issue)
issue_id = issue.project_index
redmine_headers 'Project' => issue.project.identifier, 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 'Issue-Author' => issue.author.login
redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to redmine_headers 'Issue-Assignee' => issue.assigned_to.login if issue.assigned_to
message_id issue message_id issue
@ -108,7 +109,7 @@ class Mailer < ActionMailer::Base
cc = issue.watcher_recipients - recipients cc = issue.watcher_recipients - recipients
mail :to => recipients, mail :to => recipients,
:cc => cc, :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 end
# Builds a Mail::Message object used to email recipients of the edited issue. # Builds a Mail::Message object used to email recipients of the edited issue.

View File

@ -41,7 +41,7 @@ class Project < ActiveRecord::Base
has_many :principals, :through => :member_principals, :source => :principal has_many :principals, :through => :member_principals, :source => :principal
has_many :enabled_modules, :dependent => :delete_all has_many :enabled_modules, :dependent => :delete_all
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" 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 :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 :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
has_many :time_entries, :dependent => :delete_all has_many :time_entries, :dependent => :delete_all

View File

@ -84,7 +84,7 @@
<strong> !</strong></td> <strong> !</strong></td>
</tr> </tr>
<tr> <tr>
<td class="font_lighter" style="float: right"><%= l :label_update_time %> <td class="font_lighter" style="float: right"><%= l :label_create_time %>
: <%= format_time(@course.created_at) %> : <%= format_time(@course.created_at) %>
</table> </table>
</td> </td>

View File

@ -1,4 +1,4 @@
<h1><%= link_to(h("#{issue.tracker.name} ##{issue.id}: #{issue.subject}"), issue_url) %></h1> <h1><%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %></h1>
<ul> <ul>
<li><%=l(:field_author)%>: <%=h issue.author %></li> <li><%=l(:field_author)%>: <%=h issue.author %></li>

View File

@ -1,4 +1,4 @@
<%= "#{issue.tracker.name} ##{issue.id}: #{issue.subject}" %> <%= "#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}" %>
<%= issue_url %> <%= issue_url %>
* <%=l(:field_author)%>: <%= issue.author %> * <%=l(:field_author)%>: <%= issue.author %>

View File

@ -1,3 +1,3 @@
<%= l(:text_issue_added, :id => "##{@issue.id}", :author => h(@issue.author)) %> <%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => h(@issue.author)) %>
<hr /> <hr />
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> <%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %>

View File

@ -1,4 +1,4 @@
<%= l(:text_issue_added, :id => "##{@issue.id}", :author => @issue.author) %> <%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %>
---------------------------------------- ----------------------------------------
<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> <%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %>

View File

@ -75,7 +75,7 @@
<%= l(:label_user_create_project) %> <%= link_to @project.name %><strong> !</strong></td> <%= l(:label_user_create_project) %> <%= link_to @project.name %><strong> !</strong></td>
</tr> </tr>
<tr> <tr>
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@project.created_on) %> <td class="font_lighter" style="float: right"><%= l :label_create_time %>: <%= format_time(@project.created_on) %>
</table></td> </table></td>
</tr> </tr>
</table> </table>

File diff suppressed because one or more lines are too long