From e7f8884b7bf3077910c8e9e94a5fccb32e055d76 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 22 Oct 2021 11:32:26 +0100 Subject: [PATCH] Add support for changing Wikidata tag on OSM object --- web_view.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_view.py b/web_view.py index cfbe63f..8549da0 100755 --- a/web_view.py +++ b/web_view.py @@ -662,7 +662,7 @@ def oauth_callback(): def validate_edit_list(edits): for e in edits: assert model.Item.get_by_qid(e["qid"]) - assert e["op"] in {"add", "remove"} + assert e["op"] in {"add", "remove", "change"} osm_type, _, osm_id = e['osm'].partition('/') osm_id = int(osm_id) if osm_type == 'node': @@ -744,6 +744,8 @@ def process_edit(changeset_id, e): root[0].append(tag) if e["op"] == "remove": root[0].remove(existing) + if e["op"] == "change": + existing.set("v", qid) element_data = etree.tostring(root) try: @@ -761,7 +763,7 @@ def process_edit(changeset_id, e): return "element-error" new_tags = dict(osm.tags) - if e["op"] == "add": + if e["op"] in ("add", "change"): new_tags["wikidata"] = qid if e["op"] == "remove": del new_tags["wikidata"]