Share code for creating tickets
This commit is contained in:
parent
ab0f3f843a
commit
b3383c542a
1 changed files with 18 additions and 27 deletions
45
rt2zammad.py
45
rt2zammad.py
|
@ -197,37 +197,28 @@ for ticket in tickets:
|
||||||
creator = get_user(users[ticket["ticket"]["Creator"]])
|
creator = get_user(users[ticket["ticket"]["Creator"]])
|
||||||
print(f"Importing {label} ({creator})")
|
print(f"Importing {label} ({creator})")
|
||||||
|
|
||||||
|
create_args = {
|
||||||
|
"title": "{} [{}]".format(ticket["ticket"]["Subject"], label),
|
||||||
|
"group": "Users",
|
||||||
|
"customer": creator,
|
||||||
|
"note": "RT-import:{}".format(ticket["ticket"]["original_id"]),
|
||||||
|
"article": {
|
||||||
|
"subject": ticket["ticket"]["Subject"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
if ticket["ticket"]["original_id"] != ticket["ticket"]["numerical_id"]:
|
if ticket["ticket"]["original_id"] != ticket["ticket"]["numerical_id"]:
|
||||||
# Merged ticket
|
# Merged ticket
|
||||||
get_zammad(creator).ticket.create(
|
create_args["state_id"] = 4
|
||||||
{
|
create_args["article"]["body"] = "RT ticket merged into {}".format(
|
||||||
"title": "{} [{}]".format(ticket["ticket"]["Subject"], label),
|
|
||||||
"group": "Users",
|
|
||||||
"state_id": 4,
|
|
||||||
"customer": creator,
|
|
||||||
"note": "RT-import:{}".format(ticket["ticket"]["original_id"]),
|
|
||||||
"article": {
|
|
||||||
"subject": ticket["ticket"]["Subject"],
|
|
||||||
"body": "RT ticket merged into {}".format(
|
|
||||||
ticket["ticket"]["numerical_id"]
|
ticket["ticket"]["numerical_id"]
|
||||||
),
|
)
|
||||||
},
|
get_zammad(creator).ticket.create(create_args)
|
||||||
}
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
new = get_zammad(creator).ticket.create(
|
create_args["state_id"] = STATUSMAP[ticket["ticket"]["Status"]]
|
||||||
{
|
create_args["article"]["body"] = ticket["history"][0]["Content"]
|
||||||
"title": "{} [{}]".format(ticket["ticket"]["Subject"], label),
|
new = get_zammad(creator).ticket.create(create_args)
|
||||||
"group": "Users",
|
print(f"Created ticket {new['id']}")
|
||||||
"state_id": STATUSMAP[ticket["ticket"]["Status"]],
|
|
||||||
"customer": creator,
|
|
||||||
"note": "RT-import:{}".format(ticket["ticket"]["original_id"]),
|
|
||||||
"article": {
|
|
||||||
"subject": ticket["ticket"]["Subject"],
|
|
||||||
"body": ticket["history"][0]["Content"],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
tag_obj.add("Ticket", new["id"], ticket["ticket"]["Queue"].lower().split()[0])
|
tag_obj.add("Ticket", new["id"], ticket["ticket"]["Queue"].lower().split()[0])
|
||||||
ticket_article.create(
|
ticket_article.create(
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue