| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Redmine
Revision: 1779
Author: jplang
Date: 31 Aug 2008 12:45:46
Changes:Sync with trunk r1778.
Files:| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -2,6 +2,8 @@ | |
| 2 | 2 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time' %> |
| 3 | 3 | </div> |
| 4 | 4 | |
| 5 | <%= render_timelog_breadcrumb %> | |
| 6 | ||
| 5 | 7 | <h2><%= l(:label_spent_time) %></h2> |
| 6 | 8 | |
| 7 | 9 | <% form_remote_tag(:url => {}, :update => 'content') do %> |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -19,6 +19,7 @@ | |
| 19 | 19 | def administration_settings_tabs |
| 20 | 20 | tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general}, |
| 21 | 21 | {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication}, |
| 22 | {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural}, | |
| 22 | 23 | {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking}, |
| 23 | 24 | {:name => 'notifications', :partial => 'settings/notifications', :label => l(:field_mail_notification)}, |
| 24 | 25 | {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => l(:label_incoming_emails)}, |
| ... | ...@@ -269,7 +269,7 @@ | |
| 269 | 269 | elsif options[:global] |
| 270 | 270 | # authorize if user has at least one role that has this permission |
| 271 | 271 | roles = memberships.collect {|m| m.role}.uniq |
| 272 | roles.detect {|r| r.allowed_to?(action)} | |
| 272 | roles.detect {|r| r.allowed_to?(action)} || (self.logged? ? Role.non_member.allowed_to?(action) : Role.anonymous.allowed_to?(action)) | |
| 273 | 273 | else |
| 274 | 274 | false |
| 275 | 275 | end |
| ... | ...@@ -78,7 +78,7 @@ | |
| 78 | 78 | assert_equal 2, entry.user_id |
| 79 | 79 | end |
| 80 | 80 | |
| 81 | def destroy | |
| 81 | def test_destroy | |
| 82 | 82 | @request.session[:user_id] = 2 |
| 83 | 83 | post :destroy, :id => 1 |
| 84 | 84 | assert_redirected_to 'projects/ecookbook/timelog/details' |
| ... | ...@@ -91,6 +91,29 @@ | |
| 91 | 91 | assert_template 'report' |
| 92 | 92 | end |
| 93 | 93 | |
| 94 | def test_report_all_projects | |
| 95 | get :report | |
| 96 | assert_response :success | |
| 97 | assert_template 'report' | |
| 98 | end | |
| 99 | ||
| 100 | def test_report_all_projects_denied | |
| 101 | r = Role.anonymous | |
| 102 | r.permissions.delete(:view_time_entries) | |
| 103 | r.permissions_will_change! | |
| 104 | r.save | |
| 105 | get :report | |
| 106 | assert_redirected_to '/account/login' | |
| 107 | end | |
| 108 | ||
| 109 | def test_report_all_projects_one_criteria | |
| 110 | get :report, :columns => 'week', :from => "2007-04-01", :to => "2007-04-30", :criterias => ['project'] | |
| 111 | assert_response :success | |
| 112 | assert_template 'report' | |
| 113 | assert_not_nil assigns(:total_hours) | |
| 114 | assert_equal "8.65", "%.2f" % assigns(:total_hours) | |
| 115 | end | |
| 116 | ||
| 94 | 117 | def test_report_all_time |
| 95 | 118 | get :report, :project_id => 1, :criterias => ['project', 'issue'] |
| 96 | 119 | assert_response :success |
| ... | ...@@ -148,7 +171,18 @@ | |
| 148 | 171 | assert_not_nil assigns(:total_hours) |
| 149 | 172 | assert_equal "0.00", "%.2f" % assigns(:total_hours) |
| 150 | 173 | end |
| 151 | ||
| 174 | ||
| 175 | def test_report_all_projects_csv_export | |
| 176 | get :report, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv" | |
| 177 | assert_response :success | |
| 178 | assert_equal 'text/csv', @response.content_type | |
| 179 | lines = @response.body.chomp.split("\n") | |
| 180 | # Headers | |
| 181 | assert_equal 'Project,Member,Activity,2007-1,2007-2,2007-3,2007-4,2007-5,2007-6,Total', lines.first | |
| 182 | # Total row | |
| 183 | assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last | |
| 184 | end | |
| 185 | ||
| 152 | 186 | def test_report_csv_export |
| 153 | 187 | get :report, :project_id => 1, :columns => 'month', :from => "2007-01-01", :to => "2007-06-30", :criterias => ["project", "member", "activity"], :format => "csv" |
| 154 | 188 | assert_response :success |
| ... | ...@@ -159,6 +193,14 @@ | |
| 159 | 193 | # Total row |
| 160 | 194 | assert_equal 'Total,"","","","",154.25,8.65,"","",162.90', lines.last |
| 161 | 195 | end |
| 196 | ||
| 197 | def test_details_all_projects | |
| 198 | get :details | |
| 199 | assert_response :success | |
| 200 | assert_template 'details' | |
| 201 | assert_not_nil assigns(:total_hours) | |
| 202 | assert_equal "162.90", "%.2f" % assigns(:total_hours) | |
| 203 | end | |
| 162 | 204 | |
| 163 | 205 | def test_details_at_project_level |
| 164 | 206 | get :details, :project_id => 1 |
| ... | ...@@ -218,6 +260,14 @@ | |
| 218 | 260 | assert assigns(:items).first.is_a?(TimeEntry) |
| 219 | 261 | end |
| 220 | 262 | |
| 263 | def test_details_all_projects_csv_export | |
| 264 | get :details, :format => 'csv' | |
| 265 | assert_response :success | |
| 266 | assert_equal 'text/csv', @response.content_type | |
| 267 | assert @response.body.include?("Date,User,Activity,Project,Issue,Tracker,Subject,Hours,Comment\n") | |
| 268 | assert @response.body.include?("\n04/21/2007,redMine Admin,Design,eCookbook,3,Bug,Error 281 when updating a recipe,1.0,\"\"\n") | |
| 269 | end | |
| 270 | ||
| 221 | 271 | def test_details_csv_export |
| 222 | 272 | get :details, :project_id => 1, :format => 'csv' |
| 223 | 273 | assert_response :success |
| ... | ...@@ -2,11 +2,9 @@ | |
| 2 | 2 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time' %> |
| 3 | 3 | </div> |
| 4 | 4 | |
| 5 | <h2><%= l(:label_spent_time) %></h2> | |
| 5 | <%= render_timelog_breadcrumb %> | |
| 6 | 6 | |
| 7 | <% if @issue %> | |
| 8 | <h3><%= link_to(@project.name, {:action => 'details', :project_id => @project}) %> / <%= link_to_issue(@issue) %></h3> | |
| 9 | <% end %> | |
| 7 | <h2><%= l(:label_spent_time) %></h2> | |
| 10 | 8 | |
| 11 | 9 | <% form_remote_tag( :url => {}, :method => :get, :update => 'content' ) do %> |
| 12 | 10 | <%= hidden_field_tag 'project_id', params[:project_id] %> |
| ... | ...@@ -220,6 +220,7 @@ | |
| 220 | 220 | setting_enabled_scm: SCM activés |
| 221 | 221 | setting_mail_handler_api_enabled: "Activer le WS pour la réception d'emails" |
| 222 | 222 | setting_mail_handler_api_key: Clé de protection de l'API |
| 223 | setting_sequential_project_identifiers: Générer des identifiants de projet séquentiels | |
| 223 | 224 | |
| 224 | 225 | project_module_issue_tracking: Suivi des demandes |
| 225 | 226 | project_module_time_tracking: Suivi du temps passé |
| ... | ...@@ -22,7 +22,7 @@ | |
| 22 | 22 | map.connect 'projects/:project_id/news/:action', :controller => 'news' |
| 23 | 23 | map.connect 'projects/:project_id/documents/:action', :controller => 'documents' |
| 24 | 24 | map.connect 'projects/:project_id/boards/:action/:id', :controller => 'boards' |
| 25 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog' | |
| 25 | map.connect 'projects/:project_id/timelog/:action/:id', :controller => 'timelog', :project_id => /.+/ | |
| 26 | 26 | map.connect 'boards/:board_id/topics/:action/:id', :controller => 'messages' |
| 27 | 27 | |
| 28 | 28 | map.with_options :controller => 'repositories' do |omap| |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -95,11 +95,15 @@ | |
| 95 | 95 | end |
| 96 | 96 | true |
| 97 | 97 | end |
| 98 | ||
| 99 | def deny_access | |
| 100 | User.current.logged? ? render_403 : require_login | |
| 101 | end | |
| 98 | 102 | |
| 99 | 103 | # Authorize the user for the requested action |
| 100 | 104 | def authorize(ctrl = params[:controller], action = params[:action]) |
| 101 | 105 | allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project) |
| 102 | allowed ? true : (User.current.logged? ? render_403 : require_login) | |
| 106 | allowed ? true : deny_access | |
| 103 | 107 | end |
| 104 | 108 | |
| 105 | 109 | # make sure that the user is a member of the project (or admin) if project is private |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -639,3 +639,4 @@ | |
| 639 | 639 | label_issue_watchers: Watchers |
| 640 | 640 | setting_commit_logs_encoding: Commit messages encoding |
| 641 | 641 | button_quote: Quote |
| 642 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -639,3 +639,4 @@ | |
| 639 | 639 | label_issue_watchers: Watchers |
| 640 | 640 | setting_commit_logs_encoding: Commit messages encoding |
| 641 | 641 | button_quote: Quote |
| 642 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | enumeration_doc_categories: 文档类别 |
| 638 | 638 | enumeration_activities: 活动(时间跟踪) |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -130,4 +130,15 @@ | |
| 130 | 130 | assert_equal [1, 2, 3], parent.rolled_up_trackers.collect(&:id) |
| 131 | 131 | assert_equal [2, 3], child.rolled_up_trackers.collect(&:id) |
| 132 | 132 | end |
| 133 | ||
| 134 | def test_next_identifier | |
| 135 | ProjectCustomField.delete_all | |
| 136 | Project.create!(:name => 'last', :identifier => 'p2008040') | |
| 137 | assert_equal 'p2008041', Project.next_identifier | |
| 138 | end | |
| 139 | ||
| 140 | def test_next_identifier_first_project | |
| 141 | Project.delete_all | |
| 142 | assert_nil Project.next_identifier | |
| 143 | end | |
| 133 | 144 | end |
| ... | ...@@ -118,6 +118,8 @@ | |
| 118 | 118 | default: 1 |
| 119 | 119 | default_projects_public: |
| 120 | 120 | default: 1 |
| 121 | sequential_project_identifiers: | |
| 122 | default: 0 | |
| 121 | 123 | # encodings used to convert repository files content to UTF-8 |
| 122 | 124 | # multiple values accepted, comma separated |
| 123 | 125 | repositories_encodings: |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -640,3 +640,4 @@ | |
| 640 | 640 | label_issue_watchers: Watchers |
| 641 | 641 | setting_commit_logs_encoding: Commit messages encoding |
| 642 | 642 | button_quote: Quote |
| 643 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -239,6 +239,12 @@ | |
| 239 | 239 | enabled_modules << EnabledModule.new(:name => name.to_s) |
| 240 | 240 | end |
| 241 | 241 | end |
| 242 | ||
| 243 | # Returns an auto-generated project identifier based on the last identifier used | |
| 244 | def self.next_identifier | |
| 245 | p = Project.find(:first, :order => 'created_on DESC') | |
| 246 | p.nil? ? nil : p.identifier.to_s.succ | |
| 247 | end | |
| 242 | 248 | |
| 243 | 249 | protected |
| 244 | 250 | def validate |
| ... | ...@@ -46,9 +46,6 @@ | |
| 46 | 46 | |
| 47 | 47 | <p><label><%= l(:setting_feeds_limit) %></label> |
| 48 | 48 | <%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p> |
| 49 | ||
| 50 | <p><label><%= l(:setting_default_projects_public) %></label> | |
| 51 | <%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p> | |
| 52 | 49 | </div> |
| 53 | 50 | |
| 54 | 51 | <%= submit_tag l(:button_save) %> |
| ... | ...@@ -16,6 +16,14 @@ | |
| 16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | 17 | |
| 18 | 18 | module TimelogHelper |
| 19 | def render_timelog_breadcrumb | |
| 20 | links = [] | |
| 21 | links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil}) | |
| 22 | links << link_to(h(@project), {:project_id => @project, :issue_id => nil}) if @project | |
| 23 | links << link_to_issue(@issue) if @issue | |
| 24 | breadcrumb links | |
| 25 | end | |
| 26 | ||
| 19 | 27 | def activity_collection_for_select_options |
| 20 | 28 | activities = Enumeration::get_values('ACTI') |
| 21 | 29 | collection = [] |
| ... | ...@@ -220,6 +220,7 @@ | |
| 220 | 220 | setting_enabled_scm: Enabled SCM |
| 221 | 221 | setting_mail_handler_api_enabled: Enable WS for incoming emails |
| 222 | 222 | setting_mail_handler_api_key: API key |
| 223 | setting_sequential_project_identifiers: Generate sequential project identifiers | |
| 223 | 224 | |
| 224 | 225 | project_module_issue_tracking: Issue tracking |
| 225 | 226 | project_module_time_tracking: Time tracking |
| ... | ...@@ -69,6 +69,7 @@ | |
| 69 | 69 | :order => 'name') |
| 70 | 70 | @project = Project.new(params[:project]) |
| 71 | 71 | if request.get? |
| 72 | @project.identifier = Project.next_identifier if Setting.sequential_project_identifiers? | |
| 72 | 73 | @project.trackers = Tracker.all |
| 73 | 74 | @project.is_public = Setting.default_projects_public? |
| 74 | 75 | @project.enabled_module_names = Redmine::AccessControl.available_project_modules |
| ... | ...@@ -641,3 +641,4 @@ | |
| 641 | 641 | label_issue_watchers: Watchers |
| 642 | 642 | setting_commit_logs_encoding: Commit messages encoding |
| 643 | 643 | button_quote: Quote |
| 644 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -200,7 +200,7 @@ | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | my $method = $r->method; |
| 203 | return OK if defined $read_only_methods{$method}; | |
| 203 | return OK unless defined $read_only_methods{$method}; | |
| 204 | 204 | |
| 205 | 205 | my $project_id = get_project_identifier($r); |
| 206 | 206 |
| ... | ...@@ -639,3 +639,4 @@ | |
| 639 | 639 | label_issue_watchers: Watchers |
| 640 | 640 | setting_commit_logs_encoding: Commit messages encoding |
| 641 | 641 | button_quote: Quote |
| 642 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -0,0 +1,12 @@ | |
| 1 | <% form_tag({:action => 'edit', :tab => 'projects'}) do %> | |
| 2 | ||
| 3 | <div class="box tabular settings"> | |
| 4 | <p><label><%= l(:setting_default_projects_public) %></label> | |
| 5 | <%= check_box_tag 'settings[default_projects_public]', 1, Setting.default_projects_public? %><%= hidden_field_tag 'settings[default_projects_public]', 0 %></p> | |
| 6 | ||
| 7 | <p><label><%= l(:setting_sequential_project_identifiers) %></label> | |
| 8 | <%= check_box_tag 'settings[sequential_project_identifiers]', 1, Setting.sequential_project_identifiers? %><%= hidden_field_tag 'settings[sequential_project_identifiers]', 0 %></p> | |
| 9 | </div> | |
| 10 | ||
| 11 | <%= submit_tag l(:button_save) %> | |
| 12 | <% end %> |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -17,7 +17,8 @@ | |
| 17 | 17 | |
| 18 | 18 | class TimelogController < ApplicationController |
| 19 | 19 | menu_item :issues |
| 20 | before_filter :find_project, :authorize | |
| 20 | before_filter :find_project, :authorize, :only => [:edit, :destroy] | |
| 21 | before_filter :find_optional_project, :only => [:report, :details] | |
| 21 | 22 | |
| 22 | 23 | verify :method => :post, :only => :destroy, :redirect_to => { :action => :details } |
| 23 | 24 | |
| ... | ...@@ -53,11 +54,12 @@ | |
| 53 | 54 | } |
| 54 | 55 | |
| 55 | 56 | # Add list and boolean custom fields as available criterias |
| 56 | @project.all_issue_custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| | |
| 57 | custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields) | |
| 58 | custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf| | |
| 57 | 59 | @available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'Issue' AND c.customized_id = #{Issue.table_name}.id)", |
| 58 | 60 | :format => cf.field_format, |
| 59 | 61 | :label => cf.name} |
| 60 | end | |
| 62 | end if @project | |
| 61 | 63 | |
| 62 | 64 | # Add list and boolean time entry custom fields |
| 63 | 65 | TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf| |
| ... | ...@@ -83,9 +85,10 @@ | |
| 83 | 85 | sql << " FROM #{TimeEntry.table_name}" |
| 84 | 86 | sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" |
| 85 | 87 | sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id" |
| 86 | sql << " WHERE (%s)" % @project.project_condition(Setting.display_subprojects_issues?) | |
| 87 | sql << " AND (%s)" % Project.allowed_to_condition(User.current, :view_time_entries) | |
| 88 | sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@from.to_time), ActiveRecord::Base.connection.quoted_date(@to.to_time)] | |
| 88 | sql << " WHERE" | |
| 89 | sql << " (%s) AND" % @project.project_condition(Setting.display_subprojects_issues?) if @project | |
| 90 | sql << " (%s) AND" % Project.allowed_to_condition(User.current, :view_time_entries) | |
| 91 | sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from.to_time), ActiveRecord::Base.connection.quoted_date(@to.to_time)] | |
| 89 | 92 | sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on" |
| 90 | 93 | |
| 91 | 94 | @hours = ActiveRecord::Base.connection.select_all(sql) |
| ... | ...@@ -138,8 +141,13 @@ | |
| 138 | 141 | sort_update |
| 139 | 142 | |
| 140 | 143 | cond = ARCondition.new |
| 141 | cond << (@issue.nil? ? @project.project_condition(Setting.display_subprojects_issues?) : | |
| 142 | ["#{TimeEntry.table_name}.issue_id = ?", @issue.id]) | |
| 144 | if @project.nil? | |
| 145 | cond << Project.allowed_to_condition(User.current, :view_time_entries) | |
| 146 | elsif @issue.nil? | |
| 147 | cond << @project.project_condition(Setting.display_subprojects_issues?) | |
| 148 | else | |
| 149 | cond << ["#{TimeEntry.table_name}.issue_id = ?", @issue.id] | |
| 150 | end | |
| 143 | 151 | |
| 144 | 152 | retrieve_date_range |
| 145 | 153 | cond << ['spent_on BETWEEN ? AND ?', @from, @to] |
| ... | ...@@ -197,7 +205,7 @@ | |
| 197 | 205 | @time_entry.destroy |
| 198 | 206 | flash[:notice] = l(:notice_successful_delete) |
| 199 | 207 | redirect_to :back |
| 200 | rescue RedirectBackError | |
| 208 | rescue ::ActionController::RedirectBackError | |
| 201 | 209 | redirect_to :action => 'details', :project_id => @time_entry.project |
| 202 | 210 | end |
| 203 | 211 | |
| ... | ...@@ -219,6 +227,16 @@ | |
| 219 | 227 | render_404 |
| 220 | 228 | end |
| 221 | 229 | |
| 230 | def find_optional_project | |
| 231 | if !params[:issue_id].blank? | |
| 232 | @issue = Issue.find(params[:issue_id]) | |
| 233 | @project = @issue.project | |
| 234 | elsif !params[:project_id].blank? | |
| 235 | @project = Project.find(params[:project_id]) | |
| 236 | end | |
| 237 | deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true) | |
| 238 | end | |
| 239 | ||
| 222 | 240 | # Retrieves the date range based on predefined ranges or specific from/to param dates |
| 223 | 241 | def retrieve_date_range |
| 224 | 242 | @free_period = false |
| ... | ...@@ -261,7 +279,7 @@ | |
| 261 | 279 | end |
| 262 | 280 | |
| 263 | 281 | @from, @to = @to, @from if @from && @to && @from > @to |
| 264 | @from ||= (TimeEntry.minimum(:spent_on, :include => :project, :conditions => @project.project_condition(Setting.display_subprojects_issues?)) || Date.today) - 1 | |
| 265 | @to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => @project.project_condition(Setting.display_subprojects_issues?)) || Date.today) | |
| 282 | @from ||= (TimeEntry.minimum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) - 1 | |
| 283 | @to ||= (TimeEntry.maximum(:spent_on, :include => :project, :conditions => Project.allowed_to_condition(User.current, :view_time_entries)) || Date.today) | |
| 266 | 284 | end |
| 267 | 285 | end |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -638,3 +638,4 @@ | |
| 638 | 638 | label_issue_watchers: Watchers |
| 639 | 639 | setting_commit_logs_encoding: Commit messages encoding |
| 640 | 640 | button_quote: Quote |
| 641 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -638,3 +638,4 @@ | |
| 638 | 638 | label_issue_watchers: Watchers |
| 639 | 639 | setting_commit_logs_encoding: Commit messages encoding |
| 640 | 640 | button_quote: Quote |
| 641 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -636,3 +636,4 @@ | |
| 636 | 636 | label_issue_watchers: Watchers |
| 637 | 637 | setting_commit_logs_encoding: Commit messages encoding |
| 638 | 638 | button_quote: Quote |
| 639 | setting_sequential_project_identifiers: Generate sequential project identifiers |
| ... | ...@@ -637,3 +637,4 @@ | |
| 637 | 637 | label_issue_watchers: Watchers |
| 638 | 638 | setting_commit_logs_encoding: Commit messages encoding |
| 639 | 639 | button_quote: Quote |
| 640 | setting_sequential_project_identifiers: Generate sequential project identifiers |