From 677dfdc88332aaf11c668a1d64b814dd3ac93e81 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Tue, 26 Nov 2019 06:31:04 +0000 Subject: replace multi line block "{}" to "do end" in app/controllers/issues_controller.rb git-svn-id: http://svn.redmine.org/redmine/trunk@19319 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 56 ++++++++++++++-------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 8c5a356ae..4565ec031 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -47,33 +47,33 @@ class IssuesController < ApplicationController if @query.valid? respond_to do |format| - format.html { + format.html do @issue_count = @query.issue_count @issue_pages = Paginator.new @issue_count, per_page_option, params['page'] @issues = @query.issues(:offset => @issue_pages.offset, :limit => @issue_pages.per_page) render :layout => !request.xhr? - } - format.api { + end + format.api do @offset, @limit = api_offset_and_limit @query.column_names = %w(author) @issue_count = @query.issue_count @issues = @query.issues(:offset => @offset, :limit => @limit) Issue.load_visible_relations(@issues) if include_in_api_response?('relations') - } - format.atom { + end + format.atom do @issues = @query.issues(:limit => Setting.feeds_limit.to_i) render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") - } - format.csv { + end + format.csv do @issues = @query.issues(:limit => Setting.issues_export_limit.to_i) send_data(query_to_csv(@issues, @query, params[:csv]), :type => 'text/csv; header=present', :filename => 'issues.csv') - } - format.pdf { + end + format.pdf do @issues = @query.issues(:limit => Setting.issues_export_limit.to_i) send_file_headers! :type => 'application/pdf', :filename => 'issues.pdf' - } + end end else respond_to do |format| @@ -91,9 +91,9 @@ class IssuesController < ApplicationController @has_changesets = @issue.changesets.visible.preload(:repository, :user).exists? @relations = @issue.relations. - select {|r| + select do |r| r.other_issue(@issue) && r.other_issue(@issue).visible? - } + end @journals.reverse! if User.current.wants_comments_in_reverse_order? if User.current.allowed_to?(:view_time_entries, @project) @@ -102,7 +102,7 @@ class IssuesController < ApplicationController end respond_to do |format| - format.html { + format.html do @allowed_statuses = @issue.new_statuses_allowed_to(User.current) @priorities = IssuePriority.active @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @@ -110,19 +110,19 @@ class IssuesController < ApplicationController @relation = IssueRelation.new retrieve_previous_and_next_issue_ids render :template => 'issues/show' - } - format.api { + end + format.api do @changesets = @issue.changesets.visible.preload(:repository, :user).to_a @changesets.reverse! if User.current.wants_comments_in_reverse_order? - } - format.atom { + end + format.atom do render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' - } - format.pdf { + end + format.pdf do send_file_headers!(:type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") - } + end end end @@ -143,29 +143,29 @@ class IssuesController < ApplicationController if @issue.save call_hook(:controller_issues_new_after_save, {:params => params, :issue => @issue}) respond_to do |format| - format.html { + format.html do render_attachment_warning_if_needed(@issue) flash[:notice] = l(:notice_issue_successful_create, :id => view_context.link_to("##{@issue.id}", issue_path(@issue), :title => @issue.subject)) redirect_after_create - } - format.api { + end + format.api do render :action => 'show', :status => :created, :location => issue_url(@issue) - } + end end return else respond_to do |format| - format.html { + format.html do if @issue.project.nil? render_error :status => 422 else render :action => 'new' end - } + end format.api {render_validation_errors(@issue)} end end @@ -204,11 +204,11 @@ class IssuesController < ApplicationController flash[:notice] = l(:notice_successful_update) end respond_to do |format| - format.html { + format.html do redirect_back_or_default( issue_path(@issue, previous_and_next_issue_ids_params) ) - } + end format.api {render_api_ok} end else -- 2.17.1 From f6dced19152b78a7b47b17534d9b4461ab37df0f Mon Sep 17 00:00:00 2001 From: Ashwin Date: Wed, 27 Nov 2019 07:33:52 +0000 Subject: Added feature to restrict logging time for past dates --- app/models/time_entry.rb | 3 +++ app/views/settings/_timelog.html.erb | 2 ++ config/locales/en-GB.yml | 1 + config/locales/en.yml | 1 + config/settings.yml | 3 +++ 5 files changed, 10 insertions(+) diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 38359294d..3908a682c 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -133,6 +133,9 @@ class TimeEntry < ActiveRecord::Base errors.add :hours, :invalid if hours < 0 errors.add :hours, :invalid if hours == 0.0 && hours_changed? && !Setting.timelog_accept_0_hours? + days_diff = (Date.today - spent_on) + errors.add :spent_on, :invalid if days_diff.to_i > Setting.timelog_max_days_before.to_i + max_hours = Setting.timelog_max_hours_per_day.to_f if hours_changed? && max_hours > 0.0 logged_hours = other_hours_with_same_user_and_day diff --git a/app/views/settings/_timelog.html.erb b/app/views/settings/_timelog.html.erb index 01d42384b..c4daa5951 100644 --- a/app/views/settings/_timelog.html.erb +++ b/app/views/settings/_timelog.html.erb @@ -6,6 +6,8 @@

<%= setting_text_field :timelog_max_hours_per_day, :size => 6 %>

+

<%= setting_text_field :timelog_max_days_before, :size => 6 %>

+

<%= setting_check_box :timelog_accept_0_hours %>

<%= setting_check_box :timelog_accept_future_dates %>

diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 27bc085a8..2e5188a96 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1236,6 +1236,7 @@ en-GB: same day (%{logged_hours} hours have already been logged) setting_time_entry_list_defaults: Timelog list defaults setting_timelog_accept_0_hours: Accept time logs with 0 hours + setting_timelog_max_days_before: How many days in the past can timelogs be added setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user label_x_revisions: "%{count} revisions" error_can_not_delete_auth_source: This authentication mode is in use and cannot be diff --git a/config/locales/en.yml b/config/locales/en.yml index 031c7ba87..a322a516f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -482,6 +482,7 @@ en: setting_time_entry_list_defaults: Timelog list defaults setting_timelog_accept_0_hours: Accept time logs with 0 hours setting_timelog_max_hours_per_day: Maximum hours that can be logged per day and user + setting_timelog_max_days_before: How many days in the past can timelogs be added setting_timelog_accept_future_dates: Accept time logs on future dates setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject setting_project_list_defaults: Projects list defaults diff --git a/config/settings.yml b/config/settings.yml index b5fc64747..e97667059 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -324,6 +324,9 @@ timelog_accept_0_hours: timelog_max_hours_per_day: format: int default: 999 +timelog_max_days_before: + format: int + default: 999 timelog_accept_future_dates: default: 1 show_status_changes_in_mail_subject: -- 2.17.1