Feature #2048 » changeset_journals_v1.diff
| app/models/journal_observer.rb (working copy) | ||
|---|---|---|
| 17 | 17 | |
| 18 | 18 |
class JournalObserver < ActiveRecord::Observer |
| 19 | 19 |
def after_create(journal) |
| 20 |
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
|
| 20 |
case(journal.journalized_type) |
|
| 21 |
when 'Issue': |
|
| 22 |
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
|
|
| 23 |
when 'ChangeSet': |
|
| 24 |
# notifty revision commiter |
|
| 25 |
Mailer.deliver_changeset_comment(journal) if Setting.notified_events.include?('revision_comment_added')
|
|
| 26 |
end |
|
| 21 | 27 |
end |
| 22 | 28 |
end |
| app/models/mailer.rb (working copy) | ||
|---|---|---|
| 72 | 72 |
:journal => journal, |
| 73 | 73 |
:issue_url => url_for(:controller => 'issues', :action => 'show', :id => issue) |
| 74 | 74 |
end |
| 75 |
|
|
| 76 |
def changeset_comment(journal) |
|
| 77 |
changeset = journal.journalized.reload |
|
| 78 |
redmine_headers 'Project' => changeset.repository.project.identifier, |
|
| 79 |
'Revision' => changeset.revision |
|
| 80 |
message_id journal |
|
| 81 |
references changeset |
|
| 82 |
@author = journal.user |
|
| 83 |
recipients changeset.recipients |
|
| 84 |
subject "[#{changeset.repository.project.name}] #{l(:label_revision)} #{changeset.revision}"
|
|
| 85 |
body :changeset => changeset, |
|
| 86 |
:journal => journal, |
|
| 87 |
:changeset_url => url_for(:controller => 'projects') + "/#{changeset.repository.project.identifier}/repository/revisions/#{changeset.revision}"
|
|
| 88 |
end |
|
| 75 | 89 | |
| 76 | 90 |
def reminder(user, issues, days) |
| 77 | 91 |
set_language_if_valid user.language |
| app/models/changeset.rb (working copy) | ||
|---|---|---|
| 21 | 21 |
belongs_to :repository |
| 22 | 22 |
belongs_to :user |
| 23 | 23 |
has_many :changes, :dependent => :delete_all |
| 24 |
has_many :journals, :as => :journalized, :dependent => :destroy |
|
| 24 | 25 |
has_and_belongs_to_many :issues |
| 25 | 26 | |
| 26 | 27 |
acts_as_event :title => Proc.new {|o| "#{l(:label_revision)} #{o.revision}" + (o.short_comments.blank? ? '' : (': ' + o.short_comments))},
|
| ... | ... | |
| 146 | 147 |
to_utf8(str.to_s.strip) |
| 147 | 148 |
end |
| 148 | 149 |
|
| 150 |
# Returns the mail adresses of users that should be notified for the changeset |
|
| 151 |
# Includes: project recipients, the revision commiter, and other users who have commented |
|
| 152 |
def recipients |
|
| 153 |
recipients = repository.project.recipients |
|
| 154 |
recipients << user.mail if user && user.active? # committer |
|
| 155 |
recipients << journals.collect { |j| j.user.mail if j.user } # other commenters
|
|
| 156 |
recipients.compact.uniq |
|
| 157 |
end |
|
| 158 |
|
|
| 159 |
def created_on |
|
| 160 |
self.committed_on |
|
| 161 |
end |
|
| 162 |
|
|
| 149 | 163 |
private |
| 150 | 164 | |
| 151 | 165 |
def split_comments |
| app/controllers/repositories_controller.rb (working copy) | ||
|---|---|---|
| 137 | 137 |
def revision |
| 138 | 138 |
@changeset = @repository.changesets.find_by_revision(@rev) |
| 139 | 139 |
raise ChangesetNotFound unless @changeset |
| 140 |
@journal = @changeset.journals.new |
|
| 140 | 141 | |
| 142 |
@journals = @changeset.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
|
| 143 |
@journals.each_with_index {|j,i| j.indice = i+1}
|
|
| 144 |
@journals.reverse! if User.current.wants_comments_in_reverse_order? |
|
| 145 | ||
| 141 | 146 |
respond_to do |format| |
| 142 | 147 |
format.html |
| 143 | 148 |
format.js {render :layout => false}
|
| ... | ... | |
| 146 | 151 |
show_error_not_found |
| 147 | 152 |
end |
| 148 | 153 |
|
| 154 |
def add_journal |
|
| 155 |
@changeset = @repository.changesets.find_by_revision(@rev) |
|
| 156 |
@journal = @changeset.journals.new(params[:journal]) |
|
| 157 |
@journal.user = User.current |
|
| 158 |
|
|
| 159 |
respond_to do |format| |
|
| 160 |
if @journal.save |
|
| 161 |
format.html { redirect_to :action => :revision }
|
|
| 162 |
else |
|
| 163 |
format.html { redirect_to :action => :revision }
|
|
| 164 |
end |
|
| 165 |
end |
|
| 166 |
end |
|
| 167 |
|
|
| 149 | 168 |
def diff |
| 150 | 169 |
if params[:format] == 'diff' |
| 151 | 170 |
@diff = @repository.diff(@path, @rev, @rev_to) |
| app/views/mailer/changeset_comment.text.plain.rhtml (revision 0) | ||
|---|---|---|
| 1 |
<%= l(:text_changeset_commented, :rev => "##{@changeset.revision}", :author => @journal.user) %>
|
|
| 2 | ||
| 3 |
<%= @journal.notes %> |
|
| 4 | ||
| 5 |
<%= @changeset_url %> |
|
| app/views/mailer/changeset_comment.text.html.rhtml (revision 0) | ||
|---|---|---|
| 1 |
<%= l(:text_changeset_commented, :rev => "##{@changeset.revision}", :author => @journal.user) %>
|
|
| 2 | ||
| 3 |
<%= textilizable(@journal, :notes, :only_path => false) %> |
|
| 4 | ||
| 5 |
<h1><%= link_to "#{@changeset.revision}", @changeset_url %></h1>
|
|
| app/views/repositories/revision.rhtml (working copy) | ||
|---|---|---|
| 26 | 26 | |
| 27 | 27 |
<%= textilizable @changeset.comments %> |
| 28 | 28 | |
| 29 |
<h3><%= l(:label_revision_comments) %></h3> |
|
| 30 | ||
| 31 |
<% for journal in @journals %> |
|
| 32 |
<div id="change-<%= journal.id %>" class="journal"> |
|
| 33 |
<h4><div style="float:right;"><%= link_to "##{journal.indice}", :anchor => "note-#{journal.indice}" %></div>
|
|
| 34 |
<%= content_tag('a', '', :name => "note-#{journal.indice}")%>
|
|
| 35 |
<%= authoring journal.created_on, journal.user, :label => :label_comment_added_time_by %></h4> |
|
| 36 |
<%= avatar(journal.user, :size => "32") %> |
|
| 37 |
<%= textilizable journal.notes %> |
|
| 38 |
</div> |
|
| 39 |
<%#= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
|
|
| 40 |
<% end %> |
|
| 41 | ||
| 42 |
<div class="box"> |
|
| 43 |
<fieldset><legend><%= l(:label_comment_add) %></legend> |
|
| 44 |
<% form_for :journal, @journal, :url => {:action => 'add_journal', :id => @project, :rev => @rev} do |f| %>
|
|
| 45 |
<%= f.text_area :notes, :cols => 60, :rows => 5, :class => 'wiki-edit' %><br /> |
|
| 46 |
<%= f.submit l(:label_comment) %> |
|
| 47 |
<% end %> |
|
| 48 |
</fieldset> |
|
| 49 |
</div> |
|
| 50 | ||
| 51 | ||
| 29 | 52 |
<% if @changeset.issues.any? %> |
| 30 | 53 |
<h3><%= l(:label_related_issues) %></h3> |
| 31 | 54 |
<ul> |
| config/settings.yml (working copy) | ||
|---|---|---|
| 114 | 114 |
default: |
| 115 | 115 |
- issue_added |
| 116 | 116 |
- issue_updated |
| 117 |
- revision_comment_added |
|
| 117 | 118 |
mail_handler_api_enabled: |
| 118 | 119 |
default: 0 |
| 119 | 120 |
mail_handler_api_key: |
| config/locales/en.yml (working copy) | ||
|---|---|---|
| 545 | 545 |
label_modification_plural: "{{count}} changes"
|
| 546 | 546 |
label_revision: Revision |
| 547 | 547 |
label_revision_plural: Revisions |
| 548 |
label_revision_comments: Revision Comments |
|
| 549 |
label_revision_comment_add: Comment on this Revision |
|
| 548 | 550 |
label_associated_revisions: Associated revisions |
| 549 | 551 |
label_added: added |
| 550 | 552 |
label_modified: modified |
| ... | ... | |
| 635 | 637 |
label_module_plural: Modules |
| 636 | 638 |
label_added_time_by: "Added by {{author}} {{age}} ago"
|
| 637 | 639 |
label_updated_time_by: "Updated by {{author}} {{age}} ago"
|
| 640 |
label_comment_added_time_by: "Comment added by {{author}} {{age}} ago"
|
|
| 638 | 641 |
label_updated_time: "Updated {{value}} ago"
|
| 639 | 642 |
label_jump_to_a_project: Jump to a project... |
| 640 | 643 |
label_file_plural: Files |
| ... | ... | |
| 746 | 749 |
text_issues_ref_in_commit_messages: Referencing and fixing issues in commit messages |
| 747 | 750 |
text_issue_added: "Issue {{id}} has been reported by {{author}}."
|
| 748 | 751 |
text_issue_updated: "Issue {{id}} has been updated by {{author}}."
|
| 752 |
text_changeset_commented: "Revision {{rev}} has been commented on by {{author}}."
|
|
| 749 | 753 |
text_wiki_destroy_confirmation: Are you sure you want to delete this wiki and all its content ? |
| 750 | 754 |
text_issue_category_destroy_question: "Some issues ({{count}}) are assigned to this category. What do you want to do ?"
|
| 751 | 755 |
text_issue_category_destroy_assignments: Remove category assignments |
| config/routes.rb (working copy) | ||
|---|---|---|
| 222 | 222 |
repository_views.connect 'projects/:id/repository/:action/*path' |
| 223 | 223 |
end |
| 224 | 224 |
|
| 225 |
repositories.connect 'projects/:id/repository/revisions/:rev/add_journal', :action => 'add_journal', :conditions => {:method => :post}
|
|
| 225 | 226 |
repositories.connect 'projects/:id/repository/:action', :conditions => {:method => :post}
|
| 226 | 227 |
end |
| 227 | 228 |
|
| config/environments/development.rb (working copy) | ||
|---|---|---|
| 13 | 13 |
config.action_controller.perform_caching = false |
| 14 | 14 | |
| 15 | 15 |
# Don't care if the mailer can't send |
| 16 |
config.action_mailer.raise_delivery_errors = false |
|
| 16 |
config.action_mailer.raise_delivery_errors = true |
|
| lib/redmine.rb (working copy) | ||
|---|---|---|
| 91 | 91 |
map.project_module :repository do |map| |
| 92 | 92 |
map.permission :manage_repository, {:repositories => [:edit, :committers, :destroy]}, :require => :member
|
| 93 | 93 |
map.permission :browse_repository, :repositories => [:show, :browse, :entry, :annotate, :changes, :diff, :stats, :graph] |
| 94 |
map.permission :view_changesets, :repositories => [:show, :revisions, :revision] |
|
| 94 |
map.permission :view_changesets, :repositories => [:show, :revisions, :revision, :add_journal]
|
|
| 95 | 95 |
map.permission :commit_access, {}
|
| 96 | 96 |
end |
| 97 | 97 | |