Adds atom feed on time entries details (#1479).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1560 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d991e46f12
commit
062a2d6f5d
|
@ -154,6 +154,14 @@ class TimelogController < ApplicationController
|
||||||
|
|
||||||
render :layout => !request.xhr?
|
render :layout => !request.xhr?
|
||||||
}
|
}
|
||||||
|
format.atom {
|
||||||
|
entries = TimeEntry.find(:all,
|
||||||
|
:include => [:project, :activity, :user, {:issue => :tracker}],
|
||||||
|
:conditions => cond.conditions,
|
||||||
|
:order => "#{TimeEntry.table_name}.created_on DESC",
|
||||||
|
:limit => Setting.feeds_limit.to_i)
|
||||||
|
render_feed(entries, :title => l(:label_spent_time))
|
||||||
|
}
|
||||||
format.csv {
|
format.csv {
|
||||||
# Export all entries
|
# Export all entries
|
||||||
@entries = TimeEntry.find(:all,
|
@entries = TimeEntry.find(:all,
|
||||||
|
|
|
@ -24,6 +24,11 @@ class TimeEntry < ActiveRecord::Base
|
||||||
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
belongs_to :activity, :class_name => 'Enumeration', :foreign_key => :activity_id
|
||||||
|
|
||||||
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
|
||||||
|
|
||||||
|
acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
|
||||||
|
:url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
|
||||||
|
:author => :user,
|
||||||
|
:description => :comments
|
||||||
|
|
||||||
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
|
||||||
validates_numericality_of :hours, :allow_nil => true
|
validates_numericality_of :hours, :allow_nil => true
|
||||||
|
|
|
@ -24,8 +24,13 @@
|
||||||
|
|
||||||
<p class="other-formats">
|
<p class="other-formats">
|
||||||
<%= l(:label_export_to) %>
|
<%= l(:label_export_to) %>
|
||||||
|
<span><%= link_to 'Atom', {:issue_id => @issue, :format => 'atom', :key => User.current.rss_key}, :class => 'feed' %></span>
|
||||||
<span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span>
|
<span><%= link_to 'CSV', params.merge(:format => 'csv'), :class => 'csv' %></span>
|
||||||
</p>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% html_title l(:label_spent_time), l(:label_details) %>
|
<% html_title l(:label_spent_time), l(:label_details) %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, {:issue_id => @issue, :format => 'atom', :key => User.current.rss_key}, :title => l(:label_spent_time)) %>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -210,6 +210,14 @@ class TimelogControllerTest < Test::Unit::TestCase
|
||||||
assert_equal '2007-04-22'.to_date, assigns(:to)
|
assert_equal '2007-04-22'.to_date, assigns(:to)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_details_atom_feed
|
||||||
|
get :details, :project_id => 1, :format => 'atom'
|
||||||
|
assert_response :success
|
||||||
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
|
assert_not_nil assigns(:items)
|
||||||
|
assert assigns(:items).first.is_a?(TimeEntry)
|
||||||
|
end
|
||||||
|
|
||||||
def test_details_csv_export
|
def test_details_csv_export
|
||||||
get :details, :project_id => 1, :format => 'csv'
|
get :details, :project_id => 1, :format => 'csv'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
Loading…
Reference in New Issue