-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding information to patch Redmine for allowing hooks in the API rest
- Loading branch information
rmproyectos
committed
Feb 21, 2021
1 parent
70c1cd6
commit 4f4d04a
Showing
3 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
These files have to be modified in redmineroot/app/views/issues | ||
Or patched. The important line to add is call_hook. | ||
TODO: Prepare a patch to do this automatically when the plugin is installed, or in the docker files. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
api.array :issues, api_meta(:total_count => @issue_count, :offset => @offset, :limit => @limit) do | ||
@issues.each do |issue| | ||
api.issue do | ||
api.id issue.id | ||
api.project(:id => issue.project_id, :name => issue.project.name) unless issue.project.nil? | ||
api.tracker(:id => issue.tracker_id, :name => issue.tracker.name) unless issue.tracker.nil? | ||
api.status(:id => issue.status_id, :name => issue.status.name) unless issue.status.nil? | ||
api.priority(:id => issue.priority_id, :name => issue.priority.name) unless issue.priority.nil? | ||
api.author(:id => issue.author_id, :name => issue.author.name) unless issue.author.nil? | ||
api.assigned_to(:id => issue.assigned_to_id, :name => issue.assigned_to.name) unless issue.assigned_to.nil? | ||
api.category(:id => issue.category_id, :name => issue.category.name) unless issue.category.nil? | ||
api.fixed_version(:id => issue.fixed_version_id, :name => issue.fixed_version.name) unless issue.fixed_version.nil? | ||
api.parent(:id => issue.parent_id) unless issue.parent.nil? | ||
|
||
api.subject issue.subject | ||
api.description issue.description | ||
api.start_date issue.start_date | ||
api.due_date issue.due_date | ||
api.done_ratio issue.done_ratio | ||
api.is_private issue.is_private | ||
api.estimated_hours issue.estimated_hours | ||
|
||
render_api_custom_values issue.visible_custom_field_values, api | ||
|
||
api.created_on issue.created_on | ||
api.updated_on issue.updated_on | ||
api.closed_on issue.closed_on | ||
|
||
api.array :attachments do | ||
issue.attachments.each do |attachment| | ||
render_api_attachment(attachment, api) | ||
end | ||
end if include_in_api_response?('attachments') | ||
|
||
api.array :relations do | ||
issue.relations.each do |relation| | ||
api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay) | ||
end | ||
end if include_in_api_response?('relations') | ||
call_hook(:api_issue_index_hook, {:root_api => api, :issue => issue}) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
api.issue do | ||
api.id @issue.id | ||
api.project(:id => @issue.project_id, :name => @issue.project.name) unless @issue.project.nil? | ||
api.tracker(:id => @issue.tracker_id, :name => @issue.tracker.name) unless @issue.tracker.nil? | ||
api.status(:id => @issue.status_id, :name => @issue.status.name) unless @issue.status.nil? | ||
api.priority(:id => @issue.priority_id, :name => @issue.priority.name) unless @issue.priority.nil? | ||
api.author(:id => @issue.author_id, :name => @issue.author.name) unless @issue.author.nil? | ||
api.assigned_to(:id => @issue.assigned_to_id, :name => @issue.assigned_to.name) unless @issue.assigned_to.nil? | ||
api.category(:id => @issue.category_id, :name => @issue.category.name) unless @issue.category.nil? | ||
api.fixed_version(:id => @issue.fixed_version_id, :name => @issue.fixed_version.name) unless @issue.fixed_version.nil? | ||
api.parent(:id => @issue.parent_id) unless @issue.parent.nil? | ||
|
||
api.subject @issue.subject | ||
api.description @issue.description | ||
api.start_date @issue.start_date | ||
api.due_date @issue.due_date | ||
api.done_ratio @issue.done_ratio | ||
api.is_private @issue.is_private | ||
api.estimated_hours @issue.estimated_hours | ||
api.total_estimated_hours @issue.total_estimated_hours | ||
if User.current.allowed_to?(:view_time_entries, @project) | ||
api.spent_hours(@issue.spent_hours) | ||
api.total_spent_hours(@issue.total_spent_hours) | ||
end | ||
|
||
render_api_custom_values @issue.visible_custom_field_values, api | ||
|
||
api.created_on @issue.created_on | ||
api.updated_on @issue.updated_on | ||
api.closed_on @issue.closed_on | ||
|
||
render_api_issue_children(@issue, api) if include_in_api_response?('children') | ||
|
||
api.array :attachments do | ||
@issue.attachments.each do |attachment| | ||
render_api_attachment(attachment, api) | ||
end | ||
end if include_in_api_response?('attachments') | ||
|
||
api.array :relations do | ||
@relations.each do |relation| | ||
api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay) | ||
end | ||
end if include_in_api_response?('relations') && @relations.present? | ||
|
||
api.array :changesets do | ||
@changesets.each do |changeset| | ||
api.changeset :revision => changeset.revision do | ||
api.user(:id => changeset.user_id, :name => changeset.user.name) unless changeset.user.nil? | ||
api.comments changeset.comments | ||
api.committed_on changeset.committed_on | ||
end | ||
end | ||
end if include_in_api_response?('changesets') | ||
|
||
api.array :journals do | ||
@journals.each do |journal| | ||
api.journal :id => journal.id do | ||
api.user(:id => journal.user_id, :name => journal.user.name) unless journal.user.nil? | ||
api.notes journal.notes | ||
api.created_on journal.created_on | ||
api.private_notes journal.private_notes | ||
api.array :details do | ||
journal.visible_details.each do |detail| | ||
api.detail :property => detail.property, :name => detail.prop_key do | ||
api.old_value detail.old_value | ||
api.new_value detail.value | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end if include_in_api_response?('journals') | ||
|
||
api.array :watchers do | ||
@issue.watcher_users.each do |user| | ||
api.user :id => user.id, :name => user.name | ||
end | ||
end if include_in_api_response?('watchers') && User.current.allowed_to?(:view_issue_watchers, @issue.project) | ||
|
||
call_hook(:api_issue_show_hook, {:root_api => api, :issue => @issue}) | ||
|
||
end |