From 7ee5b8bbc9c31e2743befc7081d087d196ac881a Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 30 May 2023 12:50:53 -0700 Subject: [PATCH] Make mass deactivate work --- intake/app.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/intake/app.py b/intake/app.py index 5a5eefc..4d1addf 100644 --- a/intake/app.py +++ b/intake/app.py @@ -78,7 +78,7 @@ def source_feed(source_name): now=int(time.time()), mdeac=[ {"source": item["source"], "itemid": item["id"]} - for item in all_items + for item in sorted_items if "id" in item ], ) @@ -109,6 +109,23 @@ def update(source_name, item_id): return jsonify(item) +@app.post("/mass-deactivate/") +def mass_deactivate(): + params = request.get_json() + if "items" not in params: + print(f"Bad request params: {params}") + for info in params.get("items"): + source = info["source"] + itemid = info["itemid"] + source = LocalSource(intake_data_dir(), source) + item = source.get_item(itemid) + if item["active"]: + print(f"Deactivating {info['source']}/{info['itemid']}") + item["active"] = False + source.save_item(item) + return jsonify({}) + + def wsgi(): # init_default_logging() return app