✨ add template variables for 'days_since_last_update' and 'assigned_to'
This commit is contained in:
parent
5f63efebe1
commit
c93fc9f959
4 changed files with 18 additions and 5 deletions
|
@ -4,7 +4,7 @@ redmine:
|
||||||
url: ${REDMINE_URL}
|
url: ${REDMINE_URL}
|
||||||
version: ${REDMINE_VERSION}
|
version: ${REDMINE_VERSION}
|
||||||
api_key: ${REDMINE_API_KEY}
|
api_key: ${REDMINE_API_KEY}
|
||||||
issue_closed_id: 5 # Id of the "closed" status
|
time_zone: "Europe/Berlin"
|
||||||
no_bot_tag: "#nobot" # a tag that signals bot not to handle an issue
|
no_bot_tag: "#nobot" # a tag that signals bot not to handle an issue
|
||||||
|
|
||||||
actions:
|
actions:
|
||||||
|
|
10
main.py
10
main.py
|
@ -1,7 +1,8 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from datetime import date, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
import pytz
|
||||||
import logging
|
import logging
|
||||||
from redminelib import Redmine
|
from redminelib import Redmine
|
||||||
from envyaml import EnvYAML
|
from envyaml import EnvYAML
|
||||||
|
@ -24,6 +25,7 @@ def treat_issues():
|
||||||
url = config['redmine']['url']
|
url = config['redmine']['url']
|
||||||
version = config['redmine']['version']
|
version = config['redmine']['version']
|
||||||
api_key = config['redmine']['api_key']
|
api_key = config['redmine']['api_key']
|
||||||
|
time_zone = pytz.timezone(config['redmine']['time_zone'])
|
||||||
no_bot_tag = config['redmine']['no_bot_tag']
|
no_bot_tag = config['redmine']['no_bot_tag']
|
||||||
actions = config['actions']
|
actions = config['actions']
|
||||||
logging.getLogger().setLevel(config['logging']['level'].upper())
|
logging.getLogger().setLevel(config['logging']['level'].upper())
|
||||||
|
@ -62,7 +64,11 @@ def treat_issues():
|
||||||
with open(f"{dir_path}templates/{action['template']}", newline='\r\n') as f:
|
with open(f"{dir_path}templates/{action['template']}", newline='\r\n') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
template = Template(content)
|
template = Template(content)
|
||||||
notes = template.render(author=issue.author.name, time_range=action['time_range'], url=issue.url)
|
notes = template.render(
|
||||||
|
issue=issue,
|
||||||
|
time_range=action['time_range'],
|
||||||
|
days_since_last_update=(datetime.now(time_zone) - issue.updated_on.replace(tzinfo=time_zone)).days
|
||||||
|
)
|
||||||
|
|
||||||
# Update issue
|
# Update issue
|
||||||
if action.get('close_ticket') is True:
|
if action.get('close_ticket') is True:
|
||||||
|
|
|
@ -8,3 +8,4 @@ python-redmine==2.3.0
|
||||||
PyYAML==5.4.1
|
PyYAML==5.4.1
|
||||||
requests==2.25.1
|
requests==2.25.1
|
||||||
urllib3==1.26.5
|
urllib3==1.26.5
|
||||||
|
pytz~=2021.3
|
|
@ -1,6 +1,12 @@
|
||||||
Hello {{ author }},
|
{% if issue.assigned_to is defined %}
|
||||||
|
Hello {{ issue.assigned_to }},
|
||||||
|
|
||||||
this ticket wasn't updated for at least {{ time_range }}. We therefore assume that the problem has been solved in the meantime. If the issue persists, please reopen the ticket and give us a brief update on the situation.
|
this ticket is assigned to you but wasn't updated for at least {{ days_since_last_update }}. We therefore assume that the problem has been solved in the meantime. If the issue persists, please reopen the ticket and give us a brief update on the situation.
|
||||||
|
{% else %}
|
||||||
|
Hello {{ issue.author }},
|
||||||
|
|
||||||
|
this ticket wasn't updated for at least {{ days_since_last_update }}. We therefore assume that the problem has been solved in the meantime. If the issue persists, please reopen the ticket and give us a brief update on the situation.
|
||||||
|
{% endif %}
|
||||||
Here is the ticket: {{ url }}
|
Here is the ticket: {{ url }}
|
||||||
|
|
||||||
Yours sincerely
|
Yours sincerely
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue