Skip to content

Commit

Permalink
Merge pull request #1225 from hanshuaikang/feature/develop_by_han
Browse files Browse the repository at this point in the history
bugfix: 修复get_service_roles 顺序的问题
  • Loading branch information
hanshuaikang authored Oct 31, 2023
2 parents 35f895f + c14eba1 commit c21c055
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion itsm/openapi/service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def get_service_roles(self, request):
workflow = self.queryset.get(id=service_id).workflow
# 获取第一个提单节点的id
first_state = workflow.first_state
# 根据提单节点 通过路径 乡下搜索,获得正确的state顺序
# 根据提单节点 通过路径 向下搜索,获得正确的state顺序
states = workflow.post_states(first_state["id"])

# 全量数据下,将提单节点插入第一个
Expand Down
5 changes: 4 additions & 1 deletion itsm/workflow/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
from collections import OrderedDict

import six

import jsonfield
Expand Down Expand Up @@ -571,6 +573,7 @@ def post_states(self, from_id):
if from_id in path:
from_id_index = path.index(from_id)
state_id_list.extend(path[from_id_index + 1 :])

state_list = []
common_type = [
NORMAL_STATE,
Expand All @@ -579,7 +582,7 @@ def post_states(self, from_id):
TASK_STATE,
TASK_SOPS_STATE,
]
for state_id in set(state_id_list):
for state_id in list(OrderedDict.fromkeys(state_id_list)):
state_info = self.states[str(state_id)]
if state_info["type"] in common_type:
state_list.append(state_info)
Expand Down

0 comments on commit c21c055

Please sign in to comment.