class TimelogController < ApplicationController
menu_item :issues
before_filter :find_project, :authorize, :only => [:edit, :destroy]
- before_filter :find_optional_project, :only => [:details]
+ before_filter :find_optional_project, :only => [:index]
- verify :method => :post, :only => :destroy, :redirect_to => { :action => :details }
+ verify :method => :post, :only => :destroy, :redirect_to => { :action => :index }
helper :sort
include SortHelper
helper :custom_fields
include CustomFieldsHelper
- def details
+ def index
sort_init 'spent_on', 'desc'
sort_update 'spent_on' => 'spent_on',
'user' => 'user_id',
if request.post? and @time_entry.save
flash[:notice] = l(:notice_successful_update)
- redirect_back_or_default :action => 'details', :project_id => @time_entry.project
+ redirect_back_or_default :action => 'index', :project_id => @time_entry.project
return
end
end
end
redirect_to :back
rescue ::ActionController::RedirectBackError
- redirect_to :action => 'details', :project_id => @time_entry.project
+ redirect_to :action => 'index', :project_id => @time_entry.project
end
private
<th class="category"><%=l(:field_category)%>:</th><td class="category"><%=h @issue.category ? @issue.category.name : "-" %></td>
<% if User.current.allowed_to?(:view_time_entries, @project) %>
<th class="spent-time"><%=l(:label_spent_time)%>:</th>
- <td class="spent-time"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue}) : "-" %></td>
+ <td class="spent-time"><%= @issue.spent_hours > 0 ? (link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue}) : "-" %></td>
<% end %>
</tr>
<tr>
<% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
<h3><%= l(:label_spent_time) %></h3>
<p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
- <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> |
+ <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'index', :project_id => @project}) %> |
<%= link_to(l(:label_report), {:controller => 'time_entry_reports', :action => 'report', :project_id => @project}) %></p>
<% end %>
<%= call_hook(:view_projects_show_sidebar_bottom, :project => @project) %>
<div class="tabs">
<% url_params = @free_period ? { :from => @from, :to => @to } : { :period => params[:period] } %>
<ul>
- <li><%= link_to(l(:label_details), url_params.merge({:controller => 'timelog', :action => 'details', :project_id => @project, :issue_id => @issue }),
- :class => (@controller.action_name == 'details' ? 'selected' : nil)) %></li>
+ <li><%= link_to(l(:label_details), url_params.merge({:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue }),
+ :class => (@controller.action_name == 'index' ? 'selected' : nil)) %></li>
<li><%= link_to(l(:label_report), url_params.merge({:controller => 'time_entry_reports', :action => 'report', :project_id => @project, :issue_id => @issue}),
:class => (@controller.action_name == 'report' ? 'selected' : nil)) %></li>
</ul>
+++ /dev/null
-<div class="contextual">
-<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %>
-</div>
-
-<%= render_timelog_breadcrumb %>
-
-<h2><%= l(:label_spent_time) %></h2>
-
-<% form_remote_tag( :url => {}, :html => {:method => :get, :id => 'query_form'}, :method => :get, :update => 'content' ) do %>
-<%# TOOD: remove the project_id and issue_id hidden fields, that information is
-already in the URI %>
-<%= hidden_field_tag('project_id', params[:project_id]) if @project %>
-<%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
-<%= render :partial => 'date_range' %>
-<% end %>
-
-<div class="total-hours">
-<p><%= l(:label_total) %>: <%= html_hours(l_hours(@total_hours)) %></p>
-</div>
-
-<% unless @entries.empty? %>
-<%= render :partial => 'list', :locals => { :entries => @entries }%>
-<p class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></p>
-
-<% other_formats_links do |f| %>
- <%= f.link_to 'Atom', :url => params.merge({:issue_id => @issue, :key => User.current.rss_key}) %>
- <%= f.link_to 'CSV', :url => params %>
-<% end %>
-<% end %>
-
-<% 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 %>
--- /dev/null
+<div class="contextual">
+<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time-add' %>
+</div>
+
+<%= render_timelog_breadcrumb %>
+
+<h2><%= l(:label_spent_time) %></h2>
+
+<% form_remote_tag( :url => {}, :html => {:method => :get, :id => 'query_form'}, :method => :get, :update => 'content' ) do %>
+<%# TOOD: remove the project_id and issue_id hidden fields, that information is
+already in the URI %>
+<%= hidden_field_tag('project_id', params[:project_id]) if @project %>
+<%= hidden_field_tag 'issue_id', params[:issue_id] if @issue %>
+<%= render :partial => 'date_range' %>
+<% end %>
+
+<div class="total-hours">
+<p><%= l(:label_total) %>: <%= html_hours(l_hours(@total_hours)) %></p>
+</div>
+
+<% unless @entries.empty? %>
+<%= render :partial => 'list', :locals => { :entries => @entries }%>
+<p class="pagination"><%= pagination_links_full @entry_pages, @entry_count %></p>
+
+<% other_formats_links do |f| %>
+ <%= f.link_to 'Atom', :url => params.merge({:issue_id => @issue, :key => User.current.rss_key}) %>
+ <%= f.link_to 'CSV', :url => params %>
+<% end %>
+<% end %>
+
+<% 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 %>
map.connect 'projects/:project_id/issues/:issue_id/time_entries/new', :action => 'edit', :controller => 'timelog'
map.with_options :controller => 'timelog' do |timelog|
- timelog.connect 'projects/:project_id/time_entries', :action => 'details'
+ timelog.connect 'projects/:project_id/time_entries', :action => 'index'
- timelog.with_options :action => 'details', :conditions => {:method => :get} do |time_details|
+ timelog.with_options :action => 'index', :conditions => {:method => :get} do |time_details|
time_details.connect 'time_entries'
time_details.connect 'time_entries.:format'
time_details.connect 'issues/:issue_id/time_entries'
map.project_module :time_tracking do |map|
map.permission :log_time, {:timelog => :edit}, :require => :loggedin
- map.permission :view_time_entries, :timelog => [:details], :time_entry_reports => [:report]
+ map.permission :view_time_entries, :timelog => [:index], :time_entry_reports => [:report]
map.permission :edit_time_entries, {:timelog => [:edit, :destroy]}, :require => :member
map.permission :edit_own_time_entries, {:timelog => [:edit, :destroy]}, :require => :loggedin
map.permission :manage_project_activities, {:project_enumerations => [:update, :destroy]}, :require => :member
:spent_on => '2008-03-14',
:issue_id => '1',
:hours => '7.3'}
- assert_redirected_to :action => 'details', :project_id => 'ecookbook'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
i = Issue.find(1)
t = TimeEntry.find_by_comments('Some work on TimelogControllerTest')
post :edit, :id => 1,
:time_entry => {:issue_id => '2',
:hours => '8'}
- assert_redirected_to :action => 'details', :project_id => 'ecookbook'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
entry.reload
assert_equal 8, entry.hours
def test_destroy
@request.session[:user_id] = 2
post :destroy, :id => 1
- assert_redirected_to :action => 'details', :project_id => 'ecookbook'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_successful_delete), flash[:notice]
assert_nil TimeEntry.find_by_id(1)
end
@request.session[:user_id] = 2
post :destroy, :id => 1
- assert_redirected_to :action => 'details', :project_id => 'ecookbook'
+ assert_redirected_to :action => 'index', :project_id => 'ecookbook'
assert_equal I18n.t(:notice_unable_delete_time_entry), flash[:error]
assert_not_nil TimeEntry.find_by_id(1)
TimeEntry.before_destroy.reject! {|callback| callback.method == :stop_callback_chain }
end
- def test_details_all_projects
- get :details
+ def test_index_all_projects
+ get :index
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:total_hours)
assert_equal "162.90", "%.2f" % assigns(:total_hours)
end
- def test_details_at_project_level
- get :details, :project_id => 1
+ def test_index_at_project_level
+ get :index, :project_id => 1
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:entries)
assert_equal 4, assigns(:entries).size
# project and subproject
assert_equal '2007-04-22'.to_date, assigns(:to)
end
- def test_details_at_project_level_with_date_range
- get :details, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30'
+ def test_index_at_project_level_with_date_range
+ get :index, :project_id => 1, :from => '2007-03-20', :to => '2007-04-30'
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:entries)
assert_equal 3, assigns(:entries).size
assert_not_nil assigns(:total_hours)
assert_equal '2007-04-30'.to_date, assigns(:to)
end
- def test_details_at_project_level_with_period
- get :details, :project_id => 1, :period => '7_days'
+ def test_index_at_project_level_with_period
+ get :index, :project_id => 1, :period => '7_days'
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:entries)
assert_not_nil assigns(:total_hours)
assert_equal Date.today - 7, assigns(:from)
assert_equal Date.today, assigns(:to)
end
- def test_details_one_day
- get :details, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23"
+ def test_index_one_day
+ get :index, :project_id => 1, :from => "2007-03-23", :to => "2007-03-23"
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:total_hours)
assert_equal "4.25", "%.2f" % assigns(:total_hours)
end
- def test_details_at_issue_level
- get :details, :issue_id => 1
+ def test_index_at_issue_level
+ get :index, :issue_id => 1
assert_response :success
- assert_template 'details'
+ assert_template 'index'
assert_not_nil assigns(:entries)
assert_equal 2, assigns(:entries).size
assert_not_nil assigns(:total_hours)
assert_equal '2007-04-22'.to_date, assigns(:to)
end
- def test_details_atom_feed
- get :details, :project_id => 1, :format => 'atom'
+ def test_index_atom_feed
+ get :index, :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_all_projects_csv_export
+ def test_index_all_projects_csv_export
Setting.date_format = '%m/%d/%Y'
- get :details, :format => 'csv'
+ get :index, :format => 'csv'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n")
end
- def test_details_csv_export
+ def test_index_csv_export
Setting.date_format = '%m/%d/%Y'
- get :details, :project_id => 1, :format => 'csv'
+ get :index, :project_id => 1, :format => 'csv'
assert_response :success
assert_equal 'text/csv', @response.content_type
assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n")
end
context "timelogs" do
+ should_route :get, "/time_entries", :controller => 'timelog', :action => 'index'
+ should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'index', :format => 'csv'
+ should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'index', :format => 'atom'
+ should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'index', :project_id => '567'
+ should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'csv'
+ should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'index', :project_id => '567', :format => 'atom'
+ should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'index', :issue_id => '234'
+ should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'csv'
+ should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'index', :issue_id => '234', :format => 'atom'
+ should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :issue_id => '123'
+
should_route :get, "/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :issue_id => '567'
should_route :get, "/projects/ecookbook/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook'
should_route :get, "/projects/ecookbook/issues/567/time_entries/new", :controller => 'timelog', :action => 'edit', :project_id => 'ecookbook', :issue_id => '567'
should_route :get, "/time_entries/report", :controller => 'time_entry_reports', :action => 'report'
should_route :get, "/projects/567/time_entries/report", :controller => 'time_entry_reports', :action => 'report', :project_id => '567'
should_route :get, "/projects/567/time_entries/report.csv", :controller => 'time_entry_reports', :action => 'report', :project_id => '567', :format => 'csv'
-
- should_route :get, "/time_entries", :controller => 'timelog', :action => 'details'
- should_route :get, "/time_entries.csv", :controller => 'timelog', :action => 'details', :format => 'csv'
- should_route :get, "/time_entries.atom", :controller => 'timelog', :action => 'details', :format => 'atom'
- should_route :get, "/projects/567/time_entries", :controller => 'timelog', :action => 'details', :project_id => '567'
- should_route :get, "/projects/567/time_entries.csv", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'csv'
- should_route :get, "/projects/567/time_entries.atom", :controller => 'timelog', :action => 'details', :project_id => '567', :format => 'atom'
- should_route :get, "/issues/234/time_entries", :controller => 'timelog', :action => 'details', :issue_id => '234'
- should_route :get, "/issues/234/time_entries.csv", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'csv'
- should_route :get, "/issues/234/time_entries.atom", :controller => 'timelog', :action => 'details', :issue_id => '234', :format => 'atom'
- should_route :get, "/projects/ecookbook/issues/123/time_entries", :controller => 'timelog', :action => 'details', :project_id => 'ecookbook', :issue_id => '123'
-
end
context "users" do