Fix creating owned tickets

This commit is contained in:
Michal Čihař 2020-12-30 13:14:41 +01:00
parent b06e01a774
commit ab0f3f843a

View file

@ -194,14 +194,17 @@ def get_user(userdata, attr="login", default=None):
# Create tickets # Create tickets
for ticket in tickets: for ticket in tickets:
label = "RT-{}".format(ticket["ticket"]["original_id"]) label = "RT-{}".format(ticket["ticket"]["original_id"])
print("Importing {}".format(label)) creator = get_user(users[ticket["ticket"]["Creator"]])
print(f"Importing {label} ({creator})")
if ticket["ticket"]["original_id"] != ticket["ticket"]["numerical_id"]: if ticket["ticket"]["original_id"] != ticket["ticket"]["numerical_id"]:
# Merged ticket # Merged ticket
get_zammad(get_user(users[ticket["ticket"]["Creator"]])).ticket.create( get_zammad(creator).ticket.create(
{ {
"title": "{} [{}]".format(ticket["ticket"]["Subject"], label), "title": "{} [{}]".format(ticket["ticket"]["Subject"], label),
"group": "Users", "group": "Users",
"state_id": 4, "state_id": 4,
"customer": creator,
"note": "RT-import:{}".format(ticket["ticket"]["original_id"]), "note": "RT-import:{}".format(ticket["ticket"]["original_id"]),
"article": { "article": {
"subject": ticket["ticket"]["Subject"], "subject": ticket["ticket"]["Subject"],
@ -212,11 +215,12 @@ for ticket in tickets:
} }
) )
continue continue
new = get_zammad(get_user(users[ticket["ticket"]["Creator"]])).ticket.create( new = get_zammad(creator).ticket.create(
{ {
"title": "{} [{}]".format(ticket["ticket"]["Subject"], label), "title": "{} [{}]".format(ticket["ticket"]["Subject"], label),
"group": "Users", "group": "Users",
"state_id": STATUSMAP[ticket["ticket"]["Status"]], "state_id": STATUSMAP[ticket["ticket"]["Status"]],
"customer": creator,
"note": "RT-import:{}".format(ticket["ticket"]["original_id"]), "note": "RT-import:{}".format(ticket["ticket"]["original_id"]),
"article": { "article": {
"subject": ticket["ticket"]["Subject"], "subject": ticket["ticket"]["Subject"],