Send slack message on claim
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful
This commit is contained in:
parent
24bc46e098
commit
cb2c9e31a1
@ -422,15 +422,26 @@ def view_inventory_audit(item_id):
|
||||
@login_required
|
||||
def view_inventory_claim(item_id):
|
||||
user = read_user()
|
||||
db.inventory.update_one({
|
||||
item = db.inventory.find_one({
|
||||
"_id": ObjectId(item_id),
|
||||
"inventory.owner.username": None
|
||||
})
|
||||
if not item:
|
||||
return abort(404)
|
||||
|
||||
db.inventory.update_one({
|
||||
"_id": ObjectId(item["_id"])
|
||||
}, {
|
||||
"$set": {
|
||||
"inventory.owner.username": user["username"],
|
||||
"inventory.owner.display_name": user["name"],
|
||||
},
|
||||
})
|
||||
item_name = format_name(item)
|
||||
msg = "%s has claimed %s" % (user["name"], item_name)
|
||||
if item.get("shortener") and item["shortener"].get("slug"):
|
||||
msg += ("\nk6.ee/%s" % item["shortener"]["slug"])
|
||||
spam(msg, channel)
|
||||
return redirect("/m/inventory/%s/view" % item_id)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user