]> source.dussan.org Git - redmine.git/commitdiff
Adds a pseudo format to api template names and overrides ActionController#default_tem...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 Dec 2010 17:43:39 +0000 (17:43 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 4 Dec 2010 17:43:39 +0000 (17:43 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4466 e93f8b46-1217-0410-a6f0-8f06a7374b81

22 files changed:
app/controllers/application_controller.rb
app/controllers/issues_controller.rb
app/controllers/projects_controller.rb
app/controllers/timelog_controller.rb
app/controllers/users_controller.rb
app/views/issues/index.api.rsb [new file with mode: 0644]
app/views/issues/index.apit [deleted file]
app/views/issues/show.api.rsb [new file with mode: 0644]
app/views/issues/show.apit [deleted file]
app/views/projects/index.api.rsb [new file with mode: 0644]
app/views/projects/index.apit [deleted file]
app/views/projects/show.api.rsb [new file with mode: 0644]
app/views/projects/show.apit [deleted file]
app/views/timelog/index.api.rsb [new file with mode: 0644]
app/views/timelog/index.apit [deleted file]
app/views/timelog/show.api.rsb [new file with mode: 0644]
app/views/timelog/show.apit [deleted file]
app/views/users/index.api.rsb [new file with mode: 0644]
app/views/users/index.apit [deleted file]
app/views/users/show.api.rsb [new file with mode: 0644]
app/views/users/show.apit [deleted file]
lib/redmine.rb

index d5241ff8979a725acd655dd7187c1f91d260f7b5..cb6c1a06f96a9998a85cecc9ad2a31d20694f891 100644 (file)
@@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
   include Redmine::I18n
 
   layout 'base'
-  exempt_from_layout 'builder', 'apit'
+  exempt_from_layout 'builder', 'rsb'
   
   # Remove broken cookie after upgrade from 0.8.x (#4292)
   # See https://rails.lighthouseapp.com/projects/8994/tickets/3360
@@ -426,4 +426,24 @@ class ApplicationController < ActionController::Base
     )
     render options
   end
+  
+  # Overrides #default_template so that the api template
+  # is used automatically if it exists
+  def default_template(action_name = self.action_name)
+    if api_request?
+      begin
+        return self.view_paths.find_template(default_template_name(action_name), 'api')
+      rescue ::ActionView::MissingTemplate
+        # the api template was not found
+        # fallback to the default behaviour
+      end
+    end
+    super
+  end
+  
+  # Overrides #pick_layout so that #render with no arguments
+  # doesn't use the layout for api requests
+  def pick_layout(*args)
+    api_request? ? nil : super
+  end
 end
index 79b831ca62578e884aa01ee99148e0d33d1ba628..b0c41ff29d27e6e62ab4ec73adc56d92957e02ef 100644 (file)
@@ -84,7 +84,7 @@ class IssuesController < ApplicationController
       
       respond_to do |format|
         format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
