Re-implement deactivate with HTTP DELETE

This commit is contained in:
Tim Van Baak 2023-05-29 18:54:57 -07:00
parent 466ce50e3c
commit da24d23eb7
2 changed files with 13 additions and 6 deletions

View File

@ -74,6 +74,17 @@ def source_feed(source_name):
) )
@app.delete("/item/<string:source_name>/<string:item_id>")
def deactivate(source_name, item_id):
source = LocalSource(intake_data_dir(), source_name)
item = source.get_item(item_id)
if item["active"]:
print(f"Deactivating {source_name}/{item_id}")
item["active"] = False
source.save_item(item)
return jsonify({"active": item["active"]})
def wsgi(): def wsgi():
# init_default_logging() # init_default_logging()
return app return app

View File

@ -60,12 +60,8 @@ table.feed-control td {
</style> </style>
<script> <script>
var deactivate = function (source, itemid) { var deactivate = function (source, itemid) {
fetch('/deactivate/', { fetch(`/item/${source}/${itemid}`, {
method: 'POST', method: 'DELETE',
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
body: JSON.stringify({source: source, itemid: itemid}),
}) })
.then(response => response.json()) .then(response => response.json())
.then(function (data) { .then(function (data) {