From b86a748b1d3a41fa328e4e1f61cdf1acee8137f6 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 4 Jul 2011 19:34:58 +0000 Subject: Adds REST API for versions (#7403). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6180 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/projects/settings/_versions.rhtml | 6 +++--- app/views/versions/index.api.rsb | 18 ++++++++++++++++++ app/views/versions/show.api.rsb | 14 ++++++++++++++ app/views/versions/show.rhtml | 6 +++--- 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 app/views/versions/index.api.rsb create mode 100644 app/views/versions/show.api.rsb (limited to 'app/views') diff --git a/app/views/projects/settings/_versions.rhtml b/app/views/projects/settings/_versions.rhtml index f9a4dd109..f00fe5bd2 100644 --- a/app/views/projects/settings/_versions.rhtml +++ b/app/views/projects/settings/_versions.rhtml @@ -19,9 +19,9 @@ <%=h format_version_sharing(version.sharing) %> <%= link_to_if_authorized(h(version.wiki_page_title), {:controller => 'wiki', :action => 'show', :project_id => version.project, :id => Wiki.titleize(version.wiki_page_title)}) || h(version.wiki_page_title) unless version.wiki_page_title.blank? || version.project.wiki.nil? %> - <% if version.project == @project %> - <%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %> - <%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> + <% if version.project == @project && User.current.allowed_to?(:manage_versions, @project) %> + <%= link_to l(:button_edit), edit_project_version_path(@project, version), :class => 'icon icon-edit' %> + <%= link_to l(:button_delete), project_version_path(@project, version), :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> <% end %> diff --git a/app/views/versions/index.api.rsb b/app/views/versions/index.api.rsb new file mode 100644 index 000000000..cf00e1a75 --- /dev/null +++ b/app/views/versions/index.api.rsb @@ -0,0 +1,18 @@ +api.array :versions, api_meta(:total_count => @versions.size) do + @versions.each do |version| + api.version do + api.id version.id + api.project(:id => version.project_id, :name => version.project.name) unless version.project.nil? + + api.name version.name + api.description version.description + api.status version.status + api.due_date version.effective_date + + render_api_custom_values version.custom_field_values, api + + api.created_on version.created_on + api.updated_on version.updated_on + end + end +end diff --git a/app/views/versions/show.api.rsb b/app/views/versions/show.api.rsb new file mode 100644 index 000000000..e52c52eb1 --- /dev/null +++ b/app/views/versions/show.api.rsb @@ -0,0 +1,14 @@ +api.version do + api.id @version.id + api.project(:id => @version.project_id, :name => @version.project.name) unless @version.project.nil? + + api.name @version.name + api.description @version.description + api.status @version.status + api.due_date @version.effective_date + + render_api_custom_values @version.custom_field_values, api + + api.created_on @version.created_on + api.updated_on @version.updated_on +end diff --git a/app/views/versions/show.rhtml b/app/views/versions/show.rhtml index 5fcdf8b82..72ae80218 100644 --- a/app/views/versions/show.rhtml +++ b/app/views/versions/show.rhtml @@ -1,8 +1,8 @@
-<%= link_to_if_authorized l(:button_edit), {:controller => 'versions', :action => 'edit', :id => @version}, :class => 'icon icon-edit' %> +<%= link_to(l(:button_edit), edit_project_version_path(@version.project, @version), :class => 'icon icon-edit') if User.current.allowed_to?(:manage_versions, @version.project) %> <%= link_to_if_authorized(l(:button_edit_associated_wikipage, :page_title => @version.wiki_page_title), {:controller => 'wiki', :action => 'edit', :project_id => @version.project, :id => Wiki.titleize(@version.wiki_page_title)}, :class => 'icon icon-edit') unless @version.wiki_page_title.blank? || @version.project.wiki.nil? %> -<%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => @version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)}, - :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del' %> +<%= link_to(l(:button_delete), project_version_path(@version.project, @version, :back_url => url_for(:controller => 'versions', :action => 'index', :project_id => @version.project)), + :confirm => l(:text_are_you_sure), :method => :delete, :class => 'icon icon-del') if User.current.allowed_to?(:manage_versions, @version.project) %> <%= call_hook(:view_versions_show_contextual, { :version => @version, :project => @project }) %>
-- cgit v1.2.3