-        format.api  { render :template => 'issues/index.apit' }
+        format.api
         format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
         format.csv  { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
         format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
@@ -109,7 +109,7 @@ class IssuesController < ApplicationController
     @time_entry = TimeEntry.new
     respond_to do |format|
       format.html { render :template => 'issues/show.rhtml' }
-      format.api  { render :template => 'issues/show.apit' }
+      format.api
       format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
       format.pdf  { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
     end
@@ -136,7 +136,7 @@ class IssuesController < ApplicationController
           redirect_to(params[:continue] ?  { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
                       { :action => 'show', :id => @issue })
         }
-        format.api  { render :template => 'issues/show.apit', :status => :created, :location => issue_url(@issue) }
+        format.api  { render :action => 'show', :status => :created, :location => issue_url(@issue) }
       end
       return
     else
index 8ec947258a920a384c046342e5188785da4d9cf4..1c982ac22f83eb40195ff041e6b0ad080a1773ed 100644 (file)
@@ -54,7 +54,6 @@ class ProjectsController < ApplicationController
       }
       format.api  {
         @projects = Project.visible.find(:all, :order => 'lft')
-        render :template => 'projects/index.apit'
       }
       format.atom {
         projects = Project.visible.find(:all, :order => 'created_on DESC',
@@ -89,7 +88,7 @@ class ProjectsController < ApplicationController
           flash[:notice] = l(:notice_successful_create)
           redirect_to :controller => 'projects', :action => 'settings', :id => @project
         }
-        format.api  { render :template => 'projects/show.apit', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
+        format.api  { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
       end
     else
       respond_to do |format|
@@ -165,7 +164,7 @@ class ProjectsController < ApplicationController
     
     respond_to do |format|
       format.html
-      format.api { render :template => 'projects/show.apit'}
+      format.api
     end
   end
 
index 78d31490db5ef93871f428fd5d14b46a00b2b0cf..300b28f114048730205f376d25d0f0e24c16dce2 100644 (file)
@@ -76,8 +76,6 @@ class TimelogController < ApplicationController
                                     :order => sort_clause,
                                     :limit  =>  @entry_pages.items_per_page,
                                     :offset =>  @entry_pages.current.offset)
-          
-          render :template => 'timelog/index.apit'
         }
         format.atom {
           entries = TimeEntry.find(:all,
@@ -103,7 +101,7 @@ class TimelogController < ApplicationController
     respond_to do |format|
       # TODO: Implement html response
       format.html { render :nothing => true, :status => 406 }
-      format.api  { render :template => 'timelog/show.apit' }
+      format.api
     end
   end
 
@@ -128,7 +126,7 @@ class TimelogController < ApplicationController
           flash[:notice] = l(:notice_successful_update)
           redirect_back_or_default :action => 'index', :project_id => @time_entry.project
         }
-        format.api  { render :template => 'timelog/show.apit', :status => :created, :location => time_entry_url(@time_entry) }
+        format.api  { render :action => 'show', :status => :created, :location => time_entry_url(@time_entry) }
       end
     else
       respond_to do |format|
index 5d80c2937878d72ef87cfb4b3bfe05a957f1ff62..131e6b12f80408ddb15d6d91592688af7c76332e 100644 (file)
@@ -49,7 +49,7 @@ class UsersController < ApplicationController
 
                respond_to do |format|
                  format.html { render :layout => !request.xhr? }
-      format.api  { render :template => 'users/index.apit' }
+      format.api
                end     
   end
   
@@ -71,7 +71,7 @@ class UsersController < ApplicationController
     
     respond_to do |format|
       format.html { render :layout => 'base' }
-      format.api  { render :template => 'users/show.apit' }
+      format.api
     end
   rescue ActiveRecord::RecordNotFound
     render_404
@@ -114,7 +114,7 @@ class UsersController < ApplicationController
             {:controller => 'users', :action => 'edit', :id => @user}
           )
         }
-        format.api  { render :template => 'users/show.apit', :status => :created, :location => user_url(@user) }
+        format.api  { render :action => 'show', :status => :created, :location => user_url(@user) }
       end
     else
       @auth_sources = AuthSource.find(:all)
diff --git a/app/views/issues/index.api.rsb b/app/views/issues/index.api.rsb
new file mode 100644 (file)
index 0000000..a63b07a
--- /dev/null
@@ -0,0 +1,32 @@
+api.array :issues 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.estimated_hours issue.estimated_hours
+      
+      api.array :custom_fields do
+       issue.custom_field_values.each do |custom_value|
+               api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
+       end
+      end
+      
+      api.created_on issue.created_on
+      api.updated_on issue.updated_on
+    end
+  end
+end
diff --git a/app/views/issues/index.apit b/app/views/issues/index.apit
deleted file mode 100644 (file)
index a63b07a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-api.array :issues 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.estimated_hours issue.estimated_hours
-      
-      api.array :custom_fields do
-       issue.custom_field_values.each do |custom_value|
-               api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
-       end
-      end
-      
-      api.created_on issue.created_on
-      api.updated_on issue.updated_on
-    end
-  end
-end
diff --git a/app/views/issues/show.api.rsb b/app/views/issues/show.api.rsb
new file mode 100644 (file)
index 0000000..001cabe
--- /dev/null
@@ -0,0 +1,63 @@
+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.estimated_hours @issue.estimated_hours
+  if User.current.allowed_to?(:view_time_entries, @project)
+       api.spent_hours         @issue.spent_hours
+       end
+  
+  api.array :custom_fields do
+       @issue.custom_field_values.each do |custom_value|
+               api.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?
+  
+  api.created_on @issue.created_on
+  api.updated_on @issue.updated_on
+  
+  render_api_issue_children(@issue, api)
+  
+  api.array :relations do
+       @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation|
+               api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay)
+       end
+  end
+  
+  api.array :changesets do
+       @issue.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 User.current.allowed_to?(:view_changesets, @project) && @issue.changesets.any?
+  
+  api.array :journals do
+       @issue.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.array :details do
+                               journal.details.each do |detail|
+                                       api.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
diff --git a/app/views/issues/show.apit b/app/views/issues/show.apit
deleted file mode 100644 (file)
index 001cabe..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-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.estimated_hours @issue.estimated_hours
-  if User.current.allowed_to?(:view_time_entries, @project)
-       api.spent_hours         @issue.spent_hours
-       end
-  
-  api.array :custom_fields do
-       @issue.custom_field_values.each do |custom_value|
-               api.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?
-  
-  api.created_on @issue.created_on
-  api.updated_on @issue.updated_on
-  
-  render_api_issue_children(@issue, api)
-  
-  api.array :relations do
-       @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation|
-               api.relation(:id => relation.id, :issue_id => relation.other_issue(@issue).id, :relation_type => relation.relation_type_for(@issue), :delay => relation.delay)
-       end
-  end
-  
-  api.array :changesets do
-       @issue.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 User.current.allowed_to?(:view_changesets, @project) && @issue.changesets.any?
-  
-  api.array :journals do
-       @issue.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.array :details do
-                               journal.details.each do |detail|
-                                       api.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
diff --git a/app/views/projects/index.api.rsb b/app/views/projects/index.api.rsb
new file mode 100644 (file)
index 0000000..e65477a
--- /dev/null
@@ -0,0 +1,18 @@
+api.array :projects do
+  @projects.each do |project|
+    api.project do
+      api.id          project.id
+      api.name        project.name
+      api.identifier  project.identifier
+      api.description project.description
+      api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
+      api.array :custom_fields do
+        project.visible_custom_field_values.each do |custom_value|
+          api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
+        end
+      end unless project.custom_field_values.empty?
+      api.created_on  project.created_on
+      api.updated_on  project.updated_on
+    end
+  end
+end
diff --git a/app/views/projects/index.apit b/app/views/projects/index.apit
deleted file mode 100644 (file)
index e65477a..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-api.array :projects do
-  @projects.each do |project|
-    api.project do
-      api.id          project.id
-      api.name        project.name
-      api.identifier  project.identifier
-      api.description project.description
-      api.parent(:id => project.parent_id, :name => project.parent.name) unless project.parent.nil?
-      api.array :custom_fields do
-        project.visible_custom_field_values.each do |custom_value|
-          api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
-        end
-      end unless project.custom_field_values.empty?
-      api.created_on  project.created_on
-      api.updated_on  project.updated_on
-    end
-  end
-end
diff --git a/app/views/projects/show.api.rsb b/app/views/projects/show.api.rsb
new file mode 100644 (file)
index 0000000..4479e50
--- /dev/null
@@ -0,0 +1,22 @@
+api.project do
+  api.id          @project.id
+  api.name        @project.name
+  api.identifier  @project.identifier
+  api.description @project.description
+  api.homepage    @project.homepage
+  
+  api.array :custom_fields do
+    @project.visible_custom_field_values.each do |custom_value|
+      api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
+    end
+  end unless @project.custom_field_values.empty?
+  
+  api.created_on @project.created_on
+  api.updated_on @project.updated_on
+  
+  api.array :trackers do
+    @project.trackers.each do |tracker|
+      api.tracker(:id => tracker.id, :name => tracker.name)
+    end
+  end
+end
diff --git a/app/views/projects/show.apit b/app/views/projects/show.apit
deleted file mode 100644 (file)
index 4479e50..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-api.project do
-  api.id          @project.id
-  api.name        @project.name
-  api.identifier  @project.identifier
-  api.description @project.description
-  api.homepage    @project.homepage
-  
-  api.array :custom_fields do
-    @project.visible_custom_field_values.each do |custom_value|
-      api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
-    end
-  end unless @project.custom_field_values.empty?
-  
-  api.created_on @project.created_on
-  api.updated_on @project.updated_on
-  
-  api.array :trackers do
-    @project.trackers.each do |tracker|
-      api.tracker(:id => tracker.id, :name => tracker.name)
-    end
-  end
-end
diff --git a/app/views/timelog/index.api.rsb b/app/views/timelog/index.api.rsb
new file mode 100644 (file)
index 0000000..0367e06
--- /dev/null
@@ -0,0 +1,16 @@
+api.array :time_entries do
+  @entries.each do |time_entry|
+    api.time_entry do
+      api.id time_entry.id
+      api.project(:id => time_entry.project_id, :name => time_entry.project.name) unless time_entry.project.nil?
+      api.issue(:id => time_entry.issue_id) unless time_entry.issue.nil?
+      api.user(:id => time_entry.user_id, :name => time_entry.user.name) unless time_entry.user.nil?
+      api.activity(:id => time_entry.activity_id, :name => time_entry.activity.name) unless time_entry.activity.nil?
+      api.hours time_entry.hours
+      api.comments time_entry.comments
+      api.spent_on time_entry.spent_on
+      api.created_on time_entry.created_on
+      api.updated_on time_entry.updated_on
+    end
+  end
+end
diff --git a/app/views/timelog/index.apit b/app/views/timelog/index.apit
deleted file mode 100644 (file)
index 0367e06..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-api.array :time_entries do
-  @entries.each do |time_entry|
-    api.time_entry do
-      api.id time_entry.id
-      api.project(:id => time_entry.project_id, :name => time_entry.project.name) unless time_entry.project.nil?
-      api.issue(:id => time_entry.issue_id) unless time_entry.issue.nil?
-      api.user(:id => time_entry.user_id, :name => time_entry.user.name) unless time_entry.user.nil?
-      api.activity(:id => time_entry.activity_id, :name => time_entry.activity.name) unless time_entry.activity.nil?
-      api.hours time_entry.hours
-      api.comments time_entry.comments
-      api.spent_on time_entry.spent_on
-      api.created_on time_entry.created_on
-      api.updated_on time_entry.updated_on
-    end
-  end
-end
diff --git a/app/views/timelog/show.api.rsb b/app/views/timelog/show.api.rsb
new file mode 100644 (file)
index 0000000..d5d3c5d
--- /dev/null
@@ -0,0 +1,12 @@
+api.time_entry do
+  api.id @time_entry.id
+  api.project(:id => @time_entry.project_id, :name => @time_entry.project.name) unless @time_entry.project.nil?
+  api.issue(:id => @time_entry.issue_id) unless @time_entry.issue.nil?
+  api.user(:id => @time_entry.user_id, :name => @time_entry.user.name) unless @time_entry.user.nil?
+  api.activity(:id => @time_entry.activity_id, :name => @time_entry.activity.name) unless @time_entry.activity.nil?
+  api.hours @time_entry.hours
+  api.comments @time_entry.comments
+  api.spent_on @time_entry.spent_on
+  api.created_on @time_entry.created_on
+  api.updated_on @time_entry.updated_on
+end
diff --git a/app/views/timelog/show.apit b/app/views/timelog/show.apit
deleted file mode 100644 (file)
index d5d3c5d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-api.time_entry do
-  api.id @time_entry.id
-  api.project(:id => @time_entry.project_id, :name => @time_entry.project.name) unless @time_entry.project.nil?
-  api.issue(:id => @time_entry.issue_id) unless @time_entry.issue.nil?
-  api.user(:id => @time_entry.user_id, :name => @time_entry.user.name) unless @time_entry.user.nil?
-  api.activity(:id => @time_entry.activity_id, :name => @time_entry.activity.name) unless @time_entry.activity.nil?
-  api.hours @time_entry.hours
-  api.comments @time_entry.comments
-  api.spent_on @time_entry.spent_on
-  api.created_on @time_entry.created_on
-  api.updated_on @time_entry.updated_on
-end
diff --git a/app/views/users/index.api.rsb b/app/views/users/index.api.rsb
new file mode 100644 (file)
index 0000000..815abef
--- /dev/null
@@ -0,0 +1,19 @@
+api.array :users do
+  @users.each do |user|
+    api.user do
+      api.id         user.id
+      api.login      user.login
+      api.firstname  user.firstname
+      api.lastname   user.lastname
+      api.mail       user.mail
+      api.created_on user.created_on
+      api.last_login_on user.last_login_on
+
+      api.array :custom_fields do
+        user.visible_custom_field_values.each do |custom_value|
+          api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
+        end
+      end unless user.visible_custom_field_values.empty?
+    end
+  end
+end
diff --git a/app/views/users/index.apit b/app/views/users/index.apit
deleted file mode 100644 (file)
index 815abef..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-api.array :users do
-  @users.each do |user|
-    api.user do
-      api.id         user.id
-      api.login      user.login
-      api.firstname  user.firstname
-      api.lastname   user.lastname
-      api.mail       user.mail
-      api.created_on user.created_on
-      api.last_login_on user.last_login_on
-
-      api.array :custom_fields do
-        user.visible_custom_field_values.each do |custom_value|
-          api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
-        end
-      end unless user.visible_custom_field_values.empty?
-    end
-  end
-end
diff --git a/app/views/users/show.api.rsb b/app/views/users/show.api.rsb
new file mode 100644 (file)
index 0000000..6c3dd90
--- /dev/null
@@ -0,0 +1,28 @@
+api.user do
+  api.id         @user.id
+  api.login      @user.login if User.current.admin?
+  api.firstname  @user.firstname
+  api.lastname   @user.lastname
+  api.mail       @user.mail if User.current.admin? || !@user.pref.hide_mail
+  api.created_on @user.created_on
+  api.last_login_on @user.last_login_on
+  
+  api.array :custom_fields do
+    @user.visible_custom_field_values.each do |custom_value|
+      api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
+    end
+  end unless @user.visible_custom_field_values.empty?
+  
+  api.array :memberships do
+    @memberships.each do |membership|
+      api.membership do
+        api.project :id => membership.project.id, :name => membership.project.name
+        api.array :roles do
+          membership.roles.each do |role|
+            api.role :id => role.id, :name => role.name
+          end
+        end
+      end if membership.project
+    end
+  end if @memberships.present?
+end
diff --git a/app/views/users/show.apit b/app/views/users/show.apit
deleted file mode 100644 (file)
index 6c3dd90..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-api.user do
-  api.id         @user.id
-  api.login      @user.login if User.current.admin?
-  api.firstname  @user.firstname
-  api.lastname   @user.lastname
-  api.mail       @user.mail if User.current.admin? || !@user.pref.hide_mail
-  api.created_on @user.created_on
-  api.last_login_on @user.last_login_on
-  
-  api.array :custom_fields do
-    @user.visible_custom_field_values.each do |custom_value|
-      api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name
-    end
-  end unless @user.visible_custom_field_values.empty?
-  
-  api.array :memberships do
-    @memberships.each do |membership|
-      api.membership do
-        api.project :id => membership.project.id, :name => membership.project.name
-        api.array :roles do
-          membership.roles.each do |role|
-            api.role :id => role.id, :name => role.name
-          end
-        end
-      end if membership.project
-    end
-  end if @memberships.present?
-end
index b5a9a57c5a3dc323219fbe1cf2dec3c83f0aa9ef..7fcd7647367490e2797b97d6e50d0aaaa6fd8b77 100644 (file)
@@ -230,4 +230,4 @@ Redmine::WikiFormatting.map do |format|
   format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper
 end
 
-ActionView::Template.register_template_handler :apit, Redmine::Views::ApiTemplateHandler
+ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler