Feature #38951 » Add_history_to_project.patch
| app/controllers/journals_controller.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/controllers/journals_controller.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
end
|
||
|
def diff
|
||
|
@issue = @journal.issue
|
||
|
@journalized = @journal.journalized
|
||
|
if params[:detail_id].present?
|
||
|
@detail = @journal.details.find_by_id(params[:detail_id])
|
||
|
else
|
||
|
@detail = @journal.details.detect {|d| d.property == 'attr' && d.prop_key == 'description'}
|
||
|
end
|
||
|
unless @issue && @detail
|
||
|
unless @journalized && @detail
|
||
|
render_404
|
||
|
return false
|
||
|
end
|
||
|
if @detail.property == 'cf'
|
||
|
unless @detail.custom_field && @detail.custom_field.visible_by?(@issue.project, User.current)
|
||
|
unless @detail.custom_field && @detail.custom_field.visible_by?(@journalized.project, User.current)
|
||
|
raise ::Unauthorized
|
||
|
end
|
||
|
end
|
||
| app/controllers/projects_controller.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/controllers/projects_controller.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
class ProjectsController < ApplicationController
|
||
|
menu_item :overview
|
||
|
menu_item :settings, :only => :settings
|
||
|
menu_item :project_history, :only => :history
|
||
|
menu_item :projects, :only => [:index, :new, :copy, :create]
|
||
|
before_action :find_project,
|
||
| ... | ... | |
|
before_action :authorize,
|
||
|
:except => [:index, :autocomplete, :list, :new, :create, :copy,
|
||
|
:archive, :unarchive,
|
||
|
:destroy]
|
||
|
:destroy, :history]
|
||
|
before_action :authorize_global, :only => [:new, :create]
|
||
|
before_action :require_admin, :only => [:copy, :archive, :unarchive]
|
||
|
accept_rss_auth :index
|
||
| ... | ... | |
|
end
|
||
|
def update
|
||
|
@project.init_journal(User.current)
|
||
|
@project.safe_attributes = params[:project]
|
||
|
if @project.save
|
||
|
respond_to do |format|
|
||
| ... | ... | |
|
@project = nil
|
||
|
end
|
||
|
def history
|
||
|
@journals = @project.visible_journals_with_index
|
||
|
end
|
||
|
private
|
||
|
# Returns the ProjectEntry scope for index
|
||
| app/helpers/journals_helper.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/helpers/journals_helper.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
def render_journal_actions(issue, journal, options={})
|
||
|
links = []
|
||
|
dropbown_links = []
|
||
|
indice = journal.indice || @journal.issue.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
|
||
|
indice = journal.indice || @journal.journalized.visible_journals_with_index.find{|j| j.id == @journal.id}.indice
|
||
|
dropbown_links << copy_object_url_link(issue_url(issue, anchor: "note-#{indice}", only_path: false))
|
||
|
if journal.notes.present?
|
||
| app/models/journal.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/models/journal.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
# added as a quick fix to allow eager loading of the polymorphic association
|
||
|
# since always associated to an issue, for now
|
||
|
belongs_to :issue, :foreign_key => :journalized_id
|
||
|
belongs_to :project, :foreign_key => :journalized_id
|
||
|
belongs_to :user
|
||
|
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all, :inverse_of => :journal
|
||
| app/models/project.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/models/project.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
has_one :repository, lambda {where(:is_default => true)}
|
||
|
has_many :repositories, :dependent => :destroy
|
||
|
has_many :changesets, :through => :repository
|
||
|
has_many :journals, :as => :journalized, :dependent => :destroy, :inverse_of => :journalized
|
||
|
has_one :wiki, :dependent => :destroy
|
||
|
# Custom field for the project issues
|
||
|
has_and_belongs_to_many :issue_custom_fields,
|
||
| ... | ... | |
|
:if => proc {|project| project.saved_change_to_inherit_members?}
|
||
|
after_save :remove_inherited_member_roles, :add_inherited_member_roles,
|
||
|
:if => proc {|project| project.saved_change_to_parent_id?}
|
||
|
after_save :create_journal
|
||
|
after_update :update_versions_from_hierarchy_change,
|
||
|
:if => proc {|project| project.saved_change_to_parent_id?}
|
||
|
before_destroy :delete_all_members
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
# Returns the journals that are visible to user with their index
|
||
|
# Used to display the issue history
|
||
|
def visible_journals_with_index(user=User.current)
|
||
|
result = journals.
|
||
|
preload(:details).
|
||
|
preload(:user => :email_address).
|
||
|
reorder(:created_on, :id).to_a
|
||
|
result.each_with_index {|j, i| j.indice = i + 1}
|
||
|
unless user.allowed_to?(:view_private_notes, project)
|
||
|
result.select! do |journal|
|
||
|
!journal.private_notes? || journal.user == user
|
||
|
end
|
||
|
end
|
||
|
Journal.preload_journals_details_custom_fields(result)
|
||
|
result.select! {|journal| journal.notes? || journal.visible_details.any?}
|
||
|
result
|
||
|
end
|
||
|
def init_journal(user, notes = "")
|
||
|
@current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes)
|
||
|
end
|
||
|
# Returns the current journal or nil if it's not initialized
|
||
|
def current_journal
|
||
|
@current_journal
|
||
|
end
|
||
|
# Returns the names of attributes that are journalized when updating the issue
|
||
|
def journalized_attribute_names
|
||
|
names = Project.column_names - %w(id lft rgt created_on updated_on closed_on)
|
||
|
names
|
||
|
end
|
||
|
private
|
||
|
def update_inherited_members
|
||
| ... | ... | |
|
end
|
||
|
update_attribute :status, STATUS_ARCHIVED
|
||
|
end
|
||
|
# Saves the changes in a Journal
|
||
|
# Called after_save
|
||
|
def create_journal
|
||
|
if current_journal
|
||
|
current_journal.save
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/views/journals/diff.html.erb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → app/views/journals/diff.html.erb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
<h2><%= @issue.tracker %> #<%= @issue.id %></h2>
|
||
|
<h2><%= link_to @journalized %></h2>
|
||
|
<p><%= authoring @journal.created_on, @journal.user, :label => :label_updated_time_by %></p>
|
||
|
<pre class="text-diff"><%= @diff.to_html %></pre>
|
||
|
<p>
|
||
|
<%= link_to(l(:button_back), issue_path(@issue),
|
||
|
<%= link_to(l(:button_back), '#',
|
||
|
:onclick => 'if (document.referrer != "") {history.back(); return false;}') %>
|
||
|
</p>
|
||
|
<% html_title "#{@issue.tracker.name} ##{@issue.id}: #{@issue.subject}" %>
|
||
|
<% html_title @journalized %>
|
||
| /dev/null (revision 41653+:c704208ed465+) → app/views/projects/history.html.erb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
<% for journal in @journals %>
|
||
|
<div id="change-<%= journal.id %>" class="<%= journal.css_classes %>">
|
||
|
<div id="note-<%= journal.indice %>">
|
||
|
<div class="contextual">
|
||
|
<a href="#note-<%= journal.indice %>" class="journal-link">#<%= journal.indice %></a>
|
||
|
</div>
|
||
|
<h4 class='note-header'>
|
||
|
<%= avatar(journal.user) %>
|
||
|
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %>
|
||
|
</h4>
|
||
|
<% if journal.details.any? %>
|
||
|
<ul class="details">
|
||
|
<% details_to_strings(journal.visible_details).each do |string| %>
|
||
|
<li><%= string %></li>
|
||
|
<% end %>
|
||
|
</ul>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
</div>
|
||
|
<%= call_hook(:view_project_history_journal_bottom, { :journal => journal }) %>
|
||
|
<% end %>
|
||
| config/locales/en.yml (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → config/locales/en.yml (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
label_project: Project
|
||
|
label_project_new: New project
|
||
|
label_project_plural: Projects
|
||
|
label_project_history: History
|
||
|
label_x_projects:
|
||
|
zero: no projects
|
||
|
one: 1 project
|
||
| config/locales/fa.yml (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → config/locales/fa.yml (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
label_project: پروژه
|
||
|
label_project_new: پروژه جدید
|
||
|
label_project_plural: پروژهها
|
||
|
label_project_history: سابقه پروژه
|
||
|
label_x_projects:
|
||
|
zero: بدون پروژه
|
||
|
one: "۱ پروژه"
|
||
| config/routes.rb (revision 41653:c704208ed465fcb5f84cbfa7b6d4050e229d081b) → config/routes.rb (revision 41653+:c704208ed465+) | ||
|---|---|---|
|
get 'projects/:id/activity', :to => 'activities#index', :as => :project_activity
|
||
|
get 'activity', :to => 'activities#index'
|
||
|
get 'projects/:id/history', :to => 'projects#history', :as => :project_history
|
||
|
# repositories routes
|
||
|
get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
|
||
|
get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
|
||