53 строки
1.3 KiB
Python
53 строки
1.3 KiB
Python
import config
|
|
from jira import JIRA, Issue
|
|
from models import date, Subcategory, TimeRange
|
|
|
|
|
|
jira = JIRA(
|
|
basic_auth=(
|
|
config.Jira.username,
|
|
config.Jira.token,
|
|
),
|
|
server=config.Jira.server,
|
|
)
|
|
|
|
|
|
time_ranges = {
|
|
1: ('T09:00:00.000+0300', 'T12:00:00.000+0300'),
|
|
2: ('T12:00:00.000+0300', 'T15:00:00.000+0300'),
|
|
3: ('T15:00:00.000+0300', 'T18:00:00.000+0300'),
|
|
}
|
|
|
|
|
|
async def create_issue(
|
|
subcategory: Subcategory,
|
|
_date: date,
|
|
time_range: TimeRange,
|
|
email_address: str,
|
|
phone_number: str,
|
|
comment: str,
|
|
firstname: str,
|
|
) -> Issue:
|
|
return jira.create_issue(
|
|
project='SFX',
|
|
summary='Задача от %s' % firstname,
|
|
issuetype={
|
|
'name': 'Telegram API',
|
|
},
|
|
customfield_10033={
|
|
'value': subcategory.category.name,
|
|
'child': {
|
|
'value': subcategory.name,
|
|
},
|
|
},
|
|
customfield_10035='%s%s' % (str(_date), time_ranges[time_range.id][0]),
|
|
customfield_10036='%s%s' % (str(_date), time_ranges[time_range.id][1]),
|
|
customfield_10037=email_address,
|
|
customfield_10038=phone_number,
|
|
customfield_10039=comment,
|
|
)
|
|
|
|
|
|
async def read_issue(issue_id: str):
|
|
return jira.issue(issue_id)
|