プロジェクト

全般

プロフィール

Vote #74575

未完了

Tracker change : status not updated if no available status in new tracker

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Issues_2
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
2
version_id:
0
issue_org_id:
15292
author_id:
36999
assigned_to_id:
0
comments:
0
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
72
ステータス-->[New]

説明

safe_attributes 'status_id' uses the following if Proc to test :
issue.new_statuses_allowed_to(user).any?

The problem is, at this time issue is not already updated by the issue_attributes
Thus even if the update_form ajax proposed a new compatible status (without adding a flash message by the way), this status change is refused by safe_attributes.

In fact, I don't know why, but in the if Proc, issue already has the new tracker value, but with the old status, leading to new_statuses_allowed_to empty.

I have made a fix, to insert in the issues controller, but I suppose you will find something quite more elegant :

      if (
        issue_attributes.include?('tracker_id') &&
        issue_attributes.include?('status_id')
      )
        old_tracker_id = @issue.tracker_id
        old_status_id = @issue.status_id

        @issue.tracker_id = issue_attributes['tracker_id']
        @issue.status_id = issue_attributes['status_id']
        if (
          @issue.safe_attribute?('tracker_id') &&
          @issue.safe_attribute?('status_id')
        )
          issue_attributes.delete('tracker_id')
          issue_attributes.delete('status_id')
        else
          @issue.tracker_id = old_tracker_id
          @issue.status_id = old_status_id
        end
      end

      @issue.safe_attributes = issue_attributes

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0