Defect #6136 ยป issue_serialization_patch.diff
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
rescue ActiveRecord::RecordNotFound
|
||
|
render_404
|
||
|
end
|
||
|
|
||
|
def show
|
||
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
|
||
|
@journals.each_with_index {|j,i| j.indice = i+1}
|
||
| ... | ... | |
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
|
||
|
@priorities = IssuePriority.all
|
||
|
@time_entry = TimeEntry.new
|
||
|
respond_to do |format|
|
||
|
format.html { render :template => 'issues/show.rhtml' }
|
||
|
format.xml { render :layout => false }
|
||
|
format.xml { render :text => @issue.to_xml, :layout => false }
|
||
|
format.json { render :text => @issue.to_json, :layout => false }
|
||
|
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
|
||
|
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
|
||
| app/models/issue.rb | ||
|---|---|---|
|
end
|
||
|
projects
|
||
|
end
|
||
|
def to_xml
|
||
|
xml = Builder::XmlMarkup.new
|
||
|
xml.instruct!
|
||
|
xml.issue do
|
||
|
xml.id id
|
||
|
xml.project(:id => project_id, :name => project.name) unless project.nil?
|
||
|
xml.tracker(:id => tracker_id, :name => tracker.name) unless tracker.nil?
|
||
|
xml.status(:id => status_id, :name => status.name) unless status.nil?
|
||
|
xml.priority(:id => priority_id, :name => priority.name) unless priority.nil?
|
||
|
xml.author(:id => author_id, :name => author.name) unless author.nil?
|
||
|
xml.assigned_to(:id => assigned_to_id, :name => assigned_to.name) unless assigned_to.nil?
|
||
|
xml.category(:id => category_id, :name => category.name) unless category.nil?
|
||
|
xml.fixed_version(:id => fixed_version_id, :name => fixed_version.name) unless fixed_version.nil?
|
||
|
xml.parent(:id => parent_id) unless parent.nil?
|
||
|
|
||
|
xml.subject subject
|
||
|
xml.description description
|
||
|
xml.start_date start_date
|
||
|
xml.due_date due_date
|
||
|
xml.done_ratio done_ratio
|
||
|
xml.estimated_hours estimated_hours
|
||
|
if User.current.allowed_to?(:view_time_entries, project)
|
||
|
xml.spent_hours spent_hours
|
||
|
end
|
||
|
|
||
|
xml.custom_fields do
|
||
|
custom_field_values.each do |custom_value|
|
||
|
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
||
|
end
|
||
|
end unless custom_field_values.empty?
|
||
|
|
||
|
xml.created_on created_on
|
||
|
xml.updated_on updated_on
|
||
|
|
||
|
xml.relations do
|
||
|
relations.select {|r| r.other_issue(self).visible? }.each do |relation|
|
||
|
xml.relation(:id => relation.id, :issue_id => relation.other_issue(self).id, :relation_type => relation.relation_type_for(self), :delay => relation.delay)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
xml.changesets do
|
||
|
changesets.each do |changeset|
|
||
|
xml.changeset :revision => changeset.revision do
|
||
|
xml.user(:id => changeset.user_id, :name => changeset.user.name) unless changeset.user.nil?
|
||
|
xml.comments changeset.comments
|
||
|
xml.committed_on changeset.committed_on
|
||
|
end
|
||
|
end
|
||
|
end if User.current.allowed_to?(:view_changesets, project) && changesets.any?
|
||
|
|
||
|
xml.journals do
|
||
|
journals.each do |journal|
|
||
|
xml.journal :id => journal.id do
|
||
|
xml.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
|
||
|
xml.notes journal.notes
|
||
|
xml.details do
|
||
|
journal.details.each do |detail|
|
||
|
xml.detail :property => detail.property, :name => detail.prop_key, :old => detail.old_value, :new => detail.value
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end unless journals.empty?
|
||
|
end
|
||
|
return xml.target!
|
||
|
end
|
||
|
def to_json
|
||
|
Hash.from_xml(to_xml).to_json
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
| app/views/issues/show.xml.builder | ||
|---|---|---|
|
xml.instruct!
|
||
|
xml.issue do
|
||
|
xml.id @issue.id
|
||
|
xml.project(:id => @issue.project_id, :name => @issue.project.name) unless @issue.project.nil?
|
||
|
xml.tracker(:id => @issue.tracker_id, :name => @issue.tracker.name) unless @issue.tracker.nil?
|
||
|
xml.status(:id => @issue.status_id, :name => @issue.status.name) unless @issue.status.nil?
|
||
|
xml.priority(:id => @issue.priority_id, :name => @issue.priority.name) unless @issue.priority.nil?
|
||
|
xml.author(:id => @issue.author_id, :name => @issue.author.name) unless @issue.author.nil?
|
||
|
xml.assigned_to(:id => @issue.assigned_to_id, :name => @issue.assigned_to.name) unless @issue.assigned_to.nil?
|
||
|
xml.category(:id => @issue.category_id, :name => @issue.category.name) unless @issue.category.nil?
|
||
|
xml.fixed_version(:id => @issue.fixed_version_id, :name => @issue.fixed_version.name) unless @issue.fixed_version.nil?
|
||
|
xml.parent(:id => @issue.parent_id) unless @issue.parent.nil?
|
||
|
|
||
|
xml.subject @issue.subject
|
||
|
xml.description @issue.description
|
||
|
xml.start_date @issue.start_date
|
||
|
xml.due_date @issue.due_date
|
||
|
xml.done_ratio @issue.done_ratio
|
||
|
xml.estimated_hours @issue.estimated_hours
|
||
|
if User.current.allowed_to?(:view_time_entries, @project)
|
||
|
xml.spent_hours @issue.spent_hours
|
||
|
end
|
||
|
|
||
|
xml.custom_fields do
|
||
|
@issue.custom_field_values.each do |custom_value|
|
||
|
xml.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
|
||
|
end
|
||
|
end unless @issue.custom_field_values.empty?
|
||
|
|
||
|
xml.created_on @issue.created_on
|
||
|
xml.updated_on @issue.updated_on
|
||
|
|
||
|
xml.relations do
|
||
|
@issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation|
|
||
|
xml.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay)
|
||
|
end
|
||
|
end
|
||
|
|
||
|
xml.changesets do
|
||
|
@issue.changesets.each do |changeset|
|
||
|
xml.changeset :revision => changeset.revision do
|
||
|
xml.user(:id => changeset.user_id, :name => changeset.user.name) unless changeset.user.nil?
|
||
|
xml.comments changeset.comments
|
||
|
xml.committed_on changeset.committed_on
|
||
|
end
|
||
|
end
|
||
|
end if User.current.allowed_to?(:view_changesets, @project) && @issue.changesets.any?
|
||
|
|
||
|
xml.journals do
|
||
|
@issue.journals.each do |journal|
|
||
|
xml.journal :id => journal.id do
|
||
|
xml.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil?
|
||
|
xml.notes journal.notes
|
||
|
xml.details do
|
||
|
journal.details.each do |detail|
|
||
|
xml.detail :property => detail.property, :name => detail.prop_key, :old => detail.old_value, :new => detail.value
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end unless @issue.journals.empty?
|
||
|
end
|
||