From 4f62a1662d807b27940e5d9a8e53717397d1b3b7 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Mon, 9 Aug 2021 15:17:02 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=EF=B8=8F=20add=20ability=20to=20chang?= =?UTF-8?q?e=20ticket=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also setting the 'close_ticket' entry is no longer necessary --- example_config.yaml | 4 ++-- main.py | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/example_config.yaml b/example_config.yaml index c0b9c17..1edbed1 100644 --- a/example_config.yaml +++ b/example_config.yaml @@ -4,7 +4,7 @@ redmine: url: ${REDMINE_URL} version: ${REDMINE_VERSION} api_key: ${REDMINE_API_KEY} - issue_closed_id: "5" # Id of the "closed" status + issue_closed_id: 5 # Id of the "closed" status actions: @@ -26,7 +26,7 @@ actions: - "IT Tickets" status: - "In revision" - close_ticket: false + change_status_to: 4 template: "nudge_ticket" diff --git a/main.py b/main.py index f25ad65..db7e428 100644 --- a/main.py +++ b/main.py @@ -52,9 +52,12 @@ def treat_issues(): notes = template.render(author=issue.author.name, time_range=action['time_range'], url=issue.url) # Update issue - if action['close_ticket']: + if action.get('close_ticket') is True: redmine.issue.update(issue.id, notes=notes, status_id=config['redmine']['issue_closed_id']) logging.info(f"Ticket ID: {issue.id}, ticket closed") + elif action.get('change_status_to') is not None and isinstance(action.get('change_status_to'), int): + redmine.issue.update(issue.id, notes=notes, status_id=action['change_status_to']) + logging.info(f"Ticket ID: {issue.id}, changed ticket status") else: redmine.issue.update(issue.id, notes=notes) logging.info(f"Ticket ID: {issue.id}")